一、zabbix architecture
Zabbix web GUI:zabbbix图形化接口,通常与server运行在同一台主机上
Zabbix database :存储配置信息和采集来的数据
Zabbix server:接受agent发送的报告信息,是zabbix的核心组件,所有配置,统计数据及操作数据均由其组织进行
Zabbix agent:部署在被监控主机上,收集本地数据并发往server端或者proxy端
Zabbix proxy:可选组件,常用于分布式监控环境中,使远程监控变得容易,其代理Server收集被监控节点的数据,而后统一发往Server端
官网选择rpm包或者源码安装http://www.zabbix.com/download.php
本文基于rpm包yum安装zabbix4.8,关于yum源的配置可查看,这里不再赘述http://blog.csdn.net/celeste7777/article/details/48528161
zabbix-server端已配置好LAMP环境,OS为CentOS7,zabbix-agent端OS为CentOS6x
二、Server端安装配置
1、添加repo文件
# cat /etc/yum/pluginconf.d/priorities.conf
[main]
enabled = 1 #YUM 优先级已开启
# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=zabbix for centos7
baseurl=http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/
enabled=1
gpgcheck=0
priority=1
# yum install zabbix zabbix-get zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql -y #安装zabbix-server和web gui
# rpm -qa |grep zabbix
zabbix-server-mysql-2.4.8-1.el7.x86_64
zabbix-web-2.4.8-1.el7.noarch
zabbix-server-2.4.8-1.el7.x86_64
zabbix-get-2.4.8-1.el7.x86_64 #通常在server或者proxy端执行获取远程客户端信息的命令行工具,常用于故障排查
zabbix-web-mysql-2.4.8-1.el7.noarch
zabbix-2.4.8-1.el7.x86_64
2、首先创建zabbix数据库,server和proxy的运行都依赖于数据库,agent则不需要
MariaDB [(none)]> CREATE DATABASE zabbix;
MariaDB [zabbix]> grant all on zabbix.* to 'username'@'serverIP' IDENTIFIED BY 'password' WITH GRANT OPTION;
MariaDB [zabbix]> flush privileges;
3、初始化数据库,proxy只需要导入一个sql文件,而server一共要导入3个sql文件
# mysql --default-character-set=utf8 zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/schema.sql
# mysql --default-character-set=utf8 zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/images.sql
# mysql --default-character-set=utf8 zabbix < /usr/share/doc/zabbix-server-mysql-2.4.8/create/data.sql
4、修改配置文件,zabbix_server.conf配置文件详解
http://www.ttlsa.com/zabbix/zabbix_server-conf-detail/
# cat /etc/zabbix/zabbix_server.conf |grep "^\s*[^# \t].*$"
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
DBName=zabbix #zabbix所属数据库
DBUser=username #zabbix所属数据库用户
DBPassword=password #zabbix数据库密码
DBSocket=/var/lib/mysql/mysql.sock
SNMPTrapperFile=/var/log/snmptt/snmptt.log
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
5、修改php配置文件参数
# sed -i "s@;date.timezone =@date.timezone = Asia/Shanghai@g" /etc/php.ini
# sed -i "s@max_execution_time = 30@max_execution_time = 300@g" /etc/php.ini
# sed -i "s@post_max_size = 8M@post_max_size = 32M@g" /etc/php.ini
# sed -i "s@max_input_time = 60@max_input_time = 300@g" /etc/php.ini
# sed -i "s@memory_limit = 128M@memory_limit = 128M@g" /etc/php.ini
6、启动zabbix server默认端口10051
# systemctl start zabbix-server.service
# netstat -atnlp |grep zabbix
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 4359/zabbix_server
tcp6 0 0 :::10051 :::* LISTEN 4359/zabbix_server
7、浏览器访问,默认账号:admin,密码:zabbix
三、Agent端安装配置
1、添加repo文件
# cat /etc/yum.repos.d/Zagent.repo
[agent]
name=zabbix for centos6
baseurl=http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/
enabled=1
gpgcheck=0
priority=1
# yum install zabbix zabbix-agent zabbix-sender -y
# rpm -qa |grep zabbix
zabbix-2.4.8-1.el6.x86_64
zabbix-agent-2.4.8-1.el6.x86_64 #命令行主动提交数据给server或者proxy,通常用于耗时比较长的检查
zabbix-sender-2.4.8-1.el6.x86_64
如果遇到yum源无法连接的报错,可手动下载rpm包本地yum安装
# wget http://repo.zabbix.com/zabbix/2.4/rhel/6/i386/zabbix-2.4.8-1.el6.i686.rpm
# wget http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-agent-2.4.8-1.el6.x86_64.rpm
# wget http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-sender-2.4.8-1.el6.x86_64.rpm
# yum localinstall zabbix* -y
2、编辑Agent配置文件,zabbix_agentd.conf配置文件详解
http://www.ttlsa.com/zabbix/zabbix_agentd-conf-description/
# cat /etc/zabbix/zabbix_agentd.conf |grep "^\s*[^# \t].*$"
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=zabbix serverIP #被动允许zabbix serverIP来取数据
ServerActive=zabbix serverIP #主动向zabbix serverIP提交数据
Hostname=Zabbix agent
Include=/etc/zabbix/zabbix_agentd.d/
3、启动zabbix agent默认端口10050
# service zabbix-agent start
# netstat -atnlp |grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 6821/zabbix_agentd
4、添加监控节点,选择监控项