一、安装zabbix-server
1、内网服务器配置DNS、代理(https_proxy、http_proxy)
2、下载安装release文件:rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-4.el8.noarch.rpm
3、修改zabbix url https为http
4、安装相关组件:dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
二、安装Apache
centos 8 stream系统自带PHP、HTTPD
三:安装MySQL
1、卸载自带mariadb:rpm -qa | grep mariadb,使用rpm -e --nodeps命令将上述查询出来marridb包均卸载掉
2、安装MySQL
安装MySQL repo
rpm -Uvh http://repo.mysql.com/mysql80-community-release-el8-1.noarch.rpm(安装该版rpm后续安装无法正常进行,更换mysql80-community-release-el8-9.noarch.rpm)
安装MySQL
yum module -y disable mysql
dnf install -y mysql-community-server
启动mysql
systemctl start mysqld.service
设置mysql开机自启
systemctl enable mysqld.service
获取mysql临时密码
grep ‘temporary password’ /var/log/mysqld.log
登录mysql并修改密码
mysql -uroot -p
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘new_password’;
四、创建初始数据库
登录mysql:mysql -uroot -p
create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@localhost identified by ‘password’;
grant all privileges on zabbix.* to zabbix@localhost;
set global log_bin_trust_function_creators = 1;
导入初始架构和数据,系统将提示您输入新创建的密码
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;
mysql> quit;
五、为Zabbix server配置数据库
编辑配置文件 /etc/zabbix/zabbix_server.conf
DBPassword=password
六、启动Zabbix server和agent进程
启动Zabbix server和agent进程,并为它们设置开机自启:
systemctl restart zabbix-server zabbix-agent httpd php-fpm
systemctl enable zabbix-server zabbix-agent httpd php-fpm
注:
1、centos 8 stream重启网卡命令:nmcli c reload
2、软件安装命令:dnf/yum/rpm
报错处理:
1、systemctl restart zabbix-server zabbix-agent httpd php-fpm
查看日志:/usr/sbin/zabbix_server: error while loading shared libraries: libmariadb.so.3
最终重新安装64位包解决:yum install mariadb-connector-c.x86_64
2、httpd: Could not reliably determine the server’s fully qualified domain name
修改 /etc/httpd/conf/httpd.conf文件,#ServerName www.example.com:80修改为ServerName IP:80
3、网页登录报错
不能连接到数据库。The server requested authentication method unknown to the client
原因:因为mysql8升级了密码的验证方式 caching_sha2_password, 之前一直是mysql_native_password方式,而php都升级到7.2+不支持caching_sha2_password。
修改my.cnf,添加一行default_authentication_plugin=mysql_native_password
重启MySQL
登入MySQL:
use mysql;
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘root’;
FLUSH PRIVILEGES;#刷新权限