1.添加zabbix源

rpm -Uvh https://repo.zabbix.com/zabbix/5.4/rhel/8/x86_64/zabbix-release-5.4-1.el8.noarch.rpm


2.添加mysql源

rpm -Uvh https://repo.mysql.com//mysql80-community-release-el8-1.noarch.rpm

dnf clean all

dnf module switch-to php:7.4

下载离线安装包

dnf  -yinstall zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent  mysql mysql-server mysql-devel wqy-microhei-fonts  --downloadonly --downloaddir=/tmp/offline_rpm


3.离线需要更新npm源需要挂在光盘做源

mkdir /mnt/iso

mount -o loop /dev/cdrom /mnt/iso

配置本地yum源

mkdir /etc/yum.repos.d/bak

cp -p /etc/yum.repos.d/* /etc/yum.repos.d/bak

rm -rf /etc/yum.repos.d/*.repo

vi /etc/yum.repos.d/iso.repo

复制以下内容

[BaseOS]

name=CentOS Stream $releasever - BaseOS

baseurl=file:///mnt/iso/BaseOS

gpgcheck=1

enabled=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[appstream]

name=CentOS Stream $releasever - AppStream

baseurl=file:///mnt/iso/AppStream/

gpgcheck=1

enabled=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[extras]

name=CentOS Stream $releasever - Extras

baseurl=file:///mnt/iso/Extras/

gpgcheck=1

enabled=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

:wq 保存退出

4.安装zabbix离线包

dnf localinstall/tmp/offline_rpm/* -y

启动并设置开机自启mysql


systemctl enable mysqld

systemctl start mysqld


修改数据库root密码

mysql -uroot -p

ALTER user 'root'@'localhost' IDENTIFIED BY 'password';密码必须包含大写字母、数字、特殊符号,不需要flush privileges来刷新权限。

create database zabbix character set utf8 collate utf8_bin;

create user zabbix@localhost identified by 'password';密码

grant all privileges on zabbix.* to zabbix@localhost;

quit退出数据库


导入初始架构和数据,系统将提示您输入新创建的密码。

zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uroot -p zabbix


为Zabbix server配置数据库 修改数据库密码,编辑配置文件/etc/zabbix/zabbix_server.conf

DBPassword=password手动修改

echo "DBPassword=password" >> /etc/zabbix/zabbix_server.conf 自动添加到配置文件末端二选一  

密码为创建数据库时的密码


为Zabbix前端配置PHP配置web端口,编辑配置文件/etc/nginx/conf.d/zabbix.conf

listen 80;

# server_name example.com;

注释掉原先NGINX配置

#        root         /usr/share/nginx/html;

修改时区,编辑配置文件/etc/php-fpm.d/zabbix.conf

php_value[date.timezone] = Asia/Shanghai

安装中文字体

cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf

启动Zabbix server和agent进程,并为它们设置开机自启

systemctl restart zabbix-server zabbix-agent nginx php-fpm

systemctl enable zabbix-server zabbix-agent nginx php-fpm


5.配置Zabbix前端

http://<server_ip_or_name>/zabbix.php


用户名:Admin,密码:zabbix