KingbaseES V8R6集群案例---一主二备架构单个备库宕机事务影响测试

案例说明:

对于KingbaseES V8R6集群,在sync模式下,对于一主一备架构,如果备库宕机时,主库事务commit,会被hang住,在wal_sender_timeout参数(默认60s)超过阈值后,sync转为async后,事务才能完成commit;本案例在测试一主二备架构下,同步备库宕机后,主库事务处理是否有hang住现象。

适用版本:

KingbaseES V8R6

集群架构:

  ID | Name  | Role    | Status    | Upstream | repmgrd | PID   | Paused? | Upstream last seen
----+-------+---------+-----------+----------+---------+-------+---------+--------------------
1 | node1 | primary | * running | | running | 25697 | no | n/a
2 | node2 | standby | running | node1 | running | 582 | no | 1 second(s) ago
3 | node3 | standby | running | node1 | running | 12571 | no | 1 second(s) ago

测试脚本:

[kingbase@node101 shell]$ cat 1.sh
#!/bin/bash while true
do
/home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/bin/ksql -U system prod <<EOF
insert into test1 values (now());
EOF
done [kingbase@node101 shell]$ cat 2.sh
#!/bin/bash while true
do
/home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/bin/ksql -U system prod <<EOF
select * from test1;
EOF
done

一、测试一(synchronous='sync')

1、流复制同步配置

[kingbase@node101 bin]$ cat ../etc/repmgr.conf |grep sync
synchronous='sync' [kingbase@node101 bin]$ cat /data/kingbase/hac7/data/es_rep.conf |grep _commit
synchronous_commit = remote_apply

2、集群流复制状态

test=# select * from sys_stat_replication;
pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_
start | backend_xmin | state | sent_lsn | write_lsn | flush_lsn | replay_lsn | write_lag | flush
_lag | replay_lag | sync_priority | sync_state | reply_time
------+----------+---------+------------------+---------------+-----------------+-------------+-----------------
--------------+--------------+-----------+------------+------------+------------+------------+-----------+------
-----+------------+---------------+------------+-------------------------------
2840 | 16385 | esrep | node2 | 192.168.1.102 | | 44199 | 2023-06-21 14:47
:49.668343+08 | | streaming | 1/A5000680 | 1/A5000680 | 1/A5000680 | 1/A5000680 | |
| | 1 | sync | 2023-06-21 16:51:00.439757+08
2852 | 16385 | esrep | node3 | 192.168.1.103 | | 62335 | 2023-06-21 14:47
:51.035563+08 | | streaming | 1/A5000680 | 1/A5000680 | 1/A5000680 | 1/A5000680 | |
| | 2 | potential | 2023-06-21 16:50:54.103476+08
(2 rows) ---如上所示,node2为流复制中的sync节点。

3、主库执行测试脚本

session 1:
[kingbase@node101 shell]$ sh 1.sh & session 2:
[kingbase@node101 shell]$ sh 2.sh >1.log 2>&1

4、关闭同步备库数据库服务

node2节点宕机时间:

2023-06-25 13:52:01.037 CST,,,11890,,6497d534.2e72,5,,2023-06-25 13:48:36 CST,,0,LOG,00000,"database system is shut down",,,,,,,,,"

5、查看数据插入记录

如下所示,在同步备库宕机的时间点,并没有造成事务处理的中断(事务被hang住):

.......
2023-06-25 13:52:00.907013
2023-06-25 13:52:00.937465
2023-06-25 13:52:00.966735
2023-06-25 13:52:00.995530
2023-06-25 13:52:01.026226
2023-06-25 13:52:01.055470
2023-06-25 13:52:01.082933
2023-06-25 13:52:01.168686
2023-06-25 13:52:01.238983
2023-06-25 13:52:01.324240
2023-06-25 13:52:01.374047
2023-06-25 13:52:01.427150
2023-06-25 13:52:01.464301
2023-06-25 13:52:01.519301
2023-06-25 13:52:01.573772
2023-06-25 13:52:01.628080
2023-06-25 13:52:01.735475
2023-06-25 13:52:01.804554
2023-06-25 13:52:01.891160
2023-06-25 13:52:01.957588
2023-06-25 13:52:02.070638
2023-06-25 13:52:02.166344
2023-06-25 13:52:02.219404
2023-06-25 13:52:02.264405
2023-06-25 13:52:02.304738
.....

二、测试二(synchronous='quorum')

1、流复制同步配置

[kingbase@node101 bin]$ cat ../etc/repmgr.conf |grep sync
synchronous='quorum' [kingbase@node101 bin]$ cat /data/kingbase/hac7/data/es_rep.conf |grep _commit
synchronous_commit = remote_apply

2、集群流复制状态

test=# select * from sys_stat_replication;
pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | backend_xmin | state | sent_lsn | write_lsn | flush_lsn | replay_lsn | write_lag | flush_lag | replay_lag | sync_priority | sync_state | reply_time
------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+--------------+-----------+------------+------------+------------+------------+-----------+-----------+------------+---------------+------------+-------------------------------
4598 | 16385 | esrep | node2 | 192.168.1.102 | | 41421 | 2023-06-21 14:36:45.278823+08 | | streaming | 1/A30009F8 | 1/A30009F8 | 1/A30009F8 | 1/A30009F8 | | | | 1 | quorum | 2023-06-21 15:16:03.583408+08
8945 | 16385 | esrep | node3 | 192.168.1.103 | | 61295 | 2023-06-21 15:14:39.573214+08 | | streaming | 1/A30009F8 | 1/A30009F8 | 1/A30009F8 | 1/A30009F8 | | | | 1 | quorum | 2023-06-21 15:16:02.032845+08
(2 rows)

3、主库执行测试脚本

session 1:
[kingbase@node101 shell]$ sh 1.sh & session 2:
[kingbase@node101 shell]$ sh 2.sh >1.log 2>&1

4、关闭同步备库数据库服务

node2节点宕机时间:

2023-06-25 14:04:55.740 CST,,,18910,,6497d80f.49de,5,,2023-06-25 14:00:47 CST,,0,LOG,00000,"database system is shut down",,,,,,,,,"

5、查看数据插入记录

如下所示,在同步备库宕机的时间点,并没有造成事务处理的中断(事务被hang住):

 ........
2023-06-25 14:04:54.955449
2023-06-25 14:04:54.986434
2023-06-25 14:04:55.027062
2023-06-25 14:04:55.058955
2023-06-25 14:04:55.092413
2023-06-25 14:04:55.123352
2023-06-25 14:04:55.157153
2023-06-25 14:04:55.193440
2023-06-25 14:04:55.227700
2023-06-25 14:04:55.264961
2023-06-25 14:04:55.301582
2023-06-25 14:04:55.336236
2023-06-25 14:04:55.380388
2023-06-25 14:04:55.419770
2023-06-25 14:04:55.462793
2023-06-25 14:04:55.496123
2023-06-25 14:04:55.530339
2023-06-25 14:04:55.563342
2023-06-25 14:04:55.597350
2023-06-25 14:04:55.632114
2023-06-25 14:04:55.659785
2023-06-25 14:04:55.695025
2023-06-25 14:04:55.726024
2023-06-25 14:04:55.754980
2023-06-25 14:04:55.788829
2023-06-25 14:04:55.818428
2023-06-25 14:04:55.850334
2023-06-25 14:04:55.886098
2023-06-25 14:04:55.916974
2023-06-25 14:04:55.949975
2023-06-25 14:04:55.985593
2023-06-25 14:04:56.017278
2023-06-25 14:04:56.062645
2023-06-25 14:04:56.094456
2023-06-25 14:04:56.129149
.......

三、测试三(synchronous='all')

1、流复制同步配置

[kingbase@node101 bin]$ cat ../etc/repmgr.conf |grep sync
synchronous='all' [kingbase@node101 bin]$ cat /data/kingbase/hac7/data/es_rep.conf |grep _commit
synchronous_commit = remote_apply

2、集群流复制状态

test=# select * from sys_stat_replication;
pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | backend_xmin | state | sent_lsn | write_lsn | flush_lsn | replay_lsn | write_lag | flush_lag | replay_lag | sync_priority | sync_state | reply_time
-------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+--------------+-----------+------------+------------+------------+------------+-----------+-----------+------------+---------------+------------+-------------------------------
25468 | 16385 | esrep | node2 | 192.168.1.102 | | 42097 | 2023-06-21 16:28:11.888318+08 | | streaming | 1/A4000508 | 1/A4000508 | 1/A4000508 | 1/A4000508 | | | | 1 | sync | 2023-06-21 16:28:51.499723+08
25480 | 16385 | esrep | node3 | 192.168.1.103 | | 61309 | 2023-06-21 16:28:13.300779+08 | | streaming | 1/A4000508 | 1/A4000508 | 1/A4000508 | 1/A4000508 | | | | 1 | sync | 2023-06-21 16:28:54.034186+08
(2 rows) ---如上所示,node2为流复制中的sync节点。

3、主库执行测试脚本

session 1:
[kingbase@node101 shell]$ sh 1.sh & session 2:
[kingbase@node101 shell]$ sh 2.sh >1.log 2>&1

4、关闭同步备库数据库服务

node2节点宕机时间:

2023-06-25 14:12:06.618 CST,,,24878,,6497da69.612e,5,,2023-06-25 14:10:49 CST,,0,LOG,00000,"database system is shut down",,,,,,,,,"

5、查看数据插入记录

如下所示,在同步备库宕机的时间点,并没有造成事务处理的中断(事务被hang住):

......
2023-06-25 14:12:06.910576
2023-06-25 14:12:06.944394
2023-06-25 14:12:06.977977
2023-06-25 14:12:07.006902
2023-06-25 14:12:07.027061
2023-06-25 14:12:07.058800
2023-06-25 14:12:07.090143
2023-06-25 14:12:07.121745
2023-06-25 14:12:07.159289
2023-06-25 14:12:07.192978
2023-06-25 14:12:07.216982
2023-06-25 14:12:07.244713
2023-06-25 14:12:07.275212
2023-06-25 14:12:07.305201
2023-06-25 14:12:07.333306
2023-06-25 14:12:07.365943
2023-06-25 14:12:07.396400
2023-06-25 14:12:07.430124
2023-06-25 14:12:07.457527
2023-06-25 14:12:07.487357
2023-06-25 14:12:07.518364
2023-06-25 14:12:07.551942
2023-06-25 14:12:07.580497
2023-06-25 14:12:07.615095
2023-06-25 14:12:07.642226
2023-06-25 14:12:07.667587
2023-06-25 14:12:07.705081
2023-06-25 14:12:07.738520
2023-06-25 14:12:07.777657
2023-06-25 14:12:07.816077
2023-06-25 14:12:07.847995
2023-06-25 14:12:07.888306
2023-06-25 14:12:07.917725
2023-06-25 14:12:07.952045
2023-06-25 14:12:07.984344
2023-06-25 14:12:08.021621
2023-06-25 14:12:08.051968
2023-06-25 14:12:08.082699
2023-06-25 14:12:08.114964
2023-06-25 14:12:08.145950
2023-06-25 14:12:08.175424
......

四、总结

在一主多备的架构下,同步流复制模式中,当同步备库节点宕机时,不会影响主库事务操作的连续性,建议对事务处理性能要求高的业务环境,采用一主多备的集群架构。如Oracle的DataGuard,在最大保护模式,建议采用一主多备的架构。

KingbaseES V8R6集群案例---一主二备架构单个备库宕机事务影响测试的更多相关文章

  1. kingbaseES V8R6集群备份恢复案例之---备库作为repo主机执行物理备份

    ​ 案例说明: 此案例是在KingbaseES V8R6集群环境下,当主库磁盘空间不足时,执行sys_rman备份,将集群的备库节点作为repo主机,执行备份,并将备份存储在备库的磁盘空间. 集群架构 ...

  2. KingbaseES V8R6集群外部备份案例

    案例说明: 本案例采用sys_backup.sh执行物理备份,备份使用如下逻辑架构:集群采用CentOS 7系统,repo采用kylin V10 Server. 一主一备+外部备份 此场景为主备双机常 ...

  3. KingbaseES V8R6集群运维案例之---repmgr standby promote应用案例

    案例说明: 在容灾环境中,跨区域部署的异地备节点不会自主提升为主节点,在主节点发生故障或者人为需要切换时需要手动执行切换操作.若主节点已经失效,希望将异地备机提升为主节点. $bin/repmgr s ...

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

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

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

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

  6. KingbaseES V8R6集群维护之--修改数据库服务端口案例

    ​ 案例说明: 对于KingbaseES数据库单实例环境,只需要修改kingbase.conf文件的'port'参数即可,但是对于KingbaseES V8R6集群中涉及到多个配置文件的修改,并且在应 ...

  7. KingbaseES V8R6集群部署案例之---Windows环境配置主备流复制(异机复制)

    案例说明: 目前KingbaseES V8R6的Windows版本不支持数据库sys_rman的物理备份,可以考虑通过建立主备流复制实现数据库的异机物理备份.本案例详细介绍了,在Windows环境下建 ...

  8. KingbaseES V8R6集群部署案例之---Windows环境配置主备流复制(同一主机)

    案例说明: 目前KingbaseES V8R6的Windows版本不支持数据库sys_rman的物理备份,可以考虑通过建立主备流复制实现数据库的异机物理备份.本案例详细介绍了,在Windows环境下建 ...

  9. KingbaseES V8R6集群维护案例之--单实例数据迁移到集群案例

    案例说明: 生产环境是单实例,测试环境是集群,现需要将生产环境的数据迁移到集群中运行,本文档详细介绍了从单实例环境恢复数据到集群环境的操作步骤,可以作为生产环境迁移数据的参考. 适用版本: Kingb ...

  10. KingbaseES V8R6集群维护案例之---将securecmdd通讯改为ssh案例

    案例说明: 在KingbaseES V8R6的后期版本中,为了解决有的主机之间不允许root用户ssh登录的问题,使用了securecmdd作为集群部署分发和通讯的服务,有生产环境通过漏洞扫描,在88 ...

随机推荐

  1. Springboot+Bootstrap实现增删改查实战

    说明 最近有朋友问我有没有Springboot+Bootstrap实现增删改查的DEMO,当时没有,现在他来了! 实现效果 代码地址 https://gitee.com/indexman/bootst ...

  2. spring源码学习之设计模式

    目录 1.策略模式 2.观察者模式 3.装饰者模式 4.工厂模式 工厂方法模式 抽象工厂模式 工厂方法和抽象工厂的异同 5.单例模式 6.适配器模式与外观模式 适配器模式 外观模式 7.模板方法模式 ...

  3. Miniconda安装和使用

    Miniconda概述 Miniconda是什么? 要解释Miniconda是什么,先要弄清楚什么是Anaconda,它们之间的关系是什么? 而要知道Anaconda是什么,最先要明白的是搞清楚什么是 ...

  4. 如何将 IPhone 的文件导入 Linux

    如何将 IPhone 的文件导入 Linux 完全免费方案. 方法一: 使用 Koder 的 Local File Access 功能 这方法不需要在 Linux 端做任何配置. IPhone 端 安 ...

  5. Mac上LLAMA2大语言模型安装到使用

    LLAMA介绍 LLaMA是由Facebook的母公司Meta AI设计的一个新的大型语言模型.LLaMA拥有70亿到650亿个参数的模型集合,是目前最全面的语言模型之一. Llama是目前唯一一个可 ...

  6. Android系统瘦身

    文件格式: Windows常见的文件系统是FAT16.FAT32,NTFS,在Windows环境提供了分区格式转换工具,可以在DOC环境下 使用  Convert命令(Convert e:/fs:nt ...

  7. vue3,实战项目随心笔记

    本项目模仿bibi 网站,主要是做一个pc和手机端的应用案例,主要涉及支付,三方登陆,css原子,妹子ui,路由缓存,组件封装,tailwindcss,vueuse 等常见企业级术应用, 由于本项目是 ...

  8. git的 .gitignore 配置概述

    git的 .gitignore 配置概述 学习背景:自己在使用git时发现有时会上传很多无用的配置文件,或者在项目中已经包含一个本地的git仓库,导致上一级项目上传总是报错,所以学习采用gitigno ...

  9. Python面向对象之面向对象编程

    [一]什么是面向过程 [1]面向过程介绍 面向过程,核心在于 "过程" 二字 过程的终极奥义就是将程序 "流程化" 过程是 "流水线" ,用 ...

  10. python tcp socket 源码分享

    服务端的源码: import socketserver class Handler_TCPServer(socketserver.BaseRequestHandler): ""&q ...