#参考【zabbix3.0从入门到精通】https://www.cnblogs.com/clsn/p/7885990.html#auto_id_14
环境:Centos7.2 、zabbix4.0
zabbix官网: https://www.zabbix.com
zabbix 为C\S架构 “zabbix server”端和 “zabbix agent客户端”
zabbix proxy是用来管理其他的agent,作为代理
zabbix监控范畴
硬件监控 :Zabbix IPMI Interface
系统监控 :Zabbix Agent Interface
Java 监控:ZabbixJMX Interface
网络设备监抟:Zabbix SNMP Interface
应用服务监控:Zabbix Agent UserParameter
MySQL 数据库监控:percona-monitoring-pldlgins
URL监控:Zabbix Web监控
cacti、nagios、zabbix区别:(都需要LAMP平台支持)
cacti:通过SNMP协议获取远端网络设备信息,更适合监控网络流量,如IDC机房;
nagios:告警功能强大,出图简陋,不支持web方式管理,添加主机复杂;
zabbix:告警功能丰富,支持添加自定义监控项目,提供易用的二次开发接口;
zabbix主要 模块:
一、安装:
(此文为yum安装方式)
在server端和agent端配置基础yum源:
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
server端安装:
下载地址:
https://www.zabbix.com/download
rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
yum -y install zabbix-server-mysql zabbix-web-mysql
#安装启动 mariadb数据库
yum install -y mariadb-server
systemctl start mariadb.service
#创建数据库
mysql -e 'create database zabbix character set utf8 collate utf8_bin;'
mysql -e 'grant all privileges on zabbix.* to zabbix@localhost identified by "zabbix";'
#导入数据
zcat /usr/share/doc/zabbix-server-mysql-4.0.5/create.sql.gz |mysql -uzabbix -pzabbix zabbix
如果你在这里报这个错误,说明版本号更新了导致目录找不到,查看并改一下版本号即可;
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql-4.0.5/create.sql.gz |mysql -uzabbix -pzabbix zabbix
gzip: /usr/share/doc/zabbix-server-mysql-4.0.5/create.sql.gz: No such file or directory
[root@localhost ~]# cd /usr/share/doc/zabbix-server-mysql-4.0.28/create.sql.gz
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql-4.0.28/create.sql.gz |mysql -uzabbix -pzabbix zabbix
#配置zabbixserver连接mysql
sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf
#添加时区
sed -i.ori '18a php_value date.timezone Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf
#解决中文乱码
yum -y install wqy-microhei-fonts
\cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
#启动服务
systemctl start zabbix-server
systemctl start httpd
#写入开机自启动
chmod +x /etc/rc.d/rc.local
cat >>/etc/rc.d/rc.local<<EOF
systemctl start mariadb.service
systemctl start httpd
systemctl start zabbix-server
EOF
server端安装完毕;
客户端(agent)安装:
rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.1-1.el7.x86_64.rpm
yum install zabbix-agent -y
修改配置文件指定server端的ip地址:
sed -i.ori 's#Server=127.0.0.1#Server=192.168.30.141#' /etc/zabbix/zabbix_agentd.conf
systemctl start zabbix-agent.service
#写入开机自启动
chmod +x /etc/rc.d/rc.local
cat >>/etc/rc.d/rc.local<<EOF
systemctl start zabbix-agent.service
EOF
客户端安装完毕;
二、测试连通性
服务端安装zabbix-get检测工具
yum install zabbix-get
在服务端进行测试
注意:只能在服务端进行测试
zabbix_get -s 192.168.30.159 -p 10050 -k "system.cpu.load[all,avg1]"
测试结果
[root@bogon ~]# zabbix_get -s 192.168.30.159 -p 10050 -k "system.cpu.load[all,avg1]"
0.000000
三、zabbix的web安装
3.1.1 使用浏览器访问
http://192.168.30.147/zabbix/
一路下一步直到这里进入登陆界面 账号Admin密码zabbix 注意A大写
登录后点击设置为中文: