zabbix6.0服务端不再支持Centos7的yum安装,Centos8已停止维护,rockylinux是RHEL的下游免费发行版。
1.安装rockylinux9:阿里云下载地址
#关闭防火墙和 selinux 并重启
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
systemctl disable --now firewalld
#查看firewall服务状态
systemctl status firewalld
2.替换rockylinux9的交大源或者阿里源:
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.sjtug.sjtu.edu.cn/rocky|g' \
-i.bak \
/etc/yum.repos.d/[Rr]ocky*.repo
dnf makecache
或
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \
-i.bak \
/etc/yum.repos.d/[Rr]ocky*.repo
dnf makecache
3.按照zabbix官方文档安装6.0:
a. Install Zabbix repository,Proceed with installing zabbix repository.
# rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-1.el9.noarch.rpm
# dnf clean all
b. 安装Zabbix server,Web前端,agent
# dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
c. 创建初始数据库
Make sure you have database server up and running.
本文以Mysql为例
#安装数据库,启动数据库,并开机自启
yum install mariadb-server -y
systemctl enable --now mariadb
#初始化 mariadb 并配置 root 密码
mysql_secure_installation
#直接回车,空
是否设置密码:y
输入设置密码:
再次输入密码:
是否移除anonymous用户:y
是否不允许root远程登录:n
是否移除test数据库:y
是否更新:y
在数据库主机上运行以下代码。
# mysql -uroot -p
password
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> set global log_bin_trust_function_creators = 1;
mysql> quit;
导入初始架构和数据,系统将提示您输入新创建的密码。
# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
Disable log_bin_trust_function_creators option after importing database schema.
# mysql -uroot -p
password
mysql> set global log_bin_trust_function_creators = 0;
d. 为Zabbix server配置数据库
编辑配置文件 /etc/zabbix/zabbix_server.conf
DBPassword=password
e. 启动Zabbix server和agent进程
启动Zabbix server和agent进程,并为它们设置开机自启:
# systemctl restart zabbix-server zabbix-agent httpd php-fpm
# systemctl enable zabbix-server zabbix-agent httpd php-fpm
f. Open Zabbix UI web page
The default URL for Zabbix UI when using Apache web server is http://host/zabbix