zabbix(音同 zæbix)是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix监控服务器由2部分构成,zabbix server与可选组件zabbix agent。
zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
二.基础环境介绍
1.系统:CentOS Linux release 7.1.1503 (Core)
2.编译环境:“Deveolpment Tools”
3.zabbix-Server:ip:192.168.1.125/24 (centos7) agent:192.168.1.128/24 (centos 6.5)
三.Zabbix Server端操作
1.安装zabbix-server 及所需的mysql组件、zabbix-agent
[[email protected] ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm [[email protected] ~]# yum install zabbix-server-mysql zabbix-web-mysql -y [[email protected] ~]# yum install zabbix-agent -y
2.由于centos 7 默认的数据库改由mariadb里,甲骨文公司收购了MySQL后,mysql之父便又写了这个数据库。此环境由于需要mysql ,所以下面将下载mysql 源,安装mysql。另外mysql安装完,root没有密码,可以直接登陆,后续如果需要修改密码可登陆数据库修改,或者运行 mysql_secure_installation 初始化工具
[[email protected] ~]# yum install wget -y https://tieba.baidu.com/p/5825861154 https://tieba.baidu.com/p/5825861154 [[email protected] ~]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm [[email protected] ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm [[email protected] ~]# yum install mysql-community-server -y [[email protected] ~]# service mysqld start #或者 systemctl start mysqld.service [[email protected] ~]# mysql -uroot
创建zabbix 数据库,并授权zabbix用户,以及设置zabbix用户登陆密码为zabbix
[[email protected] ~]# mysql -uroot https://tieba.baidu.com/p/5825867016 https://tieba.baidu.com/p/5825867016 mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to [email protected] identified by 'zabbix'; mysql> quit;
进入zabbix数据库脚本导入的目录,将库数据导入zabbix数据库中。
[[email protected] ~]# cd /usr/share/doc/zabbix-server-mysql-3.0.1/ [[email protected] ~]# zcat create.sql.gz | mysql -uroot zabbix
https://tieba.baidu.com/p/5825872091
https://tieba.baidu.com/p/5825872091
3.修改zabbix-server的配置文件。默认路径在:/etc/zabbix/zabbix_server.conf,修改如下。或者是备份原文件,将下面内容直接替换原有内容,不过后续的修改添加会比较麻烦点。(注意:此处只需修改4处也可以,红色加粗处)
[[email protected] ~]# grep -v '^#' /etc/zabbix/zabbix_server.conf | grep -v '^$' LogFile=/var/log/zabbix/zabbix_server.log LogFileSize=0 PidFile=/var/run/zabbix/zabbix_server.pid DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix StartPollers=10 StartPollersUnreachable=5 StartTrappers=5 StartPingers=1 StartDiscoverers=1 SNMPTrapperFile=/var/log/snmptrap/snmptrap.log HousekeepingFrequency=1 Timeout=4 AlertScriptsPath=/usr/lib/zabbix/alertscripts ExternalScripts=/usr/lib/zabbix/externalscripts LogSlowQueries=3000
修改完成后,重启zabbix-server 服务
[[email protected] ~]# systemctl restart zabbix-server
问题1:如果出现启动失败,如下所示
https://tieba.baidu.com/p/5824467730
https://tieba.baidu.com/p/5824467730
[[email protected] ~]# systemctl start zabbix-server Job for zabbix-server.service failed because a fatal signal was delivered to the control process. See "systemctl status zabbix-server.service" and "journalctl -xe" for details.
解决方法:先检查selinux是否关闭,关闭后,并安装以下两个软件。再次启动zabbix-server服务便可以启动成功。
[[email protected] ~]# yum install trousers -y [[email protected] ~]# yum install gnutls -y
https://tieba.baidu.com/p/5824478089
https://tieba.baidu.com/p/5824478089
4.下面修改php 配置文件,修改完成后并重启httpd
[[email protected] ~]# sed -i "s/;date.timezone =/date.timezone =Asia\/Shanghai/g" /etc/php.ini [[email protected] ~]# vim /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 always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
</IfModule>
[[email protected] ~]# systemctl restart httpd
5.将服务添加开机启动项
[[email protected] ~]# systemctl start zabbix-agent #竟然才发现没有将zabbix-agent服务启动。 [[email protected] ~]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [[email protected] ~]# systemctl enable zabbix-server Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service. [[email protected] ~]# systemctl enable zabbix-agent Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
6.那无,现在就可以去客户端访问web安装页面了,http://192.168.1.125/zabbix。(如果访问不了网站,看下server端的防火墙,systemctl stop firewalld)下面的步骤就不用截图了。按照提示一步一步来操作。