CentOS7下部署Zabbix4.0
本文参考官方文档完成
代码语言:javascript复制https://www.zabbix.com/cn/download?zabbix=4.0&os_distribution=centos&os_version=7&db=mysql&ws=apache
(图片可点击放大查看)
环境说明
- 1、Zabbix-Server
CentOS7.9 VMware虚拟机一台 192.168.31.232
- 2、Zabbix-Agent
CentOS7.9 VMware虚拟机一台 192.168.31.127
一、Zabbix Server端部署
1、yum源 EPEL源配置
代码语言:javascript复制curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
关闭SELINUX等操作 记得校准系统时间
代码语言:javascript复制yum install ntpdate -y
ntpdate ntp.aliyun.com
(图片可点击放大查看)
2、yum方式安装Zabbix Server及Zabbix-agent
代码语言:javascript复制rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
(图片可点击放大查看)
3、安装MariaDB数据库并导入zabbix初始化数据库
代码语言:javascript复制yum install mariadb-server
systemctl start mariadb.service
mysql_secure_installation
(图片可点击放大查看)
(图片可点击放大查看)
(图片可点击放大查看)
创建zabbix数据库
代码语言:javascript复制mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'zabbix@2021';
grant all privileges on zabbix.* to zabbix@localhost;
quit;
(图片可点击放大查看)
导入zabbix初始化数据库
代码语言:javascript复制zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
(图片可点击放大查看)
(图片可点击放大查看)
4、修改配置文件中数据库密码
代码语言:javascript复制vim /etc/zabbix/zabbix_server.conf
修改DBPassword=zabbix@2021
并启动
systemctl restart zabbix-server zabbix-agent httpd
(图片可点击放大查看)
5、配置文件中时区修改
代码语言:javascript复制vi /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
(图片可点击放大查看)
6、php.ini配置优化
代码语言:javascript复制vim /etc/php.ini
date.timezone = Asia/Shanghai
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
max_input_vars = 10000
always_populate_raw_post_data = -1
(图片可点击放大查看)
7、启动zabbix-server相关服务并设置为开机自启动
代码语言:javascript复制systemctl enable httpd
systemctl enable zabbix-server
systemctl enable zabbix-agent
systemctl enable mariadb
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=10051/tcp
firewall-cmd --reload
(图片可点击放大查看)
二、Zabbix-Server Web上完成初始化向导
代码语言:javascript复制http://192.168.31.127/zabbix/setup.php
(图片可点击放大查看)
(图片可点击放大查看)
(图片可点击放大查看)
(图片可点击放大查看)
(图片可点击放大查看)
(图片可点击放大查看)
(图片可点击放大查看)
(图片可点击放大查看)
修改界面语言为中文
(图片可点击放大查看)
(图片可点击放大查看)
三、Zabbix Agent安装与配置
1、yum源配置
代码语言:javascript复制curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
(图片可点击放大查看)
2、安装zabbix-agent
代码语言:javascript复制rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
yum install zabbix-agent
(图片可点击放大查看)
3、修改配置文件
修改配置文件中Server和ServerActive地址
代码语言:javascript复制sed -i "s/Hostname=Zabbix server/Hostname=centos.walkingcloud.cn/g" /etc/zabbix/zabbix_agentd.conf
sed -i "s/ServerActive=127.0.0.1/ServerActive=192.168.31.232/g" /etc/zabbix/zabbix_agentd.conf
sed -i "s/Server=127.0.0.1/Server=192.168.31.232/g" /etc/zabbix/zabbix_agentd.conf
cat /etc/zabbix/zabbix_agentd.conf | grep Server=
cat /etc/zabbix/zabbix_agentd.conf | grep ServerActive=
cat /etc/zabbix/zabbix_agentd.conf | grep Hostname=
(图片可点击放大查看)
4、启动zabbix-agent相关服务并设置为开机自启动
zabbix-agent需要在防火墙中放通10050端口
代码语言:javascript复制firewall-cmd --permanent --zone=public --add-port=10050/tcp
firewall-cmd --reload
systemctl enable zabbix-agent
systemctl start zabbix-agent
systemctl status zabbix-agent
tail -f /var/log/zabbix/zabbix_agentd.log
(图片可点击放大查看)
四、创建主机组,并添加主机
(图片可点击放大查看)
(图片可点击放大查看)
(图片可点击放大查看)
(图片可点击放大查看)
(图片可点击放大查看)
Tips:解决乱码问题
解决方法:安装字体并替换现有字体
代码语言:javascript复制yum install wqy-microhei-fonts -y
cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/zabbix/assets/fonts/graphfont.ttf
(图片可点击放大查看)
(图片可点击放大查看)
(图片可点击放大查看)
五、触发器告警测试
(图片可点击放大查看)
(图片可点击放大查看)
(图片可点击放大查看)
(图片可点击放大查看)
可以看到可用容量低于80%时告警产生,in方向流量超过70Mbps时同样
总结:本文只是zabbix初始安装部署入门篇,zabbix强大的监控功能后续有空再继续探索