Zabbix 是一款功能强大的分布式开源监控系统,天生自带分布式监控,大批量主机运维监控优势明显。
系统 | hostname | ip | 角色 | 服务 |
---|---|---|---|---|
RedHat 7.2 | zabbix_server | 172.25.27.30 | server | zabbix |
RedHat 6.5 | server2 | 172.25.27.2 | agent | agent |
zabbix官网:https://www.zabbix.com/
下载地址 : http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/
zabbix-agent-3.2.6-1.el7.x86_64.rpm
zabbix-server-mysql-3.2.6-1.el7.x86_64.rpm
zabbix-web-3.2.6-1.el7.noarch.rpm
zabbix-web-mysql-3.2.6-1.el7.noarch.rpm
fping-3.10-1.el7.x86_64.rpm
iksemel-1.4-2.el7.centos.x86_64.rpm
所需包:
php-mbstring-5.4.16-36.el7_1.x86_64.rpm
php-bcmath-5.4.16-36.el7_1.x86_64.rpm
yum 安装
[root@zabbix_server php]# ls
php-mbstring-5.4.16-36.el7_1.x86_64.rpm
php-bcmath-5.4.16-36.el7_1.x86_64.rpm
[root@zabbix_server php]# yum install php-mbstring-5.4.16-36.el7_1.x86_64.rpm php-bcmath-5.4.16-36.el7_1.x86_64.rpm -y
[root@zabbix_server el7]# ls
fping-3.10-1.el7.x86_64.rpm
iksemel-1.4-2.el7.centos.x86_64.rpm
zabbix-agent-3.2.6-1.el7.x86_64.rpm
zabbix-get-3.2.6-1.el7.x86_64.rpm
zabbix-java-gateway-3.2.6-1.el7.x86_64.rpm
zabbix-proxy-mysql-3.2.6-1.el7.x86_64.rpm
zabbix-proxy-pgsql-3.2.6-1.el7.x86_64.rpm
zabbix-proxy-sqlite3-3.2.6-1.el7.x86_64.rpm
zabbix-release-3.2-1.el7.noarch.rpm
zabbix-sender-3.2.6-1.el7.x86_64.rpm
zabbix-server-mysql-3.2.6-1.el7.x86_64.rpm
zabbix-server-pgsql-3.2.6-1.el7.x86_64.rpm
zabbix-web-3.2.6-1.el7.noarch.rpm
zabbix-web-japanese-3.2.6-1.el7.noarch.rpm
zabbix-web-mysql-3.2.6-1.el7.noarch.rpm
zabbix-web-pgsql-3.2.6-1.el7.noarch.rpm
[root@zabbix_server el7]# yum install -y fping-3.10-1.el7.x86_64.rpm iksemel-1.4-2.el7.centos.x86_64.rpm zabbix-agent-3.2.6-1.el7.x86_64.rpm zabbix-server-mysql-3.2.6-1.el7.x86_64.rpm zabbix-web-3.2.6-1.el7.noarch.rpm zabbix-web-mysql-3.2.6-1.el7.noarch.rpm
[root@zabbix_server ~]# yum install -y mariadb-server
[root@zabbix_server ~]# systemctl start mariadb
[root@zabbix_server ~]# systemctl enable mariadb
[root@zabbix_server ~]# mysql
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'mypasswd';
MariaDB [(none)]> quit
[root@zabbix_server ~]# zcat /usr/share/doc/zabbix-server-mysql-3.2.*/create.sql.gz | mysql -uzabbix -pmypasswd zabbix
[root@zabbix_server ~]# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbixDBUser=zabbix
DBPassword=mypasswd
[root@zabbix_server ~]# systemctl start zabbix-server
[root@zabbix_server ~]# systemctl enable zabbix-server
[root@zabbix_server ~]# vim /etc/httpd/conf.d/zabbix.conf
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 always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
[root@zabbix_server ~]# systemctl restart zabbix-server
[root@zabbix_server ~]# systemctl restart zabbix-agent
[root@zabbix_server ~]# systemctl start httpd
http://172.25.27.30/zabbix 按照提示完成安装并登陆:
next
Username: Admin
Password: zabbix
到这里安装完成,也登陆成功了,但是我这里有点小问题,就是
Zabbix server is running No localhost:10051
我们来查看下日志
[root@zabbix_server ~]# cat /var/log/zabbix/zabbix_server.log
2123:20171010:204715.862 server #11 started [trapper #3]
2131:20171010:204715.864 server #19 started [discoverer #1]
2124:20171010:204921.028 cannot send list of active checks to "127.0.0.1": host [Zabbix server] not monitored
初步判断是火墙或者selinux
[root@zabbix_server ~]# getenforce
Enforcing
[root@zabbix_server ~]# setenforce 0
问题解决
接下来可以进行语言设置及修改密码,点击右上角的小人即可进入设置界面
在被监控端(server2)安装软件包:
zabbix-agent-3.2.6-1.el6.x86_64.rpm
[root@server2 ~]# ls
zabbix-agent-3.2.6-1.el6.x86_64.rpm
[root@server2 ~]# yum install -y zabbix-agent-3.2.6-1.el6.x86_64.rpm
[root@server2 ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=172.25.27.30
ServerActive=172.25.27.30
Hostname=zabbix_server
[root@server2 ~]# service zabbix-agent start
点击 配置->自动发现
点击 Local network ,修改 IP范围并更新
再点击 停用的,启用自动发现规则
点击 Auto discovery. Linux servers 查看一下动作,这里可根据自己需要进行配置,我们这里不用修改,默认即可
回到 配置->动作,点击 停用的 启用自动发现
点击 配置->主机 可以看到新发现的主机
或者点击 监测中->自动发现 可以看到新发现的主机
等一会之后新发现的agent 的 ZBX 亮起,配置自动发现成功
Zabbix 还有很多功能,我将在下一篇博客分享一些功能的添加