1、安装mysql8
删除mariadb
yum -y remove mariadb*
2、删除mysql
yum -y remove mysql*
3、获取包
# rpm -Uvh https://repo.zabbix.com/zabbix/5.4/rhel/8/x86_64/zabbix-release-5.4-1.el8.noarch.rpm
# dnf clean all
4、安装Zabbix server,Web前端,agent
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-agent
5、安装mysql数据库
wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
yum install mysql-server
启动
systemctl start mysqld.service
查看mysql状态
systemctl status mysqld.service
mysql -uroot -p(密码是空的直接回车进入)
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newmysql';
创建用户和密码
CREATE USER 'root'@'%' IDENTIFIED BY 'newmysql';
权限赋给root用户,所有ip都能连接
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION;
更新root密码否则,远程登录会报错
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'newmysql';
刷新
FLUSH PRIVILEGES;
创建zabbix数据库
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'newmysql';
grant all privileges on zabbix.* to zabbix@localhost;
quit;
导入初始架构和数据,系统将提示您输入新创建的密码
zcat /usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz | mysql -uzabbix -p zabbix
输入mysql密码
加入3306端口
firewall-cmd --permanent --zone=public --add-port=3306/tcp
开启刷新防火墙
firewall-cmd --reload
开机自启动
systemctl enable mysqld
systemctl daemon-reload
6、为Zabbix server配置数据库
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=你的数据密码
保存退出
7、设置nginx文件
vim /etc/nginx/conf.d/zabbix.conf
去掉这两行前面的#号
listen 80;
server_name 你的IP;
8、启动Zabbix server和agent进程
启动Zabbix server和agent进程,并为它们设置开机自启:
systemctl restart zabbix-server zabbix-agent nginx php-fpm
systemctl enable zabbix-server zabbix-agent nginx php-fpm
设置selinux,vim /etc/selinux/config
修改SELINUX=disabled之后保存退出重启
9、访问zabbix:http://IP地址/setup.php
10、局域网访问:
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=10051/tcp
firewall-cmd --reload