zabbix部署
系统环境为CentOS7.
网络配置
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=75cb6d32-d068-4edf-b67e-7d860e94404b
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.1.227
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=114.114.114.114
DNS2=8.8.8.8
[root@localhost ~]# systemctl restart network.service
关闭防火墙,开机禁止起动防火墙
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
关闭selinux
[root@localhost ~]# vi /etc/selinux/config
SELINUX=disabled
重启系统
准备安装zabbix
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# yum -y install wget
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
[root@localhost yum.repos.d]# mv CentOS7-Base-163.repo CentOS7-Base.repo
[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum makecache
安装http,mariadb,php
[root@localhost ~]# yum -y install mariadb mariadb-server httpd php php-mysql
[root@localhost ~]# systemctl start httpd.service
[root@localhost ~]# systemctl enable httpd.service
[root@localhost ~]# systemctl start mariadb.service
[root@localhost ~]# systemctl enable mariadb.service
[root@localhost ~]# mysql_secure_installation #初始化数据库。
Enter current password for root (enter for none):
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
Remove anonymous users? [Y/n] y
... Success!
Disallow root login remotely? [Y/n] y
... Success!
Remove test database and access to it? [Y/n] n
... skipping.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
安装zabbix程序
[root@localhost yum.repos.d]# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
[root@localhost yum.repos.d]# rpm -import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@localhost ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
数据库配置
[root@localhost ~]# mysql -u root -p
Enter password: #123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 5.5.64-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database zabbix default character set utf8 collate utf8_bin
-> ;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'
-> ;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
读入数据库
[root@localhost ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/
[root@localhost zabbix-server-mysql-3.4.15]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@localhost zabbix-server-mysql-3.2.11]# zcat create.sql.gz |mysql -uroot -p zabbix
Enter password:
启动zabbix服务
[root@localhost ~]# vi /etc/zabbix/zabbix_server.conf
91 DBHost=localhost
100 DBName=zabbix
116 DBSchema=zabbix
124 DBPassword=zabbix
[root@localhost ~]# systemctl start zabbix-server
[root@localhost ~]# systemctl enable zabbix-server.service
编辑zabbix前端php配置
[root@localhost ~]# vi /etc/httpd/conf.d/zabbix.conf
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value max_input_vars 10000
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
</IfModule>
调整时间同步
[root@localhost ~]# yum -y install ntp
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 127.127.1.0
fudge 127.127.1.0 stratum 10
[root@localhost ~]# systemctl restart ntpd.service
[root@localhost ~]# systemctl enable ntpd.service
重启httpd服务
[root@localhost html]# systemctl restart httpd.service
浏览器访问:192.168.1.227/zabbix
点击Next step
点击Next step
用户名为:Admin。密码:zabbix。
附一:修改admin密码
1 [root@imxhy01 ~]# echo -n admin | openssl md5 2 (stdin)= 21232f297a57a5a743894a0e4a801fc3 #admin经过md5生成的加密的密码 3 [root@imxhy01 ~]# mysql -u root -p #进入数据库 4 MariaDB [(none)]> use zabbix; #选择zabbix数据库 5 MariaDB [zabbix]> select * from users; #查看users用户表可知Admin用户的ID为1,passwd为一串加密的密码 6 MariaDB [zabbix]> update users set passwd='21232f297a57a5a743894a0e4a801fc3' where userid = '1'; #将userid为1的用户即Admin的密码更新。 7 MariaDB [(none)]> flush privileges; #刷新权限即可 8 MariaDB [(none)]> exit;
点击adminstration,点users,点admin
添加本机为监控对象
[root@localhost html]# vi /etc/zabbix/zabbix_agentd.conf
Server=192.168.1.227 #服务器IP地址
ServerActive=192.168.1.227
Hostname=192.168.1.207
[root@localhost html]# systemctl restart zabbix-agent
[root@localhost html]# systemctl enable zabbix-agent
网页端创建本机被监控
配置-->主机-->创建主机
模板选择
配置-->主机-->创建主机-->模板
点击监控中--->图型
如果中文显示有乱码,可以导入windows字体
[root@localhost ~]# mv AdobeHeitiStd-Regular.otf AdobeHeitiStd-Regular.ttf
[root@localhost ~]# mv AdobeHeitiStd-Regular.ttf /usr/share/zabbix/fonts/
[root@localhost ~]# chmod 777 /usr/share/zabbix/fonts/AdobeHeitiStd-Regular.ttf
[root@localhost ~]# cd /usr/share/zabbix/include/
[root@localhost include]# vi defines.inc.php
define('ZBX_GRAPH_FONT_NAME', 'AdobeHeitiStd-Regular'); // font file name
重新刷新就好了。
监控windows主机
下载Zabbix_agents_3.4.6win,解压并修改配置件。
修改zabbix_agentd.win.conf文件内容
Server=192.168.1.227 #zabbix服务器地址
ServerActive=192.168.1.227 #zabbix服务器地址
Hostname=192.168.1.6 #windows主机地址
创建windows主机
创建linux被主机
[root@localhost ~]# ls
anaconda-ks.cfg install.log install.log.syslog zabbix-agent-3.2.6-1.el6.x86_64.rpm
[root@localhost ~]# yum -y install zabbix-agent-3.2.6-1.el6.x86_64.rpm
[root@localhost ~]# vi /etc/zabbix/zabbix_agentd.conf
Server=192.168.1.227
ServerActive=192.168.1.227
Hostname=192.168.1.211
[root@localhost ~]# service zabbix-agent restart #启动服务。
Shutting down Zabbix agent: [失败]
Starting Zabbix agent: [确定]
添加主机和上面一样。