案例说明:

本案例通过对KingbaseES V8R3集群failover切换过程进行观察,分析了主备库切换后wal日志的变化,对应用者了解KingbaseES V8R3(R6) failover切换过程有一定的帮助。

以下为现场案例:

failover切换后主备库的wal日志信息:

新主库数据库服务启动故障:(sys_log)

=如下所示,在sys_log中,新主库启动startup后,建立流复制,流复制的起始wal日志是:“ 00000004000000050000002A”,导致复制失败。=

适用版本:

KingbaseES V8R3/R6

节点信息:

集群节点状态信息:

[kingbase@node102 bin]$ ./ksql -U SYSTEM -W 123456 TEST -p 9999
ksql (V008R003C002B0290)
Type "help" for help. TEST=# show pool_nodes;
node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay
---------+---------------+-------+--------+-----------+---------+------------+-------------------+-------------------
0 | 192.168.1.101 | 54321 | up | 0.500000 | standby | 0 | true | 0
1 | 192.168.1.102 | 54321 | up | 0.500000 | primary | 0 | false | 0
(2 rows)

一、查看failover切换前节点信息

1、原主库wal日志

[kingbase@node102 sys_xlog]$ ls -lh
.......
-rw------- 1 kingbase kingbase 16M Jul 7 15:25 00000009000000000000002D.partial
-rw------- 1 kingbase kingbase 339 Jul 7 15:09 00000009.history
-rw------- 1 kingbase kingbase 16M Jul 29 10:56 0000000A000000000000002D
-rw------- 1 kingbase kingbase 16M Jul 29 16:32 0000000A000000000000002E
-rw------- 1 kingbase kingbase 16M Aug 3 10:22 0000000A000000000000002F
-rw------- 1 kingbase kingbase 382 Jul 7 15:25 0000000A.history

2、原主库控制文件信息

[kingbase@node102 bin]$ ./sys_controldata -D ../data
sys_control version number: 830
Catalog version number: 201608131
Database system identifier: 7080416207291699599
Database cluster state: in production
sys_control last modified: Wed 03 Aug 2022 10:26:57 AM CST
Latest checkpoint location: 0/2F000108
Prior checkpoint location: 0/2F000028
Latest checkpoint's REDO location: 0/2F0000D0
Latest checkpoint's REDO WAL file: 0000000A000000000000002F
Latest checkpoint's TimeLineID: 10
Latest checkpoint's PrevTimeLineID: 10

3、备库wal日志

[kingbase@node101 bin]$ ls -lh ../data/sys_xlog
.......
-rw------- 1 kingbase kingbase 16M Jul 7 15:25 00000009000000000000002D
-rw------- 1 kingbase kingbase 339 Jun 22 16:15 00000009.history
-rw------- 1 kingbase kingbase 16M Jul 29 16:14 0000000A000000000000002D
-rw------- 1 kingbase kingbase 16M Aug 3 10:22 0000000A000000000000002E
-rw------- 1 kingbase kingbase 16M Aug 3 10:27 0000000A000000000000002F
-rw------- 1 kingbase kingbase 382 Jul 29 10:33 0000000A.history

4、备库控制文件信息

[kingbase@node101 bin]$ ./sys_controldata -D ../data
sys_control version number: 830
Catalog version number: 201608131
Database system identifier: 7080416207291699599
Database cluster state: in archive recovery
sys_control last modified: Wed 03 Aug 2022 10:26:55 AM CST
Latest checkpoint location: 0/2F000028
Prior checkpoint location: 0/2E0002C8
Latest checkpoint's REDO location: 0/2F000028
Latest checkpoint's REDO WAL file: 0000000A000000000000002F
Latest checkpoint's TimeLineID: 10
Latest checkpoint's PrevTimeLineID: 10

二、执行failover切换(关闭主库数据库服务)

1、关闭主库数据库服务

[kingbase@node102 bin]$ ./sys_ctl stop -D ../data
waiting for server to shut down....... done
server stopped

三、failover切换完成主备状态信息

1、新主库wal日志

[kingbase@node101 bin]$ ls -lh ../data/sys_xlog
.......
-rw------- 1 kingbase kingbase 339 Jun 22 16:15 00000009.history
-rw------- 1 kingbase kingbase 16M Jul 29 16:14 0000000A000000000000002D
-rw------- 1 kingbase kingbase 16M Aug 3 10:22 0000000A000000000000002E
-rw------- 1 kingbase kingbase 16M Aug 3 10:30 0000000A000000000000002F
-rw------- 1 kingbase kingbase 16M Aug 3 10:30 0000000A0000000000000030.partial
-rw------- 1 kingbase kingbase 382 Jul 29 10:33 0000000A.history
-rw------- 1 kingbase kingbase 16M Aug 3 10:31 0000000B0000000000000030
-rw------- 1 kingbase kingbase 426 Aug 3 10:30 0000000B.history

切换完成后timeline发生切换:

查看timeline history文件信息:

2、新主库控制文件信息

[kingbase@node101 bin]$  ./sys_controldata -D ../data
sys_control version number: 830
Catalog version number: 201608131
Database system identifier: 7080416207291699599
Database cluster state: in production
sys_control last modified: Wed 03 Aug 2022 10:35:48 AM CST
Latest checkpoint location: 0/3005E110
Prior checkpoint location: 0/30004BD8
Latest checkpoint's REDO location: 0/3005B370
Latest checkpoint's REDO WAL file: 0000000B0000000000000030
Latest checkpoint's TimeLineID: 11
Latest checkpoint's PrevTimeLineID: 11

3、新备库wal日志

[kingbase@node102 bin]$ ls -lh ../data/sys_xlog
.......
-rw------- 1 kingbase kingbase 16M Jul 29 10:56 0000000A000000000000002D
-rw------- 1 kingbase kingbase 16M Jul 29 16:32 0000000A000000000000002E
-rw------- 1 kingbase kingbase 16M Aug 3 10:34 0000000A000000000000002F
-rw------- 1 kingbase kingbase 16M Aug 3 10:34 0000000A0000000000000030.partial
-rw------- 1 kingbase kingbase 382 Aug 3 10:34 0000000A.history
-rw------- 1 kingbase kingbase 16M Aug 3 10:34 0000000B0000000000000030
-rw------- 1 kingbase kingbase 426 Aug 3 10:34 0000000B.history

4、新备库控制文件信息

[kingbase@node102 bin]$ ./sys_controldata -D ../data
sys_control version number: 830
Catalog version number: 201608131
Database system identifier: 7080416207291699599
Database cluster state: in archive recovery
sys_control last modified: Wed 03 Aug 2022 10:35:42 AM CST
Latest checkpoint location: 0/30004BD8
Prior checkpoint location: 0/30004BD8
Latest checkpoint's REDO location: 0/30004BA0
Latest checkpoint's REDO WAL file: 0000000B0000000000000030
Latest checkpoint's TimeLineID: 11
Latest checkpoint's PrevTimeLineID: 11

四、将原主库作为备库恢复到集群

1、在原主库data下创建recovery.conf

[kingbase@node102 data]$ cp ../etc/recovery.done ./recovery.conf

2、查看recovery.log信息

primary node/Im node status is changed, primary ip[192.168.1.101], recovery.conf NEED_CHANGE [0] (0 is need ), I,m status is [1] (1 is down), I will be in recovery.
node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay
---------+---------------+-------+--------+-----------+---------+------------+-------------------+-------------------
0 | 192.168.1.101 | 54321 | up | 0.500000 | primary | 0 | true | 0
1 | 192.168.1.102 | 54321 | down | 0.500000 | standby | 0 | false | 0
(2 rows) if recover node up, let it down , for rewind
2022-08-03 10:34:35 sys_rewind...
sys_rewind --target-data=/home/kingbase/cluster/R3HA/db/data --source-server="host=192.168.1.101 port=54321 user=SUPERMANAGER_V8ADMIN dbname=TEST"
datadir_source = /home/kingbase/cluster/R3HA/db/data
rewinding from last common checkpoint at 0/2F000108 on timeline 10
find last common checkpoint start time from 2022-08-03 10:34:35.349563 CST to 2022-08-03 10:34:35.405349 CST, in "0.055786" seconds.
reading source file list
reading target file list
reading WAL in target
Rewind datadir file from source
update the control file: minRecoveryPoint is '0/3004D0C8', minRecoveryPointTLI is '11', and database state is 'in archive recovery'
rewind start wal location 0/2F0000D0 (file 0000000A000000000000002F), end wal location 0/3004D0C8 (file 0000000B0000000000000030). time from 2022-08-03 10:34:37.349563 CST to 2022-08-03 10:34:37.872586 CST, in "2.523023" seconds.
Done!
sed conf change #synchronous_standby_names 2022-08-03 10:34:39 file operate
cp recovery.conf...
change recovery.conf ip -> primary.ip
2022-08-03 10:34:39 change recovery.conf
delete pid file if exist
del the replication_slots if exis
drop the slot [slot_node101].
drop the slot [slot_node102].
2022-08-03 10:34:40 start up the kingbase...
waiting for server to start....LOG: redirecting log output to logging collector process
HINT: Future log output will appear in directory "/home/kingbase/cluster/R3HA/db/data/sys_log".
done
server started
ksql "port=54321 user=SUPERMANAGER_V8ADMIN dbname=TEST connect_timeout=10" -c "select 33333;"
SYS_CREATE_PHYSICAL_REPLICATION_SLOT
--------------------------------------
(slot_node101,)
(1 row) 2022-08-03 10:34:42 create the slot [slot_node101] success.
SYS_CREATE_PHYSICAL_REPLICATION_SLOT
--------------------------------------
(slot_node102,)
(1 row) 2022-08-03 10:34:42 create the slot [slot_node102] success.
2022-08-03 10:34:42 start up standby successful!
can not get the replication of myself

如下所示:recovery过程:

五、总结

在集群执行failover切换时,可以结合wal日志和recovery.log和控制文件的变化,可以详细了解failover切换中wal日志的变化,及通过sys_rewind工具对原主库的恢复过程。

KingbaseES V8R3集群管理和维护案例之---failover切换wal日志变化分析的更多相关文章

  1. KingbaseES V8R3集群管理维护案例之---集群迁移单实例架构

    案例说明: 在生产中,需要将KingbaseES V8R3集群转换为单实例架构,可以采用以下方式快速完成集群架构的迁移. 适用版本: KingbaseES V8R3 当前数据库版本: TEST=# s ...

  2. KingbaseES V8R6集群管理运维案例之---repmgr standby switchover故障

    案例说明: 在KingbaseES V8R6集群备库执行"repmgr standby switchover"时,切换失败,并且在执行过程中,伴随着"repmr stan ...

  3. KingbaseES V8R3集群维护案例之---在线添加备库管理节点

    案例说明: 在KingbaseES V8R3主备流复制的集群中 ,一般有两个节点是集群的管理节点,分为master和standby:如对于一主二备的架构,其中有两个节点是管理节点,三个数据节点:管理节 ...

  4. KingbaseES V8R3集群运维案例之---主库系统down failover切换过程分析

    ​ 案例说明: KingbaseES V8R3集群failover时两个cluster都会触发,但只有一个cluster会调用脚本去执行真正的切换流程,另一个有对应的打印,但不会调用脚本,只是走相关的 ...

  5. KingbaseES R3 集群主库归档失败案例

    案例说明: 本案例用于KingbaseES R3集群归档进程归档日志失败的处理,对于一线的生产环境具有 一定的参考意义. 数据库版本: TEST=# select version(); VERSION ...

  6. KingbaseES V8R3集群运维案例之---用户自定义表空间管理

    ​案例说明: KingbaseES 数据库支持用户自定义表空间的创建,并建议表空间的文件存储路径配置到数据库的data目录之外.本案例复现了,当用户自定义表空间存储路径配置到data下时,出现的故障问 ...

  7. KingbaseES V8R3 集群专用机网关失败分析案例

    ​ KingbaseES R3集群网关检测工作机制: 1.Cluster下watchdog进程在固定间隔时间,通过ping 网关地址监控链路的连通性,如果连通网关地址失败,则修改cluster sta ...

  8. KingbaseES R6 集群手工配置VIP案例

    经常有用户问,V8R6集群搭建时没有配置VIP,搭建完成后,如何添加VIP?以下向大家介绍下手动添加VIP 的过程. 一.操作系统环境 操作系统(UOS): root@uos01:~# cat /et ...

  9. KingbaseES V8R6集群维护案例之---停用集群node_export进程

    案例说明: 在KingbaseES V8R6集群启动时,会启动node_exporter进程,此进程主要用于向kmonitor监控服务输出节点状态信息.在系统安全漏洞扫描中,提示出现以下安全漏洞: 对 ...

随机推荐

  1. Vue-简单安装和运行

    安装Vue CLI 安装nodejs 下载: https://nodejs.org/en/download/ 安装Vue CLI 文档: https://cli.vuejs.org/guide/ins ...

  2. 关闭windows更新、设置自启动、提高开发机性能

    做Java开发的朋友都知道,每次开机启动一堆的软件和工具,包括未写完的文档,是非常花时间的,加上一桌面的快捷方式,往往不是那么容易直接找到.windows的自动更新往往在凌晨自动启动,导致很多软件被异 ...

  3. 论文解读(AGC)《Attributed Graph Clustering via Adaptive Graph Convolution》

    论文信息 论文标题:Attributed Graph Clustering via Adaptive Graph Convolution论文作者:Xiaotong Zhang, Han Liu, Qi ...

  4. Navicat中查询mysql版本

    SELECT VERSION( ) FROM DUAL

  5. .NET ORM框架HiSql实战-第三章-使用自定义编号生成【申请编号】

    一.引言 上一篇.NET ORM框架HiSql实战-第二章-使用Hisql实现菜单管理(增删改查) 中菜单编号采用的是雪花ID,生成的编号无法自定义.比如本系统的一个申请业务,需要按前缀+日期+流水号 ...

  6. 研发效能生态完整图谱&DevOps工具选型必看

    本文主要梳理了研发效能领域完整的方向图谱以及主流工具,其中对少部分工具也做了一些点评.看了之后,大家可以对研发效能这个领域有个整体认识,同时研发效能落地的时候也有对应的工具(黑话叫抓手)可以选择. 我 ...

  7. 【FAQ】接入HMS Core推送服务,服务端下发消息常见错误码原因分析及解决方法

    HMS Core推送服务支持开发者使用HTTPS协议接入Push服务端,可以从服务器发送下行消息给终端设备.这篇文章汇总了服务端下发消息最常见的6个错误码,并提供了原因分析和解决方法,有遇到类似问题的 ...

  8. VS Code + GitHub

    来到博客园学着别人美化了一下自己的博客页面,蛮好看的,然后右上角有一个"Fork me on GitHub".之前就因为好奇而注册过GitHub,但一直不会使,现在正式开始编程学习 ...

  9. Dubbo源码(四) - 服务引用(消费者)

    前言 本文基于Dubbo2.6.x版本,中文注释版源码已上传github:xiaoguyu/dubbo 上一篇文章,讲了Dubbo的服务导出: Dubbo源码(三) - 服务导出(生产者) 本文,咱们 ...

  10. 清北学堂 2020 国庆J2考前综合强化 Day2

    目录 1. 题目 T1 一 题目描述 Sol T2 二 题目描述 Sol T3 三 题目描述 Sol T4 四 题目描述 Sol 2. 算法 -- 数据结构 1. 题目 T1 一 题目描述 问题描述 ...