ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

kingbaseES R6集群切换priority为0测试案例

2022-01-25 15:35:18  阅读:199  来源: 互联网

标签:03 R6 01 10 priority 12 2021 keepalives kingbaseES


案例说明:

在一主多备的架构中,需要配置一台备库在主备切换时,不能选举为主库。对于repmgr主备切换主库的选择算法如下:

Tips:
Repmgr选举候选备节点会以以下顺序选举:LSN ---->Priority----> Node_ID。
系统会先选举一个LSN比较大者作为候选备节点;如LSN一样,会根据Priority优先级进行比较,该优先级是在配置文件中进行参数配置;如优先级也一样,会比较节点的Node ID,小者会优先选举。在选举主机过程中,权重高的备机具有升主的更高优先级,如果权重为0,则该备机永远不会升级为主机。

repmgr集群,默认主备库优先级都是100:

对于repmgr.conf中的参数priority:
priority=60

权重,在选举主机过程中,权重高的备机具有升主的更高优先级,如果权重为0,则该备机永远不会升级为主机

修改priority参数:

测试案例:

1、切换前集群节点状态

[kingbase@node1 bin]$ ./repmgr cluster show
 ID | Name    | Role    | Status    | Upstream | Location | Priority | Timeline | Connection string                                                                                                                                
----+---------+---------+-----------+----------+----------+----------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------
 1  | node248 | primary | * running |          | default  | 100      | 10       | host=192.168.7.248 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
 3  | node243 | standby |   running | node248  | default  | 0        | 10       | host=192.168.7.243 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

** 2、修改repmgr.conf中priority参数**

 [kingbase@node1 etc]$ vi repmgr.conf 
on_bmj=off
.......
priority=0

重新注册备库:

[kingbase@node3 bin]$ ./repmgr standby register --force
INFO: connecting to local node "node243" (ID: 3)
INFO: connecting to primary database
INFO: standby registration complete
NOTICE: standby node "node243" (ID: 3) successfully registered

在集群节点状态信息中,standby的priority显示为0:

3、重启主库系统做failover切换测试
[root@node1 ~]#reboot

4、在备库查看集群节点状态

=== 如下所示,集群未发生切换,只是显示主库不能连接===

[kingbase@node3 bin]$ ./repmgr cluster show
 ID | Name    | Role    | Status        | Upstream  | Location | Priority | Timeline | Connection string                                                                                                                                
----+---------+---------+---------------+-----------+----------+----------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------
 1  | node248 | primary | ? unreachable |           | default  | 100      | ?        | host=192.168.7.248 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
 3  | node243 | standby |   running     | ? node248 | default  | 0        | 10       | host=192.168.7.243 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

WARNING: following issues were detected
  - unable to connect to node "node248" (ID: 1)
  - node "node248" (ID: 1) is registered as an active primary but is unreachable
  - unable to connect to node "node243" (ID: 3)'s upstream node "node248" (ID: 1)
  - unable to determine if node "node243" (ID: 3) is attached to its upstream node "node248" (ID: 1)

5、主库系统重启后,启动数据库服务

[kingbase@node1 bin]$ ./sys_ctl start -D ../data
waiting for server to start....2021-03-01 12:03:41.870 CST [5257] LOG:  sepapower extension initialized
2021-03-01 12:03:41.893 CST [5257] LOG:  starting KingbaseES V008R006C003B0010 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit
2021-03-01 12:03:41.893 CST [5257] LOG:  listening on IPv4 address "0.0.0.0", port 54321
2021-03-01 12:03:41.893 CST [5257] LOG:  listening on IPv6 address "::", port 54321
2021-03-01 12:03:42.030 CST [5257] LOG:  listening on Unix socket "/tmp/.s.KINGBASE.54321"
2021-03-01 12:03:42.454 CST [5257] LOG:  redirecting log output to logging collector process
2021-03-01 12:03:42.454 CST [5257] HINT:  Future log output will appear in directory "sys_log".
. done
server started

6、集群节点状态恢复正常

[kingbase@node1 bin]$ ./repmgr cluster show
 ID | Name    | Role    | Status    | Upstream | Location | Priority | Timeline | Connection string                                                                                                                                
----+---------+---------+-----------+----------+----------+----------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------
 1  | node248 | primary | * running |          | default  | 100      | 10       | host=192.168.7.248 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
 3  | node243 | standby |   running | node248  | default  | 0        | 10       | host=192.168.7.243 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

7、查看备库repmgr.log日志

=== 提示备库priority=0 ,不能提升为主库===

[2021-03-01 12:43:30] [NOTICE] starting monitoring of node "node243" (ID: 3)
[2021-03-01 12:43:30] [INFO] "connection_check_type" set to "ping"
[2021-03-01 12:43:30] [INFO] monitoring connection to upstream node "node248" (ID: 1)
[2021-03-01 12:43:30] [NOTICE] wal catched_up state changed to 1
[2021-03-01 12:45:00] [WARNING] unable to ping "host=192.168.7.248 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3"
[2021-03-01 12:45:00] [DETAIL] PQping() returned "PQPING_REJECT"
[2021-03-01 12:45:00] [WARNING] unable to connect to upstream node "node248" (ID: 1)
[2021-03-01 12:45:00] [INFO] sleeping 5 seconds until next reconnection attempt
[2021-03-01 12:45:05] [INFO] checking state of node 1, 1 of 3 attempts
[2021-03-01 12:45:15] [WARNING] unable to ping "user=esrep connect_timeout=10 dbname=esrep host=192.168.7.248 port=54321 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3 fallback_application_name=repmgr"
[2021-03-01 12:45:15] [DETAIL] PQping() returned "PQPING_NO_RESPONSE"
[2021-03-01 12:45:15] [INFO] sleeping 5 seconds until next reconnection attempt
[2021-03-01 12:45:20] [INFO] checking state of node 1, 2 of 3 attempts
[2021-03-01 12:45:30] [WARNING] unable to ping "user=esrep connect_timeout=10 dbname=esrep host=192.168.7.248 port=54321 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3 fallback_application_name=repmgr"
[2021-03-01 12:45:30] [DETAIL] PQping() returned "PQPING_NO_RESPONSE"
[2021-03-01 12:45:30] [INFO] sleeping 5 seconds until next reconnection attempt
[2021-03-01 12:45:35] [INFO] checking state of node 1, 3 of 3 attempts
[2021-03-01 12:45:45] [WARNING] unable to ping "user=esrep connect_timeout=10 dbname=esrep host=192.168.7.248 port=54321 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3 fallback_application_name=repmgr"
[2021-03-01 12:45:45] [DETAIL] PQping() returned "PQPING_NO_RESPONSE"
[2021-03-01 12:45:45] [WARNING] unable to reconnect to node 1 after 3 attempts
[2021-03-01 12:45:45] [NOTICE] setting "wal_retrieve_retry_interval" to 86405000 milliseconds
[2021-03-01 12:45:45] [INFO] sleeping 5 seconds
[2021-03-01 12:45:50] [NOTICE] killing WAL receiver with PID 14273
[2021-03-01 12:45:51] [INFO] WAL receiver with pid 14273 killed
[2021-03-01 12:45:52] [NOTICE] WAL receiver disconnected on all sibling nodes
[2021-03-01 12:45:52] [INFO] WAL receiver disconnected on all 0 sibling nodes
[2021-03-01 12:45:52] [NOTICE] this node's priority is 0 so will not be considered as an automatic promotion candidate
[2021-03-01 12:45:52] [NOTICE] setting "wal_retrieve_retry_interval" to 5000 ms
[2021-03-01 12:45:52] [INFO] follower node awaiting notification from a candidate node

8、修改备库优先级为默认优先级

1)注释或删除priority参数配置

2)重新注册standby

[kingbase@node3 bin]$ ./repmgr standby register --force
INFO: connecting to local node "node243" (ID: 3)
INFO: connecting to primary database
INFO: standby registration complete
NOTICE: standby node "node243" (ID: 3) successfully registered

3)查看集群节点状态

[kingbase@node3 bin]$ ./repmgr cluster show
 ID | Name    | Role    | Status    | Upstream | Location | Priority | Timeline | Connection string                                                                                                                                
----+---------+---------+-----------+----------+----------+----------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------
 1  | node248 | primary | * running |          | default  | 100      | 10       | host=192.168.7.248 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
 3  | node243 | standby |   running | node248  | default  | 100      | 10       | host=192.168.7.243 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

标签:03,R6,01,10,priority,12,2021,keepalives,kingbaseES
来源: https://www.cnblogs.com/tiany1224/p/15843057.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有