1、安装zabbix源

rpm -Uvh https://repo.huaweicloud.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

开启zabbix-frontend源
vi /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
...
enabled=1
...

2、安装服务端和客户端

yum install zabbix-server-mysql zabbix-agent zabbix-get
yum install centos-release-scl
yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl

3、安装mysql(注意官档中缺少安装步骤,一定要安装)

安装yum源
rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

安装key
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

验证
yum repolist enabled | grep "mysql.*-community.*"

安装mysql
yum install mysql-community-server

启动并开机自启
systemctl enable --now mysqld

修改root密码
grep 'temporary password' /var/log/mysqld.log
set password for 'root'@'localhost'=password('Asdf1234!@#'); 

允许远程连接
create user 'root'@'%' identified by 'Asdf1234!@#';
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;

4、创建zabbix库

创建
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'Asdf1234!@#';
grant all privileges on zabbix.* to zabbix@localhost;
flush privileges;
quit;

导入数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

5、修改zabbix配置

数据库修改
vi /etc/zabbix/zabbix_server.conf
DBPassword=Asdf1234!@#

前端修改
vi /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
listen 80; 
server_name zabbix.example.com; # 注意修改域名,去访问

后端修改
vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
listen.acl_users = apache,nginx
php_value[date.timezone] = Asisa/Shanghai

6、启动zabbix且开机自启关联服务

systemctl enable --now zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm # systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm

7、端口

nginx:80
php-fpm:9000
zabbix-server:10051
zabbix-agent:10050

8、访问

本地配置host
http://zabbix.example.com
用户:Admin
密码:zabbix

9、客户端配置

安装yum源
rpm -Uvh https://repo.huaweicloud.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

安装客户端
yum -y install zabbix-agent

修改配置
vi /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1,192.168.94.138 #服务端ip地址,多个可以用','号分割,如果不限定服务器ip用0.0.0.0/0
ServerActive=127.0.0.1,192.168.94.138 #主动推送服务端ip地址,同Server一样配置
Hostname=k8s-node-1 #在web界面配置的Host名称

启动并开机自启
systemctl enable --now zabbix-agent

10、解决服务端数据乱码问题

安装字体
yum -y install wqy-microhei-fonts

更新字体
cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf

重启服务
systemctl restart zabbix-server