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中关于邮 ...
 
随机推荐
- Linux 下配置Oracle开机自动启动
			
一./etc/oratab说明 直接使用cat 查看这个文件: gg1:/home/oracle> cat /etc/oratab # # This file is used by ORACLE ...
 - Java并发编程实例--19.在一个锁中使用多个条件
			
一个锁可能关联了一个或多个条件.这些条件可以在Condition接口中声名. 使用这些条件的目的是去控制一个锁并且可以检查一个条件是true或false,如果为false,则暂停直到 另一个线程来唤醒 ...
 - 苹果AppleMacOs最新Sonoma系统本地训练和推理GPT-SoVITS模型实践
			
GPT-SoVITS是少有的可以在MacOs系统下训练和推理的TTS项目,虽然在效率上没有办法和N卡设备相提并论,但终归是开发者在MacOs系统构建基于M系列芯片AI生态的第一步. 环境搭建 首先要确 ...
 - 3分钟总览微软TPL并行编程库
			
有小伙伴问我每天忽悠的TPL是什么?☹️ 这次站位高一点,严肃讲一讲. 引言 俗话说,不想开飞机的程序员不是一名好爸爸:作为微软技术栈的老鸟,一直将代码整洁之道奉为经典, 优秀的程序员将优雅.高性能的 ...
 - MySQL写入SQL整个执行流程
			
innodb存储引擎中一条sql写入的详细流程 第0步:会先去看缓冲区有没有这条数据,如果有就不进行缓存,直接进入第三步. 第1步:会将要修改的那一行数据所在的一整页加载到缓冲池Buffe ...
 - 像闪电般击碎天空吧——快速轻量化模型之 SDXL-Lightning
			
SDXL-Lightning 是一个由 ByteDance(字节跳动) 开发的文本到图像的生成模型,其主要贡献在于其高速的生成能力和轻量化的设计. 模型的特点 快速生成:SDXL-Lightning ...
 - ubuntu18.04下nginx配合fastdfs使用的安装和配置
			
前期准备 1.安装依赖包 # 新装的ubuntu缺少gcc编译,需要先安装这个 sudo apt-get install build-essential 1.解压缩 libfastcommon-mas ...
 - 07-Redis系列之-双写一致性,缓存详解和优化点
			
双写一致性 双写一致性指的是当我们更新了数据库的数据之后redis中的数据也要同步去更新. redis和mysql数据同步方案 先更新缓存,再更新数据库(然并软...) 先更新数据库,再更新缓存(一般 ...
 - Jmeter json断言的使用
			
1 添加方式:取样器右键->添加->断言->JSON断言 作用:使用JSON表达式提取实际数据与预期进行比较 2首先我们来了解下断言组件的各个功能: Asset JSON Pat ...
 - Linux 系统编程从入门到进阶 学习指南
			
引言 大家好,我是小康 ,今天我们来学习一下 Linux 系统编程相关的知识.Linux 系统编程是连接高级语言和硬件的桥梁,它对深入理解计算机系统至关重要.无论你是打算构建高性能服务器还是开发嵌入式 ...