zabbix on CentOS 7
zabbix:2.0,2.2,2.4
epel
zabbix20
zabbix22
Linux开源监控系统:
nagios
cacti
zabbix:
ganglia
zabbix-2.4
mariadb
实验环境:
主机名称:node1.smoke.com master
操作系统:CentOS 7.5
内核版本:3.10.0-862.el7.x86_64
网卡1:vmnet0 172.16.100.67
网卡2:vmnet8 dhcp
主机名称:node2.smoke.com
操作系统:CentOS 7.5
内核版本:3.10.0-862.el7.x86_64
网卡1:vmnet0 172.16.100.68
网卡2:vmnet8 dhcp
主机名称:node3.smoke.com
操作系统:Windows xp
网卡1:172.16.100.69
系统配置:
node1:zabbix-server
[root@node1 ~]# hostname
node1.smoke.com
[root@node1 ~]# ip addr show
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:67:e5:70 brd ff:ff:ff:ff:ff:ff
inet 172.16.100.67/24 brd 172.16.100.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::7382:eaed:fa1f:633f/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: ens37: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:67:e5:7a brd ff:ff:ff:ff:ff:ff
inet 192.168.243.128/24 brd 192.168.243.255 scope global noprefixroute dynamic ens37
valid_lft 1052sec preferred_lft 1052sec
inet6 fe80::9612:1176:5405:40dd/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@node1 ~]# ip route show
default via 192.168.243.2 dev ens37 proto dhcp metric 101
172.16.100.0/24 dev ens33 proto kernel scope link src 172.16.100.67 metric 100
192.168.243.0/24 dev ens37 proto kernel scope link src 192.168.243.128 metric 101
[root@node1 ~]# crontab -l
*/5 * * * * /usr/sbin/ntpdate time.nist.gov &> /dev/null
[root@node1 ~]# vim /etc/hosts
172.16.100.7 node1.smoke.com node1
172.16.100.8 node2.smoke.com node2
172.16.100.9 node3.smoke.com node3
node2:linux-agent
[root@node2 ~]# hostname
node2.smoke.com
[root@node2 ~]# ip addr show
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:70:86:6c brd ff:ff:ff:ff:ff:ff
inet 172.16.100.68/24 brd 172.16.100.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::d665:1c67:c985:a1cf/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: ens37: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:70:86:76 brd ff:ff:ff:ff:ff:ff
inet 192.168.243.144/24 brd 192.168.243.255 scope global noprefixroute dynamic ens37
valid_lft 1062sec preferred_lft 1062sec
inet6 fe80::8e7:556e:fcc9:216f/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@node2 ~]# ip route show
default via 192.168.243.2 dev ens37 proto dhcp metric 101
172.16.100.0/24 dev ens33 proto kernel scope link src 172.16.100.68 metric 102
192.168.243.0/24 dev ens37 proto kernel scope link src 192.168.243.144 metric 101
[root@node2 ~]# crontab -l
*/5 * * * * /usr/sbin/ntpdate time.nist.gov &> /dev/nulll
[root@node2 ~]# vim /etc/hosts
172.16.100.67 node1.smoke.com node1
172.16.100.68 node2.smoke.com node2
172.16.100.69 node3.smoke.com node3
node3:windows-agent
zabbix-server安装:
node1:zabbix-server
[root@node1 ~]# yum -y install mariadb-server
[root@node1 ~]# vim /etc/my.cnf
[mysqld]
innodb_file_per_table = 1
skip_name_resolve = 1
[root@node1 ~]# systemctl start mariadb.service
[root@node1 ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 *:3306 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
[root@node1 ~]# yum -y install trousers
[root@node1 ~]# cd zabbix-2.4.6/
[root@node1 zabbix-2.4.6]# ls
zabbix-2.4.6-1.el7.x86_64.rpm zabbix-proxy-pgsql-2.4.6-1.el7.x86_64.rpm zabbix-web-2.4.6-1.el7.noarch.rpm
zabbix-agent-2.4.6-1.el7.x86_64.rpm zabbix-proxy-sqlite3-2.4.6-1.el7.x86_64.rpm zabbix-web-japanese-2.4.6-1.el7.noarch.rpm
zabbix-get-2.4.6-1.el7.x86_64.rpm zabbix-sender-2.4.6-1.el7.x86_64.rpm zabbix-web-mysql-2.4.6-1.el7.noarch.rpm
zabbix-java-gateway-2.4.6-1.el7.x86_64.rpm zabbix-server-2.4.6-1.el7.x86_64.rpm zabbix-web-pgsql-2.4.6-1.el7.noarch.rpm
zabbix-proxy-2.4.6-1.el7.x86_64.rpm zabbix-server-mysql-2.4.6-1.el7.x86_64.rpm
zabbix-proxy-mysql-2.4.6-1.el7.x86_64.rpm zabbix-server-pgsql-2.4.6-1.el7.x86_64.rpm
[root@node1 zabbix-2.4.6]# yum -y localinstall zabbix-2.4.6-1.el7.x86_64.rpm zabbix-agent-2.4.6-1.el7.x86_64.rpm zabbix-get-2.4.6-1.el7.x86_64.rpm zabbix-java-gateway-2.4.6-1.el7.x86_64.rpm zabbix-sender-2.4.6-1.el7.x86_64.rpm zabbix-server-2.4.6-1.el7.x86_64.rpm zabbix-server-mysql-2.4.6-1.el7.x86_64.rpm zabbix-web-2.4.6-1.el7.noarch.rpm zabbix-web-mysql-2.4.6-1.el7.noarch.rpm
安装报错:
Error: Package: zabbix-server-mysql-2.4.6-1.el7.x86_64 (/zabbix-server-mysql-2.4.6-1.el7.x86_64)
Requires: libiksemel.so.3()(64bit)
Error: Package: zabbix-server-2.4.6-1.el7.x86_64 (/zabbix-server-2.4.6-1.el7.x86_64)
Requires: iksemel
Error: Package: zabbix-server-2.4.6-1.el7.x86_64 (/zabbix-server-2.4.6-1.el7.x86_64)
Requires: fping
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
[root@node1 ~]# ls
anaconda-ks.cfg fping-3.10-4.el7.x86_64.rpm iksemel-1.4-6.el7.x86_64.rpm iksemel-devel-1.4-6.el7.x86_64.rpm zabbix-2.4.6
[root@node1 ~]# yum -y localinstall *.rpm
配置zabbix:
node1:zabbix-server
[root@node1 ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-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 CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 1 row affected (0.01 sec)
MariaDB [(none)]> GRANT ALL ON zabbix.* TO 'zbxuser'@'172.16.100.%' IDENTIFIED BY 'zbxpass';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> \q
Bye
[root@node1 ~]# cd /usr/share/doc/zabbix-server-mysql-2.4.6/create/
[root@node1 create]# ls
data.sql images.sql schema.sql
[root@node1 create]# ls
data.sql images.sql schema.sql
[root@node1 create]# mysql zabbix < schema.sql #导入数据库要有顺序,先schema、images、data;
[root@node1 create]# mysql zabbix < images.sql
[root@node1 create]# mysql zabbix < data.sql
[root@node1 create]# vim /etc/zabbix/zabbix_server.conf
DBHost=172.16.100.67
DBUser=zbxuser
DBPassword=zbxpass
[root@node1 create]# systemctl start zabbix-server.service
[root@node1 create]# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Chongqing
[root@node1 create]# systemctl start httpd.service
配置zabbix-web:
通过windows的浏览器输入172.16.100.67/zabbix;
点击next,所有检查通过,点击next,配置数据库连接,数据库主机172.16.100.67、数据库用户zbxuser、密码zbxpass,点击next;
配置zabbix主机地址172.16.100.67,name为node1.smoke.com,点击next,到finish,自动跳转到zabbix登录界面;
zabbix-server监控自己:
node1:zabbix-server
[root@node1 create]# vim /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1,172.16.100.67
ServerActive=127.0.0.1,172.16.100.67
Hostname=node1.smoke.com
[root@node1 create]# systemctl start zabbix-agent.service
在zabbix-web上面启用对node1.smoke.com的监控,点击Configuration--Hosts,默认zabbix-server已经把自己监控了,点击Disable启用本机监控;