zabbix-proxy代理服务器配置

下载zabbix源

rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

安装

yum -y install zabbix-proxy-mysql zabbix_get

查看相关文件路径

rpm -ql zabbix-proxy-mysql

创建数据库

mysq -uroot -proot

mysql> create database zabbix_proxy character set utf8 collate utf8_bin; 

mysql> GRANT ALL PRIVILEGES ON zabbix_proxy.* TO 'zabbix_proxy'@'%';

mysql> flush privileges;

mysql> exit

导入初始数据
zcat /usr/share/doc/zabbix-proxy-mysql-5.0.38/schema.sql.gz | mysql -uzabbix_proxy -pzabbix zabbix_proxy

mysql  -uzabbix_proxy -p

mysql> user zabbix_proxy;
mysql> show tables;

mysql> exit

systemc restart mysql

 修改proxy.conf配置文件

[root@test-03 ~]# grep '^[a-Z]' /etc/zabbix/zabbix_proxy.conf
Server=192.168.40.113  #zabbix-server ip
Hostname=test-03   #proxy主机名称
LogFile=/var/log/zabbix/zabbix_proxy.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_proxy.pid
SocketDir=/var/run/zabbix
DBName=zabbix_proxy  #数据库名称
DBUser=zabbix_proxy    #数据库用户
DBPassword=zabbix     #数据库密码
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1

systemc restart zabbix-proxy
 

报错问题

1、 20949:20231018:080621.069 database is down: reconnecting in 10 seconds
 20949:20231018:080631.069 [Z3001] connection to database 'zabbix_proxy' failed: [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sok' (2)

因为zabbix-proxy找不到 /var/lib/mysql/mysql.sok 所以报错

mysq -uroot -proot
mysql> SHOW VARIABLES LIKE 'socket';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| socket        | /tmp/mysql.sock |
+---------------+-----------------+
1 row in set (0.00 sec)

确认sock安装路径,在zabbix_proxy.conf 203修改配置

vim /etc/zabbix/zabbix_proxy.conf

203  DBSocket=/tmp/mysql.sock

2、25305:20231018:081433.392 using configuration file: /etc/zabbix/zabbix_proxy.conf 25305:20231018:081433.394 [Z3001] connection to database 'zabbix_proxy' 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 25305:20231018:081433.394 Cannot connect to the database. Exiting...

根据错误信息,你遇到了一个关于 MySQL 认证插件 caching_sha2_password 的问题。这个插件要求共享对象文件 caching_sha2_password.so,但在指定的路径 /usr/lib64/mysql/plugin/ 下找不到该文件。

解决此问题的方法是,你可以尝试更改 MySQL 用户的认证插件,以使用较旧的 mysql_native_password 插件,这在较旧版本的 MySQL 中更常见。以下是解决方法:

mysql> ALTER USER 'zabbix_proxy'@'%' IDENTIFIED WITH 'mysql_native_password' BY 'zabbix';
Query OK, 0 rows affected (0.07 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.03 sec)

mysql>
mysql> exit

systemctl restart mysql

web配置

zabbix-proxy代理服务器配置_第1张图片

zabbix-proxy代理服务器配置_第2张图片

在zabbix-server查看

[root@localhost ~]# tailf /var/log/zabbix/zabbix_server.log
  9946:20231018:155145.260 server #34 started [trapper #4]
  9949:20231018:155145.261 server #37 started [alert syncer #1]
  9945:20231018:162028.694 sending configuration data to proxy "test-03" at "192.168.40.18", datalen 3662, bytes 1299 with compression ratio 2.8
  9944:20231018:162029.795 sending configuration data to proxy "test-03" at "192.168.40.18", datalen 3662, bytes 1299 with compression ratio 2.8
  9925:20231018:162145.372 executing housekeeper
  9925:20231018:162148.973 housekeeper [deleted 7662 hist/trends, 265000 items/triggers, 0 events, 0 problems, 0 sessions, 0 alarms, 0 audit, 0 records in 3.599864sec, idle for 1 hour(s)]

 zabbix-proxy代理服务器配置_第3张图片


 

你可能感兴趣的:(zabbix,linux,运维)