KingbaseES V8R6 集群运维系列--sys_monitor.sh stop关闭集群分析
案例说明:
对于KingbaseES V8R6集群关闭整个集群通过执行‘sys_monitor.sh stop’命令完成,本案例解析了在执行‘sys_monitor.sh stop’后,数据库的关闭方式及数据库访问带来的影响。
KingbaseES停止数据库方式:(sys_ctl)
参数-m控制数据库停止模式 smart fast immediate:
smart 模式会等待活动的事务提交结束,并等待客户端主动断开连接之后关闭数据库
fast 模式则会回滚所有活动的事务,并强制断客户端的连接之后关闭数据库
immediate 模式立即终止所有服务器进程,当下一次数据库启动时它会首先进入恢复状态,一般不推荐使用。
适用版本:
KingbaseES V8R6
一、集群关闭案例测试
1、查看关闭数据库前控制文件
[kingbase@node101 bin]$ ./sys_controldata -D /data/kingbase/r6ha/data
sys_control version number: 1201
Catalog version number: 202112261
Database system identifier: 7080367334319169673
Database cluster state: in production
sys_control last modified: Fri 23 Dec 2022 11:01:58 AM CST
Latest checkpoint location: 4/F5000028
Latest checkpoint's REDO location: 4/F5000028
Latest checkpoint's REDO WAL file: 0000002300000004000000F5
Latest checkpoint's TimeLineID: 35
Latest checkpoint's PrevTimeLineID: 35
......
2、sys_monitor.sh关闭集群
[kingbase@node101 bin]$ ./sys_monitor.sh stop
.......
2022-12-23 11:04:53 begin to stop DB on "[192.168.1.102]".
waiting for server to shut down.... done
server stopped
2022-12-23 11:04:55 DB on "[192.168.1.102]" stop success.
2022-12-23 11:04:55 begin to stop DB on "[192.168.1.101]".
waiting for server to shut down............ done
server stopped
2022-12-23 11:05:06 DB on "[192.168.1.101]" stop success.
2022-12-23 11:05:06 Done.
3、查看主备库sys_log日志
#主库
2022-12-23 11:04:57.625 CST,,,10977,,63a51a26.2ae1,3,,2022-12-23 11:01:58 CST,,0,LOG,00000,"received fast shutdown request",,,,,,,,,""
2022-12-23 11:04:57.638 CST,,,10977,,63a51a26.2ae1,4,,2022-12-23 11:01:58 CST,,0,LOG,00000,"aborting any active transactions",,,,,,,,,""
2022-12-23 11:04:57.643 CST,,,10977,,63a51a26.2ae1,5,,2022-12-23 11:01:58 CST,,0,LOG,00000,"background worker ""kwr collector"" (PID 10988) exited with exit code 1",,,,,,,,,""
2022-12-23 11:04:57.643 CST,,,10977,,63a51a26.2ae1,6,,2022-12-23 11:01:58 CST,,0,LOG,00000,"background worker ""logical replication launcher"" (PID 10989) exited with exit code 1",,,,,,,,,""
2022-12-23 11:04:57.643 CST,"system","prod",12318,"192.168.1.102:58496",63a51a8e.301e,1,"INSERT",2022-12-23 11:03:42 CST,10/118,3274,FATAL,57P01,"terminating connection due to administrator command",,,,,,"insert into t1 select * from t1;",,,"kingbase_*&+_"
2022-12-23 11:04:58.876 CST,,,10980,,63a51a26.2ae4,2,,2022-12-23 11:01:58 CST,,0,LOG,00000,"checkpoint complete: wrote 15484 buffers (94.5%); 1 WAL file(s) added, 0 removed, 0 recycled; write=12.169 s, sync=0.426 s, total=13.518 s; sync files=6, longest=0.224 s, average=0.071 s; distance=694028 kB, estimate=694028 kB",,,,,,,,,""
2022-12-23 11:04:58.876 CST,,,10980,,63a51a26.2ae4,3,,2022-12-23 11:01:58 CST,,0,LOG,00000,"shutting down",,,,,,,,,""
2022-12-23 11:04:58.913 CST,,,10980,,63a51a26.2ae4,4,,2022-12-23 11:01:58 CST,,0,LOG,00000,"checkpoint starting: shutdown immediate",,,,,,,,,""
2022-12-23 11:04:59.494 CST,,,10980,,63a51a26.2ae4,5,,2022-12-23 11:01:58 CST,,0,LOG,00000,"checkpoint complete: wrote 4108 buffers (25.1%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.130 s, sync=0.301 s, total=0.615 s; sync files=2, longest=0.271 s, average=0.150 s; distance=223475 kB, estimate=646973 kB",,,,,,,,,""
2022-12-23 11:05:06.494 CST,,,10977,,63a51a26.2ae1,7,,2022-12-23 11:01:58 CST,,0,LOG,00000,"database system is shut down",,,,,,,,,""
#备库
2022-12-22 17:18:09.565 CST,,,1887,,63a4206f.75f,3,,2022-12-22 17:16:31 CST,,0,LOG,00000,"received fast shutdown request",,,,,,,,,""
2022-12-22 17:18:09.587 CST,,,1887,,63a4206f.75f,4,,2022-12-22 17:16:31 CST,,0,LOG,00000,"aborting any active transactions",,,,,,,,,""
2022-12-22 17:18:09.598 CST,,,1909,,63a42079.775,2,,2022-12-22 17:16:41 CST,,0,FATAL,57P01,"terminating walreceiver process due to administrator command",,,,,,,,,""
2022-12-22 17:18:09.599 CST,,,1906,,63a4206f.772,1,,2022-12-22 17:16:31 CST,,0,LOG,00000,"shutting down",,,,,,,,,""
2022-12-22 17:18:09.599 CST,,,1906,,63a4206f.772,2,,2022-12-22 17:16:31 CST,,0,LOG,00000,"restartpoint starting: shutdown immediate",,,,,,,,,""
2022-12-22 17:18:11.179 CST,,,1906,,63a4206f.772,3,,2022-12-22 17:16:31 CST,,0,LOG,00000,"restartpoint complete: wrote 44628 buffers (68.1%); 0 WAL file(s) added, 0 removed, 35 recycled; write=1.014 s, sync=0.458 s, total=1.580 s; sync files=6, longest=0.174 s, average=0.076 s; distance=573439 kB, estimate=573439 kB",,,,,,,,,""
2022-12-22 17:18:11.179 CST,,,1906,,63a4206f.772,4,,2022-12-22 17:16:31 CST,,0,LOG,00000,"recovery restart point at 1/CD000028","Last completed transaction was at log time 2022-12-22 17:17:06.024532+08.",,,,,,,,""
2022-12-22 17:18:11.241 CST,,,1887,,63a4206f.75f,5,,2022-12-22 17:16:31 CST,,0,LOG,00000,"database system is shut down",,,,,,,,,""
.......
如下图所示:
1)数据库收到“received fast shutdown request"的关库的请求。
2)数据库终止并回滚正在执行的事务,断开客户端的连接。
3)在关闭数据库之前执行了checkpoint。

4、客户端连接测试
#客户端连接数据库访问
[kingbase@node102 bin]$ ./ksql -h 192.168.1.101 -U system test
ksql (V8.0)
Type "help" for help.
test=# \c prod
You are now connected to database "prod" as user "system".
#查看t1表关库前数据
prod=# select count(*) from t1;
count
----------
16000000
(1 row)
#执行insert操作,在数据库关闭时,事务被回滚并且客户端连接被断开
prod=# insert into t1 select * from t1;
FATAL: terminating connection due to administrator command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
5、查看数据库服务关闭后控制文件
[kingbase@node101 bin]$ ./sys_controldata -D /data/kingbase/r6ha/data
sys_control version number: 1201
Catalog version number: 202112261
Database system identifier: 7080367334319169673
Database cluster state: shut down
sys_control last modified: Fri 23 Dec 2022 11:04:59 AM CST
Latest checkpoint location: 5/2D000028
Latest checkpoint's REDO location: 5/2D000028
Latest checkpoint's REDO WAL file: 00000023000000050000002D
Latest checkpoint's TimeLineID: 35
Latest checkpoint's PrevTimeLineID: 35
.......
---如上所示,在数据库被关闭后,产生了新的检查点。
6、数据库服务启动后,查询数据(事务被回滚)
[kingbase@node102 bin]$ ./ksql -h 192.168.1.101 -U system test
ksql (V8.0)
Type "help" for help.
test=# \c prod
You are now connected to database "prod" as user "system".
prod=# select count(*) from t1;
count
----------
16000000
(1 row)
二、sys_ctl fast stop关库测试
1、查看关库前检查点
sys_control version number: 1201
Catalog version number: 202202151
Database system identifier: 7100823070678531859
Database cluster state: in production
sys_control last modified: Thu 22 Dec 2022 05:30:20 PM CST
Latest checkpoint location: 0/242CFEF0
Latest checkpoint's REDO location: 0/242CFEF0
Latest checkpoint's REDO WAL file: 000000010000000000000024
Latest checkpoint's TimeLineID: 1
Latest checkpoint's PrevTimeLineID: 1
.......
2、sys_ctl fast stop 关闭数据库
[kingbase@node2 bin]$ ./sys_ctl -m fast stop -D /data/kingbase/v8r6_054/data
waiting for server to shut down.... done
server stopped
3、查看sys_log日志
[kingbase@node2 sys_log]$ tail -f kingbase-2022-12-22_165801.log
2022-12-22 16:58:01.351 CST [31158] LOG: database system was shut down at 2022-12-22 16:56:55 CST
2022-12-22 16:58:01.361 CST [31156] LOG: database system is ready to accept connections
2022-12-22 16:59:16.314 CST [31156] LOG: received fast shutdown request
2022-12-22 16:59:16.320 CST [31156] LOG: aborting any active transactions
2022-12-22 16:59:16.320 CST [31876] FATAL: terminating connection due to administrator command
2022-12-22 16:59:16.329 CST [31156] LOG: background worker "kwr collector" (PID 31166) exited with exit code 1
2022-12-22 16:59:16.329 CST [31156] LOG: background worker "logical replication launcher" (PID 31167) exited with exit code 1
2022-12-22 16:59:16.329 CST [31159] LOG: shutting down
2022-12-22 16:59:16.534 CST [31156] LOG: database system is shut down
如下图所示:
1)sys_ctl fast stop将中断事务的操作(回滚 rollback)。
2)终止客户端对数据库的连接访问。
3) shutdown数据库前没有触发checkpoint。

4、查看关库后检查点信息
[kingbase@node2 bin]$ ./sys_controldata -D /data/kingbase/v8r6_054/data/
sys_control version number: 1201
Catalog version number: 202202151
Database system identifier: 7100823070678531859
Database cluster state: shut down
sys_control last modified: Thu 22 Dec 2022 05:32:03 PM CST
Latest checkpoint location: 0/242E5298
Latest checkpoint's REDO location: 0/242E5298
Latest checkpoint's REDO WAL file: 000000010000000000000024
Latest checkpoint's TimeLineID: 1
Latest checkpoint's PrevTimeLineID: 1
........
--如上所示,在执行sys_ctl fast stop关闭数据库后,检查点没有发生变化,在sys_log日志
中没有记录触发检查点的日志信息。
如下图所示:不指定任何参数的sys_ctl关闭数据库(等同于‘fast stop’)

三、总结
在集群执行sys_monitor.sh stop和sys_ctl fast stop关闭数据库服务时:
1)都会调用’fast shutdown’方式关闭数据库。
2)数据库终止并回滚正在执行的事务,断开客户端的连接。
3)sys_monitor.sh stop执行时,数据库shutdown之前将会执行checkpoint,而sys_ctl fast stop不会执行checkpoint。
KingbaseES V8R6 集群运维系列--sys_monitor.sh stop关闭集群分析的更多相关文章
- KingbaseES V8R6集群管理运维案例之---repmgr standby switchover故障
案例说明: 在KingbaseES V8R6集群备库执行"repmgr standby switchover"时,切换失败,并且在执行过程中,伴随着"repmr stan ...
- KingbaseES V8R6集群运维案例之---repmgr standby promote应用案例
案例说明: 在容灾环境中,跨区域部署的异地备节点不会自主提升为主节点,在主节点发生故障或者人为需要切换时需要手动执行切换操作.若主节点已经失效,希望将异地备机提升为主节点. $bin/repmgr s ...
- KingbaseES V8R6集群维护案例之---停用集群node_export进程
案例说明: 在KingbaseES V8R6集群启动时,会启动node_exporter进程,此进程主要用于向kmonitor监控服务输出节点状态信息.在系统安全漏洞扫描中,提示出现以下安全漏洞: 对 ...
- KingbaseES V8R6集群维护案例之--单实例数据迁移到集群案例
案例说明: 生产环境是单实例,测试环境是集群,现需要将生产环境的数据迁移到集群中运行,本文档详细介绍了从单实例环境恢复数据到集群环境的操作步骤,可以作为生产环境迁移数据的参考. 适用版本: Kingb ...
- KingbaseES V8R6集群维护案例之--修改securecmdd工具服务端口
案例说明: 在一些生产环境,为了系统安全,不支持ssh互信,或限制root用户使用ssh登录,KingbaseES V8R6可以使用securecmdd工具支持主机之间的通讯.securecmdd工具 ...
- KingbaseES V8R6集群维护之--修改数据库服务端口案例
案例说明: 对于KingbaseES数据库单实例环境,只需要修改kingbase.conf文件的'port'参数即可,但是对于KingbaseES V8R6集群中涉及到多个配置文件的修改,并且在应 ...
- kingbaseES V8R6集群备份恢复案例之---备库作为repo主机执行物理备份
案例说明: 此案例是在KingbaseES V8R6集群环境下,当主库磁盘空间不足时,执行sys_rman备份,将集群的备库节点作为repo主机,执行备份,并将备份存储在备库的磁盘空间. 集群架构 ...
- KingbaseES V8R6集群外部备份案例
案例说明: 本案例采用sys_backup.sh执行物理备份,备份使用如下逻辑架构:集群采用CentOS 7系统,repo采用kylin V10 Server. 一主一备+外部备份 此场景为主备双机常 ...
- SQL Server自动化运维系列——关于邮件通知那点事(.Net开发人员的福利)
需求描述 在我们的生产环境中,大部分情况下需要有自己的运维体制,包括自己健康状态的检测等.如果发生异常,需要提前预警的,通知形式一般为发邮件告知. 邮件作为一种非常便利的预警实现方式,在及时性和易用性 ...
- SQL Server自动化运维系列——监控跑批Job运行状态(Power Shell)
需求描述 在我们的生产环境中,大部分情况下需要有自己的运维体制,包括自己健康状态的检测等.如果发生异常,需要提前预警的,通知形式一般为发邮件告知. 在上一篇文章中已经分析了SQL SERVER中关于邮 ...
随机推荐
- Swoole从入门到入土(5)——TCP服务器[异步任务]
无论对于B/S还是C/S,程序再怎么变,唯一不变的是用户不想等太久的躁动心情.所以服务端对于客户的请求,能有多快就多快.如果服务端需要执行很耗时的操作,就需要异步任务处理机制,保证当前的响应速度不受影 ...
- java: -source 1.5 中不支持 diamond 运算符
1.问题说明 平常在用idea编译spring boot多模块项目时,老是无端提示: Error:(107, 55) java: -source 1.5 中不支持 diamond 运算符 (请使用 - ...
- Spring Boot图书管理系统项目实战-11.检索图书
导航: pre:10.借还统计 next: 只挑重点的讲,具体的请看项目源码. 1.项目源码 需要源码的朋友,请捐赠任意金额后留下邮箱发送:) 2.页面设计 2.1 index.html <!D ...
- ORACLE SEQUENCE 详解
1. About Sequences(关于序列) 序列是数据库对象一种.多个用户可以通过序列生成连续的数字以此来实现主键字段的自动.唯一增长,并且一个序列可为多列.多表同时使用. 序列消除了串行 ...
- C++ 虚基类
虚基类(Virtual Base Class)在面向对象编程中的作用是解决多重继承中的菱形继承问题(Diamond Inheritance Problem)和共享基类问题(Shared Base Cl ...
- win32 - GDI+ 高斯模糊的使用
虽然标题中标有GDI+,但其实真正实施的时候并没有用到. 不过GDI+的相关文档有一些关于高斯模糊的api说明,见下面链接: Blur class (gdipluseffects.h) 使用Bl ...
- 【Azure 应用服务】[App Service For Linux(Function) ] Python ModuleNotFoundError: No module named 'MySQLdb'
问题描述 在使用Azure Function创建新的Python Function时,使用MySQLdb连接数据库时候出现 ModuleNotFoundError: No module named ' ...
- 【代码更新】SPI时序——AD数模数转换
[代码更新]SPI时序--AD数模数转换 AD芯片手册:https://www.ti.com.cn/cn/lit/ds/symlink/ads8558.pdf?ts=1709473143911& ...
- Android---TextView基础属性 + 跑马灯的三种方式
<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:layout_wid ...
- 如何避免MYSQL主从延迟带来的读写问题?
在MYSQL 部署架构选型上,许多公司都会用到主从读写分离的架构,如下是一个一主一从的架构,主库master负责写入,从库slave进行读取. 但是既然是读写分离,必然会面临这样一个问题,当在主库上进 ...