安装CentOS9 Stream
使用最小化安装即可。
如果在Esxi虚拟机中安装,请选用BIOS固件(不要选建议的EFI,否则无法安装)。
CentOS9升级
安装完毕CentOS9之后,在root权限下执行如下指令
yum update -y
修改CentOS安全属性
关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
关闭selinux
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
安装mysql8社区版
移除之前的库
yum remove -y mysql
find / -name mysql
然后将找到的全删掉
rm -rf /var/lib/selinux/targeted/active/modules/100/mysql
安装mysql
yum install wget -y
wget https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
yum install mysql80-community-release-el8-1.noarch.rpm -y
yum install -y mysql-community-server --nogpgcheck
配置mysql
修改/etc/my.cnf
vi /etc/my.cnf
取消此行注释
default-authentication-plugin=mysql_native_password
启动mysql
systemctl enable mysqld
systemctl start mysqld
安装Zabbix
注意:最后一行zabbix-agent2,与官方包(zabbix-agent)不一致。
rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-1.el9.noarch.rpm
yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent2
导入初始化数据
查找mysql root 临时密码
grep 'temporary password' /var/log/mysqld.log
[root@CentOS9 ~]# grep 'temporary password' /var/log/mysqld.log
2023-09-27T07:00:22.581536Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: *(dqflf!;33A
创建mysql数据库
mysql -uroot -p
password
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Abc@123.com';
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user zabbix@localhost identified by 'Abc@123.com';
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
这里需要多等一等,时间比较久。
关闭 log_bin_trust_function_creators选项
mysql -uroot -p
password
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;
配置Zabbix 数据库
vi /etc/zabbix/zabbix_server.conf
取消DBPassword注释,并赋值
DBPassword=Abc@123.com
启动Zabbix server和agent进程
systemctl restart zabbix-server zabbix-agent2 httpd php-fpm
systemctl enable zabbix-server zabbix-agent2 httpd php-fpm
安装中文包
yum install langpacks-zh_CN.noarch
访问网站
http://x.x.x.x/zabbix/
Admin
zabbix