zabbix官网:
https://www.zabbix.com
zabbix(音同 zæbix)是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
环境:
系统:
centos7 1708
服务器ip:
192.168.12.74 zabbix.example.com
本次采用yum源安装zabbix3.0 LTS 的版本:
zabbix-server的安装:
#安装zabbix源
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
#安装zabbix
yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-java-gateway
#安装启动mariadb数据库
yum install -y mariadb-serve
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-*/create.sql.gz | mysql -uzabbix -pzabbix zabbix
#配置zabbixserver连接mysql
sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf
ps:
如何数据库与zabbix-server 的主机不在用一台主机上:
sed -i.ori '81a DBHost=zabbix_mysql_ip' /etc/zabbix/zabbix_server.conf
#添加时区
sed -i '18a php_value date.timezone Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf
#解决中文乱码
yum install -y 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.servicer
systemctl start httpd
systemctl start zabbix-server
EOF
#输出信息
echo "浏览器访问 http://`hostname -I |awk '{print $1}'`/zabbix"
zabbix-agent的安装:
#!/bin/bash
#安装zabbix源
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
#安装zabbix客户端
yum install zabbix-agent -y
sed -i 's#Server=127.0.0.1#Server=192.168.12.74#' /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