该文章会延续上一章Zabbix7.0安装的基础环境

Zabbix01

192.168.10.133

Server, Frontend, Agent,Apache

Zabbix02

192.168.10.134

Server, Frontend, Agent,Apache

DB01

192.168.10.135

MySQL

在Zabbix01继续修改Zabbix_server.conf配置文件

[root@zabbix01 ~]# cat /etc/zabbix/zabbix_server.conf  | grep -v '^$' | grep -v '^#'
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/run/zabbix/zabbix_server.pid
SocketDir=/run/zabbix
DBHost=DB01
DBName=zabbix
DBUser=zabbix
DBPassword=password
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
HANodeName=zabbix01
NodeAddress=192.168.10.133:10051
[root@zabbix01 ~]#

在Zabbix02修改Zabbix_server.conf

[root@zabbix02 ~]#  cat /etc/zabbix/zabbix_server.conf  | grep -v '^$' | grep -v '^#'
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/run/zabbix/zabbix_server.pid
SocketDir=/run/zabbix
DBHost=DB01
DBName=zabbix
DBUser=zabbix
DBPassword=password
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
HANodeName=zabbix02
NodeAddress=192.168.10.134:10051
[root@zabbix02 ~]#

在Zabbix01拷贝文件至Zabbix02

[root@zabbix01 ~]# scp /etc/zabbix/web/zabbix.conf.php  root@zabbix02:/etc/zabbix/web/
root@zabbix02's password:
zabbix.conf.php                                                                                                            100% 1608   816.3KB/s   00:00
[root@zabbix01 ~]#

参考Zabbix01文件权限,修改文件权限

[root@zabbix01 ~]# ls -latr /etc/zabbix/web/zabbix.conf.php
-rw-------. 1 apache apache 1608 Jan 31 11:28 /etc/zabbix/web/zabbix.conf.php
[root@zabbix01 ~]#

在Zabbix02修改如下

[root@zabbix02 ~]# ls -latr /etc/zabbix/web/zabbix.conf.php
-rw-------. 1 root root 1608 Jan 31 11:53 /etc/zabbix/web/zabbix.conf.php
[root@zabbix02 ~]# chown apache.apache /etc/zabbix/web/zabbix.conf.php
[root@zabbix02 ~]# ls -latr /etc/zabbix/web/zabbix.conf.php
-rw-------. 1 apache apache 1608 Jan 31 11:53 /etc/zabbix/web/zabbix.conf.php
[root@zabbix02 ~]#

在Zabbix01和Zabbix02重启Zabbix相关的服务

Zabbix01

[root@zabbix01 ~]#  systemctl restart zabbix-server zabbix-agent httpd php-fpm
[root@zabbix01 ~]#

Zabbix02

[root@zabbix02 ~]#  systemctl restart zabbix-server zabbix-agent httpd php-fpm
[root@zabbix02 ~]# 

登录web验证

Zabbix HA cluster_赵广生

Zabbix HA cluster_赵广生_02

该指令只能在active主机进行命令行验证

[root@zabbix02 web]# zabbix_server -R ha_status
Failover delay: 60 seconds
Cluster status:
   #  ID                        Name                      Address                        Status      Last Access
   1. cls19ahmh0001f2lptkw9ztx5 zabbix01                  192.168.10.133:10051           stopped     22m 30s
   2. cls19ifgo0001umlqp1i9lx1j zabbix02                  192.168.10.134:10051           active      2s
[root@zabbix02 web]#

standby模式主机

[root@zabbix01 ~]# zabbix_server -R ha_status
Runtime commands can be executed only in active mode
[root@zabbix01 ~]#

在Zabbix01web添加一台基于agent监控主机

Zabbix HA cluster_Zabbix_03

在Zabbix02节点web已经同步过去

Zabbix HA cluster_Zabbix_04

日志显示节点01处于standby模式

[root@zabbix01 conf.d]# tail -f /var/log/zabbix/zabbix_server.log
 13516:20240131:120843.563 thread stopped [discovery worker #5]
 13516:20240131:120843.563 thread stopped [discovery worker #3]
 13520:20240131:120843.564 syncing history data in progress...
 13520:20240131:120843.564 syncing history data done
 13556:20240131:120843.567 thread stopped
 13516:20240131:120843.567 thread stopped [discovery worker #4]
 13502:20240131:120845.148 HA manager has been stopped
 13501:20240131:120845.156 syncing trend data...
 13501:20240131:120845.171 syncing trend data done
 13501:20240131:120845.175 Zabbix Server stopped. Zabbix 7.0.0beta1 (revision 9bc845eca94).
 13746:20240131:123249.686 Starting Zabbix Server. Zabbix 7.0.0beta1 (revision 9bc845eca94).
 13746:20240131:123249.686 ****** Enabled features ******
 13746:20240131:123249.686 SNMP monitoring:           YES
 13746:20240131:123249.686 IPMI monitoring:           YES
 13746:20240131:123249.686 Web monitoring:            YES
 13746:20240131:123249.686 VMware monitoring:         YES
 13746:20240131:123249.686 SMTP authentication:       YES
 13746:20240131:123249.686 ODBC:                      YES
 13746:20240131:123249.686 SSH support:               YES
 13746:20240131:123249.686 IPv6 support:              YES
 13746:20240131:123249.686 TLS support:               YES
 13746:20240131:123249.686 ******************************
 13746:20240131:123249.686 using configuration file: /etc/zabbix/zabbix_server.conf
 13746:20240131:123249.721 current database version (mandatory/optional): 06050209/06050209
 13746:20240131:123249.721 required mandatory version: 06050209
 13747:20240131:123249.740 starting HA manager
 13747:20240131:123249.751 HA manager started in standby mode
 13746:20240131:123249.752 "zabbix01" node started in "standby" mode

zabbix HA 参考:https://www.zabbix.com/documentation/devel/en/manual/concepts/server/ha