zabbix官网:https://www.zabbix.com/
- 安装Zabbix存储库
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all
- 安装Zabbix server,Web前端,agent
yum install zabbix-server-mysql zabbix-agent -y
- 安装Zabbix前端
启用红帽软件集合
yum install centos-release-scl -y
编辑配置文件 /etc/yum.repos.d/zabbix.repo 并启用zabbix-frontend
存储库。
[zabbix-frontend]
...
enabled=1
...
安装Zabbix前端包
yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl -y
- 安装mysql
查看是否有mariadb,有先卸载掉
rpm -qa|grep mariadb
删除mariadb,命令:rpm -e --nodeps mariadb-libs
mysql官网下载离线包:https://dev.mysql.com/downloads/mysql/
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.31-1.el7.x86_64.rpm-bundle.tar
解压包
[root@localhost opt]# tar -xvf mysql-8.0.31-1.el7.x86_64.rpm-bundle.tar
mysql-community-client-8.0.31-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm
mysql-community-common-8.0.31-1.el7.x86_64.rpm
mysql-community-debuginfo-8.0.31-1.el7.x86_64.rpm
mysql-community-devel-8.0.31-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.31-1.el7.x86_64.rpm
mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm
mysql-community-libs-8.0.31-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.31-1.el7.x86_64.rpm
mysql-community-server-8.0.31-1.el7.x86_64.rpm
mysql-community-server-debug-8.0.31-1.el7.x86_64.rpm
mysql-community-test-8.0.31-1.el7.x86_64.rpm
安装mysql
rpm -i mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm
rpm -i mysql-community-common-8.0.31-1.el7.x86_64.rpm
rpm -i mysql-community-libs-8.0.31-1.el7.x86_64.rpm
rpm -i mysql-community-server-8.0.31-1.el7.x86_64.rpm
rpm -i mysql-community-client-8.0.31-1.el7.x86_64.rpm
rpm -i mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm
rpm -i mysql-community-server-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.31-1.el7.x86_64.rpm
启动mysql,并设置开机自启
[root@localhost opt]# systemctl start mysqld
[root@localhost opt]# systemctl enable mysqld
[root@localhost opt]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2022-12-03 23:19:50 CST; 7s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 12842 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 12925 (mysqld)
Status: "Server is operational"
CGroup: /system.slice/mysqld.service
└─12925 /usr/sbin/mysqld
Dec 03 23:19:37 localhost systemd[1]: Starting MySQL Server...
Dec 03 23:19:50 localhost systemd[1]: Started MySQL Server.
查看mysql初始密码
[root@localhost opt]# grep password /var/log/mysqld.log
2022-12-03T15:19:43.671682Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: aiABK61z!Hg8
使用ALTER语句修改默认密码
[root@localhost opt]# mysql -uroot -p
Enter password:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
创建zabbix初始数据库
mysql> create database zabbix character set utf8 collate utf8_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> flush privileges;
mysql> quit;
导入初始架构和数据,系统将提示您输入新创建的密码。
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix -Dzabbix
在导入数据库模式后禁用log_bin_trust_function_创建者选项。
# 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前端配置PHP
编辑配置文件 /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf 取消注释并设置’listen’和’server_name’指令。
listen 80;
server_name ip地址;
编辑配置文件 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf 添加nginx监听。acl_users指令。
listen.acl_users = apache,nginx
取消注释并设置正确的时区。
php_value[date.timezone] = Asia/Shanghai
- 启动Zabbix server和agent进程
启动Zabbix server和agent进程,并为它们设置开机自启:
systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
报错
error while loading shared libraries: libmysqlclient.so.18: cannot open
yum -y install libmysqlclient.so.18
报错
[root@bogon ~]# tail -n 5 /var/log/zabbix/zabbix_server.log
2339:20221206:113447.180 TLS support: YES
2339:20221206:113447.180 ******************************
2339:20221206:113447.180 using configuration file: /etc/zabbix/zabbix_server.conf
2339:20221206:113447.183 [Z3001] connection to database 'zabbix' failed: [2059] Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
2339:20221206:113447.183 Cannot connect to the database. Exiting...
[root@bogon ~]#
解决方法
mysql> use mysql;
mysql> select user,host,plugin,authentication_string from user; # 查看身份验证插件是否为mysql_native_password
mysql> alter user 'zabbix'@'localhost' identified with mysql_native_password by 'password';
mysql> select user,host,plugin,authentication_string from user; # 再次查看验证方式,已经改了
原因:
身份验证插件找不到。
原来的身份验证插件为(mysql_native_password)。zabbix找不到新的身份验证插件(caching_sha2_password),
我们将mysql用户使用的登录密码加密规则 还原成 mysql_native_password,即可登陆成功。
再次重启zabbix-server即可
再次访问web页面,发现访问失败,但是curl 可以成功访问
解决方法:修改 /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
注释掉fastcgi_pass 行,添加fastcgi_pass 127.0.0.1:9000;
再次访问 http://ip
报错
解决方法:
修改配置文件 参数 /etc/opt/rh/rh-php72/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = ‘Asia/Shanghai’
重启服务
systemctl restart rh-php72-php-fpm
刷新页面查看
登录
Admin
zabbix
汉化
Zabbix汉化乱码问题
Win+R打开此窗口。 输入\Windows\Fonts
选择一个字体,上传到服务器
上传文件到 /usr/share/zabbix/assets/fonts/
修改配置文件vim /usr/share/zabbix/include/defines.inc.php
刷新web页面,乱码解决