zabbix服务端
1.配置zabbix源
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
2.安装zabbix部署包
yum install zabbix-server-mysql zabbix-web-mysql httpd php mariadb-server -y
3.启动并配置数据库:
1 2 3 4 5 6 7 8 9 10 11 |
# 启动数据库 systemctl start mariadb && systemctl enable mariadb # 设置数据库密码 mysqladmin -uroot password '123456' mysql -uroot -p123456 # 创建库 create database zabbix character set utf8 collate utf8_bin; #授权 grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; |
4.安装初始化数据库
1 2 3 4 |
cd /usr/share/doc/zabbix-server-mysql-3.4.15/ && zcat create.sql.gz | mysql -uzabbix -pzabbix zabbix # 验证 mysql -uzabbix -pzabbix -e 'use zabbix;show tables;' |
5.启动zabbix server进程
1 2 3 4 5 |
vi /etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix |
6.配置PHP时区:
1 2 |
# 配置Apache与Php配置 sed -i 's#\# php_value date.timezone Europe/Riga#php_value date.timezone Asia/Shanghai#g' /etc/httpd/conf.d/zabbix.conf |
7.解决中文乱码
1 |
yum -y install wqy-microhei-fonts \cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf |
8.启动zabbix相关服务:
1 2 |
systemctl start zabbix-server && systemctl enable zabbix-server systemctl start httpd && systemctl enable httpd |
9.默认端口为10051:
1 |
netstat -tunpl|grep 10051 |
10.访问
1 2 3 4 |
http://192.168.12.91/zabbix #默认登录用户:Admin #默认登录密码:zabbix |
zabbix客户端
1.安装对应版本的agent
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
2.安装zabbix客户端
1 2 3 4 5 6 |
yum install zabbix-agent -y sed -i.ori 's#Server=127.0.0.1#Server=192.168.12.91#' /etc/zabbix/zabbix_agentd.conf # 启动并加入开机自启 systemctl start zabbix-agent.service && systemctl enable zabbix-agent.service |
3.加入开机自启
1 2 3 4 |
chmod +x /etc/rc.d/rc.local cat >>/etc/rc.d/rc.local<<EOF systemctl start zabbix-agent.service EOF |
zabbix服务端测试连通性
1 2 3 4 5 6 7 |
# 服务端安装zabbix-get检测工具 yum install zabbix-get -y # 只能在服务端进行测试 这里的ip是客户端的ip zabbix_get -s 192.168.12.92 -p 10050 -k "system.cpu.load[all,avg1]" 0.000000 zabbix_get -s 192.168.12.92 -p 10050 -k "system.cpu.load[all,avg1]" 0.000000 |