关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
关闭selinux
sed -i 's/enforcing/disabled/' /etc/selinux/config # 永久
setenforce 0 # 临时
升级MariaDB源,zabbix6.0必须10.5以上版本
vim /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.5 CentOS repository list - created 2021-12-01 06:20 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://mirror.kku.ac.th/mariadb/yum/10.5/centos8-amd64
module_hotfixes=1
gpgkey=https://mirror.kku.ac.th/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
vim deploy_zabbix6.sh
#!/bin/bash
#Author:demoduan
#Blog:https://www.cnblogs.com/demoduan
IP=`ip -4 a show ens160 |grep inet |awk '{print $2}' |cut -d/ -f1`
systemctl disable firewalld.service --now
setenforce 0
rpm -Uvh http://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
yum -y install zabbix-server-mysql.x86_64 zabbix-web-mysql.noarch zabbix-nginx-conf.noarch
yum -y install mariadb-server
systemctl enable mariadb.service --now
cat >zabbix.txt <<EOF
create database zabbix character set utf8 collate utf8_bin;
grant all on zabbix.* to zabbix@localhost identified by 'zabbix';
flush privileges;
exit
EOF
mysql <zabbix.txt
rm -f zabbix.txt
rpm -Uvh http://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-sql-scripts-6.0.0-1.el8.noarch.rpm
path1=`rpm -ql zabbix-sql-scripts |grep 'server.sql.gz' |grep mysql`
zcat $path1 |mysql -uzabbix -pzabbix zabbix
target1=`egrep -v "^#|^$" /etc/zabbix/zabbix_server.conf -n |grep DBUser |cut -d: -f1`
sed -i "${target1}a DBPassword=zabbix" /etc/zabbix/zabbix_server.conf
path2=`find /etc/ -name zabbix.conf |grep nginx`
sed -i "2,3s/#//; s/example.com/$IP/" $path2
systemctl restart zabbix-server.service php-fpm.service nginx.service
systemctl enable zabbix-server.service php-fpm.service nginx.service
上面脚本执行成功后,在web界面访问本机IP