KingbaseES V8R6集群运维系列 -- connect_check_type参数

案例说明:
在KingbaseES V8R6C7的版本中,repmgr.conf增加了connect_check_type参数可以指定参数值,默认值是‘mix’,以前版本为隐藏参数,默认值‘ping‘。connect_check_type参数可以配置为:

监控数据库connect_check_type设置:

connection_check _type:检查上游(upstream)数据库状态的方法。
ping,使用PQping()检查;
connection,建立数据库连接;
query,使用已有连接执行SELECT TRUE进行检查;
mix,平常使用PQping()进行检查,如果多次失败,最后一次使用已有连接执行 SELECT TRUE进行检查,否则一切正常。

可选参数:ping, connection, query, mix;默认为mix。

适用版本:
KingbaseES V8R6

1、集群架构及状态

# 节点信息
node1<------> 192.169.1.102
node2<------> 192.169.1.101

# 集群节点状态
[kingbase@node102 bin]$ ./repmgr cluster show

----+-------+---------+-----------+----------+----------+----------+----------+---------+---------------------------------------------------------------------------------------------------------------------------------------------------
  1  | node1 | standby |   running | node2    | default  | 100      | 2        | 0 bytes | host=192.168.1.102 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
 2  | node2 | primary | * running |          | default  | 100      | 2        |         | host=192.168.1.101 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

2、集群repmgr.conf配置

[kingbase@node102 bin]$ cat ../etc/repmgr.conf
use_scmd=off
ha_running_mode='DG'
node_id=1
node_name='node1'
conninfo='host=192.168.1.102 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3'
connection_check_type='mix'
.......
reconnect_attempts=2
reconnect_interval=5

默认connect_check_type参数:

3、模拟主库网卡down

[root@node101 ~]# ifdown enp0s3 && sleep 60 && ifup enp0s3

Device 'enp0s3' successfully disconnected.
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)

4、查看备库hamgr.log日志

---如下图所示,failover切换完成,原备库被promote为新的主库。

切换日志信息:

standby被提升为新主库:

5、切换完成

# 在repmgr.conf中配置recovery='automatic',会完成原主库自动recovery为新备库加入到集群中;其他参数需要手工恢复。
[kingbase@node102 bin]$ ./repmgr cluster show

 ID | Name  | Role    | Status    | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string               
----+-------+---------+-----------+----------+----------+----------+----------+---------+---------------------------------------------------------------------------------------------------------------------------------------------------
 1  | node1 | primary | * running |          | default  | 100      | 3        |         | host=192.168.1.102 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
 2  | node2 | standby |   running | node1    | default  | 100      | 3        | 0 bytes | host=192.168.1.101 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
posted @ 2023-09-20 14:11  KINGBASE研究院  阅读(57)  评论(0编辑  收藏  举报