如果文章对你有用,请留下痕迹在配置过程中有问题请及时留言,本作者可以及时更新文章
目录
1、提前准备环境
最新版本需要在centos9安装部署
官方地址下载Zabbix
[root@localhost ~]# cat /etc/redhat-release
CentOS Stream release 9
2、zabbix7.2安装部署
rpm -Uvh https://repo.zabbix.com/zabbix/7.2/release/rhel/9/noarch/zabbix-release-latest-7.2.el9.noarch.rpm
dnf clean all
#配置zabbix库
安装Zabbix server,Web前端,agent
centos7包管理是yum,centos9更换成了dnf
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
[root@localhost ~]# rpm -qa | grep zabbix-release
zabbix-release-7.2-1.el9.noarch
[root@localhost ~]# rpm -qa | grep zabbix*
zabbix-release-7.2-1.el9.noarch
zabbix-web-7.2.6-release1.el9.noarch
zabbix-web-mysql-7.2.6-release1.el9.noarch
zabbix-web-deps-7.2.6-release1.el9.noarch
zabbix-apache-conf-7.2.6-release1.el9.noarch
zabbix-server-mysql-7.2.6-release1.el9.x86_64
zabbix-sql-scripts-7.2.6-release1.el9.noarch
zabbix-selinux-policy-7.2.6-release1.el9.x86_64
zabbix-agent-7.2.6-release1.el9.x86_64
3、安装并配置数据库
dnf install -y mariadb-server mariadb
[root@localhost ~]# systemctl restart mariadb
[root@localhost ~]# netstat -pltun|grep 3306
tcp6 0 0 :::3306 :::* LISTEN 88171/mariadbd
#默认密码 123456
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.27-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> create user 'zabbix'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> quit
Bye
导入初始架构和数据,系统将提示您输入新创建的密码。
[root@localhost ~]# ll /usr/share/zabbix/sql-scripts/mysql/server.sql.gz
-rw-r--r--. 1 root root 4082453 Apr 23 14:42 /usr/share/zabbix/sql-scripts/mysql/server.sql.gz
[root@localhost ~]# zcat /usr/share/zabbix/sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
Enter password:
验证初始数据是否完成
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.5.27-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| auditlog |
| autoreg_host |
| changelog |
| conditions |
| config |
| config_autoreg_tls |
| connector |
| connector_tag |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
导入数据库架构后禁用log_bin_trust_function_creators选项。
MariaDB [zabbix]> set global log_bin_trust_function_creators = 0;
Query OK, 0 rows affected (0.000 sec)
MariaDB [zabbix]> quit
Bye
[root@localhost ~]#
4、为Zabbix server配置数据库
[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf
### Option: DBPassword
# Database password.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=123456
5、为Zabbix前端配置PHP
# listen 8080;
# server_name example.com;
[root@localhost ~]# vim /etc/nginx/conf.d/zabbix.conf
server {
listen 80;
server_name zabbix.com;
6、启动Zabbix server和agent进程
[root@localhost ~]# systemctl restart zabbix-server zabbix-agent nginx php-fpm
[root@localhost ~]# netstat -pltun
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1434/sshd: /usr/sbi
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 95368/nginx: master
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 95354/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 95386/zabbix_server
tcp6 0 0 :::22 :::* LISTEN 1434/sshd: /usr/sbi
tcp6 0 0 :::80 :::* LISTEN 95368/nginx: master
tcp6 0 0 :::3306 :::* LISTEN 88171/mariadbd
tcp6 0 0 :::10050 :::* LISTEN 95354/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 95386/zabbix_server
udp 0 0 127.0.0.1:323 0.0.0.0:* 756/chronyd
udp6 0 0 ::1:323 :::* 756/chronyd
[root@localhost ~]#
7、关闭防火墙访问zabbix
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# systemctl status firewalld
○ firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; preset: enabled)
Active: inactive (dead) since Tue 2025-05-13 11:11:39 CST; 3h 41min ago
Duration: 1min 52.402s
Docs: man:firewalld(1)
Main PID: 744 (code=exited, status=0/SUCCESS)
CPU: 698ms
May 13 11:09:46 localhost systemd[1]: Starting firewalld - dynamic firewall daemon...
May 13 11:09:47 localhost systemd[1]: Started firewalld - dynamic firewall daemon.
May 13 11:11:39 localhost.localdomain systemd[1]: Stopping firewalld - dynamic firewall daemon...
May 13 11:11:39 localhost.localdomain systemd[1]: firewalld.service: Deactivated successfully.
May 13 11:11:39 localhost.localdomain systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@localhost ~]#
8、Web界面配置
http://192.168.25.151/setup.php
根据前面创建的zabbix用户写写入
初始登录username是 Admin 密码是zabbix
z
9、配置中文界面
[root@localhost ~]# dnf install -y fontconfig langpacks-zh_CN.noarch
[root@localhost ~]# dnf install -y https://download1.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm
[root@localhost ~]# dnf install -y google-roboto-fonts
检查是否有中文字体
[root@localhost ~]# rpm -qa | grep google
google-noto-cjk-fonts-common-20230817-2.el9.noarch
google-noto-sans-cjk-ttc-fonts-20230817-2.el9.noarch
google-noto-serif-cjk-ttc-fonts-20230817-2.el9.noarch
google-roboto-fonts-2.138-10.el9.noarch
[root@localhost ~]# fc-list :lang=zh
/usr/share/fonts/google-noto-cjk/NotoSansCJK-DemiLight.ttc: Noto Sans CJK TC,Noto Sans CJK TC DemiLight:style=DemiLight,Regular
[root@localhost alternatives]# ln -fs /usr/share/fonts/google-noto-cjk/NotoSansCJK-DemiLight.ttc /etc/alternatives/zabbix-web-ui-font
10、重启服务
systemctl restart zabbix-server zabbix-agent nginx php-fpm
选择中文语言
完成