1. 查看系统版本```bash
    cat /etc/os-release
1
2
3
2. 根据提示禁用EPEL源,启用Zabbix源```bash
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-6.0-4.el9.noarch.rpm
dnf clean all
  1. 安装Zabbix server,Web前端,agent```bash
    dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
1
2
3
4
5
6
7
4. 安装MySQL```bash
yum -y remove mysql
find / -name mysql
rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
yum module disable mysql
yum install mysql-community-server
systemctl start mysqld
  1. 登陆MySQL```bash
    grep -i password /var/log/mysqld.log
    mysql -uroot -p'password'
1
2
3
4
6. 修改 MySQL 的 root 用户密码```sql
alter user 'root'@'localhost' identified by 'your-password';
flush privileges;
quit;
  1. 再次进入MySQL后创建 Zabbix 数据库```sql
    create database zabbix character set utf8mb4 collate utf8mb4_bin;
    create user zabbix@'%' identified by 'password';
    grant all privileges on zabbix.* to zabbix@'%';
    set global log_bin_trust_function_creators = 1;
    quit;
1
2
3
4
5


注意这里创建的 Zabbix 用户的登陆主机不是 localhost
8. 在 /etc/zabbix/zabbix_server.conf 配置数据库密码:```toml
DBPassword=为Zabbix分配的数据库的用户密码
  1. 导入初始架构和数据,系统将提示您输入新创建的密码。(这步在其中一台监控主机上做好即可) ```bash
    zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql –default-character-set=utf8mb4 -uzabbix -p zabbix
1
2
3
4
5
6


如果 Zabbix 服务与数据库不在同一主机上时,注意mysql命令中要加`-h`参数
10. 为Zabbix前端配置PHP,编辑配置文件 /etc/nginx/conf.d/zabbix.conf 并且设置 ‘listen’和’server_name’项```toml
listen 8080;
server_name example.com;
  1. 启动Zabbix server和agent进程```bash
    systemctl restart zabbix-server zabbix-agent nginx php-fpm
    systemctl enable zabbix-server zabbix-agent nginx php-fpm