案例说明:

在KingbaseES V8R3集群,network_rewind.sh用于当节点数据库服务down时,实现数据库服务的自动恢复功能。在network_rewind.sh执行时,会对数据库的存储(data)所在的磁盘进行R/W的检查,默认如果读写检查失败,将会关闭数据库;在生产环境,磁盘I/O压力较大的情况下,可能会触发误判,导致数据库关闭,影响正常的应用。可以通过参数调整,在检测失败的情况下,不关闭数据库服务。

适用版本:

KingbaseES V8R3

一、集群架构

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 | primary | 0 | false | 0
1 | 192.168.1.102 | 54321 | up | 0.500000 | standby | 0 | true | 0
(2 rows)

二、测试默认磁盘检测功能

1、模拟磁盘检测故障

[root@node102 db]# pwd
/home/kingbase/cluster/HAR3/db
[root@node102 db]# ls -lhd data
drwx------ 20 kingbase kingbase 4.0K Mar 17 10:20 data
[root@node102 db]# chown root.root data
[root@node102 db]# chmod 700 data
[root@node102 db]# ls -lhd data
drwx------ 20 root root 4.0K Mar 17 10:20 data ---如上所示,对于数据存储data目录,数据库用户kingbase无读写权限。

2、查看节点recovery.log

Tips:

默认在KingbaseES V8R3集群,每过一分钟,crond调用network_rewind.sh脚本检测节点数据库状态,可以通过recovery.log获取详细执行信息。

2023-03-17 10:21:01 recover beging...
my pid is 9836,officially began to perform recovery
2023-03-17 10:21:01 check read/write on mount point
2023-03-17 10:21:01 check read/write on mount point (1 / 6).
2023-03-17 10:21:01 stat the directory of the mount point "/home/kingbase/cluster/HAR3/db/data" ...
ls: cannot open directory /home/kingbase/cluster/HAR3/db/data: Permission denied
could not stat the mount point "/home/kingbase/cluster/HAR3/db/data", please check it
could not execute "ls /home/kingbase/cluster/HAR3/db/data".
2023-03-17 10:21:01 failed to check read/write on mount point (1 / 6).
2023-03-17 10:21:11 check read/write on mount point (2 / 6).
2023-03-17 10:21:11 stat the directory of the mount point "/home/kingbase/cluster/HAR3/db/data" ...
ls: cannot open directory /home/kingbase/cluster/HAR3/db/data: Permission denied
could not stat the mount point "/home/kingbase/cluster/HAR3/db/data", please check it
could not execute "ls /home/kingbase/cluster/HAR3/db/data".
2023-03-17 10:21:11 failed to check read/write on mount point (2 / 6).
2023-03-17 10:21:21 check read/write on mount point (3 / 6).
2023-03-17 10:21:21 stat the directory of the mount point "/home/kingbase/cluster/HAR3/db/data" ...
ls: cannot open directory /home/kingbase/cluster/HAR3/db/data: Permission denied
could not stat the mount point "/home/kingbase/cluster/HAR3/db/data", please check it
could not execute "ls /home/kingbase/cluster/HAR3/db/data".
2023-03-17 10:21:21 failed to check read/write on mount point (3 / 6).
2023-03-17 10:21:31 check read/write on mount point (4 / 6).
2023-03-17 10:21:31 stat the directory of the mount point "/home/kingbase/cluster/HAR3/db/data" ...
ls: cannot open directory /home/kingbase/cluster/HAR3/db/data: Permission denied
could not stat the mount point "/home/kingbase/cluster/HAR3/db/data", please check it
could not execute "ls /home/kingbase/cluster/HAR3/db/data".
2023-03-17 10:21:31 failed to check read/write on mount point (4 / 6).
2023-03-17 10:21:41 check read/write on mount point (5 / 6).
2023-03-17 10:21:41 stat the directory of the mount point "/home/kingbase/cluster/HAR3/db/data" ...
ls: cannot open directory /home/kingbase/cluster/HAR3/db/data: Permission denied
could not stat the mount point "/home/kingbase/cluster/HAR3/db/data", please check it
could not execute "ls /home/kingbase/cluster/HAR3/db/data".
2023-03-17 10:21:41 failed to check read/write on mount point (5 / 6).
2023-03-17 10:21:51 check read/write on mount point (6 / 6).
2023-03-17 10:21:51 stat the directory of the mount point "/home/kingbase/cluster/HAR3/db/data" ...
ls: cannot open directory /home/kingbase/cluster/HAR3/db/data: Permission denied
could not stat the mount point "/home/kingbase/cluster/HAR3/db/data", please check it
could not execute "ls /home/kingbase/cluster/HAR3/db/data".
2023-03-17 10:21:51 failed to check read/write on mount point (6 / 6).
2023-03-17 10:22:01 execute check_mount_point() failed, maybe the disk is error
2023-03-17 10:22:01 USE_CHECK_DISK = on, will exit with stop db.
exit with error and stop db.....
sys_ctl: could not open PID file "/home/kingbase/cluster/HAR3/db/data/kingbase.pid": Permission denied
2023-03-17 10:22:01 now will del vip [192.168.1.204/24]
I'm already recovery now pid[9836], return nothing to do,will exit script will success
now, there is no 192.168.1.204/24 on my DEV
......
---如上所示,对“/home/kingbase/cluster/HAR3/db/data”目录读写执行检测。

如下图所示:磁盘检测失败关闭数据库服务

三、调整磁盘检测功能

Tips:

默认" if failed in check_mount_point(), should stop the database? default is on, do stop db",参数
USE_CHECK_DISK=1(默认),将关闭数据库服务;USE_CHECK_DISK=0,不关闭数据库服务。

1、配置磁盘检测参数

[root@node102 db]# cat etc/HAmodule.conf |grep -i disk
USE_CHECK_DISK=0 ---在所有节点HAmodule.conf增加此参数配置(默认配置文件无此参数)。

2、模拟磁盘检测故障

[root@node102 db]# pwd
/home/kingbase/cluster/HAR3/db
[root@node102 db]# ls -lhd data
drwx------ 20 kingbase kingbase 4.0K Mar 17 10:20 data [root@node102 db]# chown root.root data
[root@node102 db]# chmod 700 data
[root@node102 db]# ls -lhd data
drwx------ 20 root root 4.0K Mar 17 10:20 data ---如上所示,对于数据存储data目录,数据库用户kingbase无读写权限。

3、查看节点recovery.log

---------------------------------------------------------------------
2023-03-17 10:33:01 recover beging...
my pid is 16274,officially began to perform recovery
2023-03-17 10:33:01 check read/write on mount point
2023-03-17 10:33:01 check read/write on mount point (1 / 6).
2023-03-17 10:33:01 stat the directory of the mount point "/home/kingbase/cluster/HAR3/db/data" ...
.......
2023-03-17 10:33:51 check read/write on mount point (6 / 6).
2023-03-17 10:33:51 stat the directory of the mount point "/home/kingbase/cluster/HAR3/db/data" ...
ls: cannot open directory /home/kingbase/cluster/HAR3/db/data: Permission denied
could not stat the mount point "/home/kingbase/cluster/HAR3/db/data", please check it
could not execute "ls /home/kingbase/cluster/HAR3/db/data".
2023-03-17 10:33:51 failed to check read/write on mount point (6 / 6).
2023-03-17 10:34:01 execute check_mount_point() failed, maybe the disk is error
2023-03-17 10:34:01 USE_CHECK_DISK = off, do nothing.
2023-03-17 10:34:01 check read/write on mount point ... ok
2023-03-17 10:34:01 check if the network is ok
I'm already recovery now pid[16274], return nothing to do,will exit script will success
ping trust ip 192.168.1.1 success ping times :[3], success times:[2]
determine if i am master or standby
........

如下图所示:磁盘检测失败,但没有触发数据库关闭:

四、总结

磁盘检测功能有助于集群数据库数据的安全,但是在有的生产环境,磁盘I/O压力大情况下,有可能引起误判,可以根据生产应用环境,调整"USE_CHECK_DISK"参数,即保证集群的高可用性,又保证数据的安全。

KingbaseES V8R3 集群运维系列之 -- network_rewind.sh磁盘检测功能详解的更多相关文章

  1. KingbaseES V8R3集群运维案例之---kingbase_monitor.sh启动”two master“案例

    案例说明: KingbaseES V8R3集群,执行kingbase_monitor.sh启动集群,出现"two master"节点的故障,启动集群失败:通过手工sys_ctl启动 ...

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

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

  3. KingbaseES V8R3集群运维案例之---cluster.log ERROR: md5 authentication failed

    案例说明: 在KingbaseES V8R3集群的cluster.log日志中,经常会出现"ERROR: md5 authentication failed:DETAIL: password ...

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

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

  5. KingbaseES V8R3集群维护案例之---pcp_node_refresh应用

    案例说明: 在一次KingbaseES V8R3集群切换分析中,运维人员执行了pcp_node_refresh,导致集群发生了failover的切换.此文档对pcp_node_refresh工具做了应 ...

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

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

  7. KingbaseES V8R3集群管理和维护案例之---failover切换wal日志变化分析

    ​ 案例说明: 本案例通过对KingbaseES V8R3集群failover切换过程进行观察,分析了主备库切换后wal日志的变化,对应用者了解KingbaseES V8R3(R6) failover ...

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

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

  9. Memcached集群/分布式/高可用 及 Magent缓存代理搭建过程 详解

    当网站访问量达到一定时,如何做Memcached集群,又如何高可用,是接下来要讨论的问题. 有这么一段文字来描述“Memcached集群” Memcached如何处理容错的? 不处理!:) 在memc ...

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

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

随机推荐

  1. python课本学习-第二章

    chapter 2 编程基础 一.基本语法 1.注释 python注释以\("#"\)开始 多行注释使用三个单引号/双引号作为开始和结束标志 2.标识符与关键字 python命名时 ...

  2. win32 - 创建带有标准阴影的无边框窗口

    这个框框好像删不掉,就先放这边吧...   #define WIN32_LEAN_AND_MEAN #include <unknwn.h> #include <windows.h&g ...

  3. (微服务)服务治理:熔断器介绍以及hystrix-go的使用

    一.什么是熔断器 要理解熔断器,可以先看看电路中使用的保险丝. 保险丝(fuse)也被称为电流保险丝,IEC127 标准将它定义为"熔断体(fuse-link)".保险丝是一种保证 ...

  4. mysql-数据类型,类型约束,联合唯一约束,表与表之间的关系,存储引擎---day36

    # ### char varchar(补充) char 字符长度 255个 varchar 字符长度 21845个 # ### part1 数据类型 -时间 date YYYY-MM-DD 年月日(结 ...

  5. python定义类模块之attr

    # attr可以简单理解为namedtuple的增强版 import attr @attr.s class Point(object): x = attr.ib(default=1) # 定义默认参数 ...

  6. 2.Go 的指针

    Go的指针 1. 变量内存地址 var age = 18 // & + 变量 = 变量内存地址 fmt.Println("age:",&age) 2. 指针变量 / ...

  7. 数据结构(三):舞伴配对问题(C++,队列)

    好家伙, 题目如下: 1.舞伴配对问题:假设在周末舞会上,男士们和女士们进入舞厅时,各自排成一队.跳舞开始时,依次从男队和女队的队头上各出一人配成舞伴. 2.若两队初始人数不相同,则较长的那一队中未配 ...

  8. 【Azure Developer】PHP网站使用AAD授权登录的参考示例

    问题描述 如果有个PHP网站,需要使用AAD授权登录,有没有PHP代码实例 可供参考呢? 参考代码 参考一篇博文(Single sign-on with Azure AD in PHP),学习使用SS ...

  9. Java 线程安全问题 使用同步机制讲单例模式中的懒汉式改写为线程安全的

    1 package bytezero.deadlock; 2 3 /** 4 * 使用同步机制讲单例模式中的懒汉式改写为线程安全的 5 * 6 * 7 * 8 * 9 * @author Byteze ...

  10. MYSQL中正则表达式检索数据库

    1.MySQL中使用通配符检索数据库,之外还可以使用正则表达式来检索数据. 使用通配符   '_'  和   '%'的区别如下,   使用通配符的技巧:一般的来说 通配符可以处理数据,但是消耗内存较大 ...