案例环境:

操作系统:
  [root@node1 ~]# cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)

数据库:
test=# select version();
                                                      version                                                      
------------------------------------------------------------------------------
KingbaseES V008R006C003B0010 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit
(1 row)

集群架构:

一、查看当前集群节点状态信息

1、集群节点信息

[kingbase@node3 bin]$ ./repmgr cluster show
ID | Name   | Role   | Status   | Upstream | Location | Priority | Timeline | Connection string                                                                                                                                
----+---------+---------+-----------+----------+----------+----------+----
1 | node248 | primary | * running |         | default | 100     | 5       | host=192.168.7.248 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2 | node249 | standby |   running | node248 | default | 100     | 5       | host=192.168.7.249 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
3 | node243 | standby |   running | node248 | default | 100     | 5       | host=192.168.7.243 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

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    
------+----------+---------+------------------+---------------+-----------
3403 |   16384 | esrep   | node249         | 192.168.7.249 |                 |       14247 | 2021-03-01 12:03:37.651419+08 |             | streaming | 1/F9005BA0 | 1/F9005BA0 | 1/F9005BA0 | 1/F9005BA0 |           |           |           |             1 | quorum     | 2021-03-01 12:31:56.432910+08
3419 |   16384 | esrep   | node243         | 192.168.7.243 |                 |       34939 | 2021-03-01 12:03:43.876552+08 |             | streaming | 1/F9005BA0 | 1/F9005BA0 | 1/F9005BA0 | 1/F9005BA0 |           |           |           |             1 | quorum     | 2021-03-01 12:30:42.663663+08
(2 rows)

3、复制槽信息

test=# select * from sys_replication_slots;  
  slot_name   | plugin | slot_type | datoid | database | temporary | active | active_pid | xmin | catalog_xmin | restart_lsn | confirmed_flush_lsn
---------------+--------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+---------------------
repmgr_slot_2 |       | physical |       |         | f         | t     |       3403 |     |             | 1/F9005BA0 |
repmgr_slot_3 |       | physical |       |         | f         | t     |       3419 |     |             | 1/F9005BA0 |
(2 rows)

二、将standby节点unregister

1、unregister standby node

在要删除的Standby 节点执行:​
[kingbase@node3 bin]$ ./repmgr standby unregister;
INFO: connecting to local standby
INFO: connecting to primary database
NOTICE: unregistering node 3
INFO: try to drop slot "repmgr_slot_3" of node 3 on primary node
WARNING: replication slot "repmgr_slot_3" is still active on node 3
INFO: standby unregistration complete

2、查看集群节点信息

[kingbase@node3 bin]$ ./repmgr cluster show
ID | Name   | Role   | Status   | Upstream | Location | Priority | Timeline | Connection string                                                                                                                                
----+---------+---------+-----------+----------+----------+----------+----
1 | node248 | primary | * running |         | default | 100     | 5       | host=192.168.7.248 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2 | node249 | standby |   running | node248 | default | 100     | 5       | host=192.168.7.249 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

=== 从以上获知,集群节点信息已经没有unregister的节点信息===

三、停止本地集群服务删除复制槽

1、停止本地集群服务

[kingbase@node3 bin]$ ./sys_monitor.sh stoplocal
Service process "node_export" was killed at process 4928
Service process "postgres_ex" was killed at process 4929
2021-03-01 12:33:52 begin to stop repmgrd on "[localhost]".
2021-03-01 12:33:54 repmgrd on "[localhost]" stop success.
2021-03-01 12:33:54 begin to stop DB on "[localhost]".
waiting for server to shut down.... done
server stopped
2021-03-01 12:33:55 DB on "[localhost]" stop success.

2、关闭cron计划任务:

[kingbase@node2 bin]$ cat /etc/cron.d/KINGBASECRON
#*/1 * * * * kingbase . /etc/profile;/home/kingbase/cluster/R6HA/KHA/kingbase/bin/kbha -A daemon -f /home/kingbase/cluster/R6HA/KHA/kingbase/bin/../etc/repmgr.conf >> /home/kingbase/cluster/R6HA/KHA/kingbase/bin/../kbha.log 2>&1
#*/1 * * * * kingbase /home/kingbase/cluster/kha/db/bin/network_rewind.sh

3、停止hamgr进程:

[kingbase@node2 bin]$ ps -ef |grep repmgr
kingbase 7536 1 0 12:20 ? 00:01:12 /home/kingbase/cluster/R6HA/KHA/kingbase/bin/repmgrd -d -v -f /home/kingbase/cluster/R6HA/KHA/kingbase/bin/../etc/repmgr.conf
kingbase 7955 1 0 12:21 ? 00:00:01 /home/kingbase/cluster/R6HA/KHA/kingbase/bin/kbha -A daemon -f /home/kingbase/cluster/R6HA/KHA/kingbase/bin/../etc/repmgr.conf [kingbase@node2 bin]$ kill -2 7536 7955

4、停止export进程:

[kingbase@node2 bin]$ ps -ef |grep kingbase
kingbase 8190 1 0 12:21 ? 00:00:00 /home/kingbase/cluster/R6HA/KHA/kingbase/bin/../share/node_exporter
kingbase 8191 1 0 12:21 ? 00:00:00 /home/kingbase/cluster/R6HA/KHA/kingbase/bin/../share/postgres_exporter
......
[kingbase@node2 bin]$ kill -9 8190 8191

5、查看复制槽信息

test=# select * from sys_replication_slots;
slot_name | plugin | slot_type | datoid | database | temporary | active | active_pid | xmin | catalog_xmin | restart_lsn | confirmed_flush_lsn
---------------+--------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+---------------------
repmgr_slot_2 | | physical | | | f | t | 3403 | | | 1/F9007590 |
repmgr_slot_3 | | physical | | | f | f | | | | 1/F9007590 |
(2 rows)

6、删除复制槽

test=# select sys_drop_replication_slot('repmgr_slot_3');
sys_drop_replication_slot
--------------------------- (1 row)
test=# select * from sys_replication_slots;
slot_name | plugin | slot_type | datoid | database | temporary | active | active_pid | xmin | catalog_xmin | restart_lsn | confirmed_flush_lsn
---------------+--------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+---------------------
repmgr_slot_2 | | physical | | | f | t | 3403 | | | 1/F9007590 |
(1 row)

7、查看流复制信息

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
------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+--------------+------
3403 | 16384 | esrep | node249 | 192.168.7.249 | | 14247 | 2021-03-01 12:03:37.651419+08 | | streaming | 1/F9007590 | 1/F9007590 | 1/F9007590 | 1/F9007590 | | | | 1 | quorum | 2021-03-01 12:35:38.819940+08
(1 row)

四、重新启动集群服务测试

[kingbase@node1 bin]$ ./sys_monitor.sh restart
2021-03-01 12:37:43 Ready to stop all DB ...
Service process "node_export" was killed at process 4546
Service process "postgres_ex" was killed at process 4547
Service process "node_export" was killed at process 4242
Service process "postgres_ex" was killed at process 4243
2021-03-01 12:37:49 begin to stop repmgrd on "[192.168.7.248]".
2021-03-01 12:37:50 repmgrd on "[192.168.7.248]" stop success.
2021-03-01 12:37:50 begin to stop repmgrd on "[192.168.7.249]".
2021-03-01 12:37:51 repmgrd on "[192.168.7.249]" stop success.
2021-03-01 12:37:51 begin to stop DB on "[192.168.7.249]".
waiting for server to shut down.... done
server stopped
2021-03-01 12:37:52 DB on "[192.168.7.249]" stop success.
2021-03-01 12:37:52 begin to stop DB on "[192.168.7.248]".
waiting for server to shut down..... done
server stopped
2021-03-01 12:37:53 DB on "[192.168.7.248]" stop success.
2021-03-01 12:37:53 Done.
2021-03-01 12:37:53 Ready to start all DB ...
2021-03-01 12:37:53 begin to start DB on "[192.168.7.248]".
waiting for server to start.... done
server started
2021-03-01 12:37:55 execute to start DB on "[192.168.7.248]" success, connect to check it.
2021-03-01 12:37:56 DB on "[192.168.7.248]" start success.
2021-03-01 12:37:56 Try to ping trusted_servers on host 192.168.7.248 ...
2021-03-01 12:37:59 Try to ping trusted_servers on host 192.168.7.249 ...
2021-03-01 12:38:01 begin to start DB on "[192.168.7.249]".
waiting for server to start.... done
server started
2021-03-01 12:38:03 execute to start DB on "[192.168.7.249]" success, connect to check it.
2021-03-01 12:38:04 DB on "[192.168.7.249]" start success.
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+---------+---------+-----------+----------+----------+----------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------
1 | node248 | primary | * running | | default | 100 | 5 | host=192.168.7.248 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2 | node249 | standby | running | node248 | default | 100 | 5 | host=192.168.7.249 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2021-03-01 12:38:04 The primary DB is started.
2021-03-01 12:38:08 Success to load virtual ip [192.168.7.240/24] on primary host [192.168.7.248].
2021-03-01 12:38:08 Try to ping vip on host 192.168.7.248 ...
2021-03-01 12:38:11 Try to ping vip on host 192.168.7.249 ...
2021-03-01 12:38:13 begin to start repmgrd on "[192.168.7.248]".
[2021-03-01 12:38:14] [NOTICE] using provided configuration file "/home/kingbase/cluster/R6HA/KHA/kingbase/bin/../etc/repmgr.conf"
[2021-03-01 12:38:14] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/KHA/kingbase/hamgr.log" 2021-03-01 12:38:14 repmgrd on "[192.168.7.248]" start success.
2021-03-01 12:38:14 begin to start repmgrd on "[192.168.7.249]".
[2021-03-01 12:38:45] [NOTICE] using provided configuration file "/home/kingbase/cluster/R6HA/KHA/kingbase/bin/../etc/repmgr.conf"
[2021-03-01 12:38:45] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/KHA/kingbase/hamgr.log" 2021-03-01 12:38:15 repmgrd on "[192.168.7.249]" start success.
ID | Name | Role | Status | Upstream | repmgrd | PID | Paused? | Upstream last seen
----+---------+---------+-----------+----------+---------+-------+---------+--------------------
1 | node248 | primary | * running | | running | 14373 | no | n/a
2 | node249 | standby | running | node248 | running | 12219 | no | n/a
2021-03-01 12:38:23 Done.

=== 重新启动集群服务,启动后集群节点状态正常,standby节点删除成功===

KingbaseES R6 集群在线删除standby节点的更多相关文章

  1. KingbaseES R3集群在线删除数据节点案例

    案例说明: kingbaseES R3集群一主多从的架构,一般有两个节点是集群的管理节点,所有的节点都可以为数据节点:对于非管理节点的数据节点可以在线删除:但是对于管理节点,无法在线删除,如果删除管理 ...

  2. KingbaseES R6 集群repmgr.conf参数'recovery'测试案例(一)

    KingbaseES R6集群repmgr.conf参数'recovery'测试案例(一) 案例说明: 在KingbaseES R6集群中,主库节点出现宕机(如重启或关机),会产生主备切换,但是当主库 ...

  3. KingbaseES R6 集群 recovery 参数对切换的影响

    案例说明:在KingbaseES R6集群中,主库节点出现宕机(如重启或关机),会产生主备切换,但是当主库节点系统恢复正常后,如何对原主库节点进行处理,保证集群数据的一致性和安全,可以通过对repmg ...

  4. KingbaseES R6 集群通过备库clone在线添加新节点

    案例说明: KingbaseES R6集群可以通过图形化方式在线添加新节点,但是在添加新节点clone环节时,是从主库copy数据到新的节点,这样在生产环境,如果数据量大,将会对主库的网络I/O造成压 ...

  5. KingbaseES R6 集群修改data目录

    案例说明: 本案例是在部署完成KingbaseES R6集群后,由于业务的需求,集群需要修改data(数据存储)目录的测试.本案例分两种修改方式,第一种是离线修改data目录,即关闭整个集群后,修改数 ...

  6. KingbaseES R6 集群创建流复制只读副本库案例

    一.环境概述 [kingbase@node2 bin]$ ./ksql -U system test ksql (V8.0) Type "help" for help. test= ...

  7. KingbaseES R6 集群修改物理IP和VIP案例

    在用户的实际环境里,可能有时需要修改主机的IP,这就涉及到集群的配置修改.以下以例子的方式,介绍下KingbaseES R6集群如何修改IP. 一.案例测试环境 操作系统: [KINGBASE@nod ...

  8. KingbaseES R6 集群sys_monitor.sh change_password一键修改集群用户密码

    案例说明: kingbaseES R6集群用户密码修改,需要修改两处: 1)修改数据库用户密码(alter user): 2)修改.encpwd文件中用户密码: 可以通过sys_monitor.sh ...

  9. KingbaseES R6 集群启动‘incorrect command permissions for the virtual ip’故障案例

    案例说明: KingbaseES R6集群启动时,出现"incorrect command permissions for the virtual ip"故障,本案例介绍了如何分析 ...

随机推荐

  1. JQuery实现图片轮播无缝滚动

    图片轮播无缝滚动实例 实现效果展示预览: 思路: 1.设置当前索引curIndex,和前一张索引prevIndex.(curIndex为下一次要显示的图片索引,prevIndex为现在看见的图片) 2 ...

  2. 基于Vue2.x的前端架构,我们是这么做的

    通过Vue CLI可以方便的创建一个Vue项目,但是对于实际项目来说还是不够的,所以一般都会根据业务的情况来在其基础上添加一些共性能力,减少创建新项目时的一些重复操作,本着学习和分享的目的,本文会介绍 ...

  3. Unity3D学习笔记4——创建Mesh高级接口

    目录 1. 概述 2. 详论 3. 其他 4. 参考 1. 概述 在文章Unity3D学习笔记2--绘制一个带纹理的面中使用代码的方式创建了一个Mesh,不过这套接口在Unity中被称为简单接口.与其 ...

  4. NC200211 装备合成

    NC200211 装备合成 题目 题目描述 牛牛有 \({x}\) 件材料 \({a}\) 和 \({y}\) 件材料 \({b}\) ,用 \({2}\) 件材料 \({a}\) 和 \({3}\) ...

  5. 【ASP.NET Core】自定义的配置源

    本文的主题是简单说说如何实现 IConfigurationSource.IConfigurationProvider 接口来自定义一个配置信息的来源,后面老周给的示例是实现用 CSV 文件进行应用配置 ...

  6. DHCP 动态主机设置协议 分析

    在TCP/IP网络中,每个接口都需要一个IP地址.子网掩码和广播地址( IPv6中没有),简单来说就是需要网络配置信息.如果想访问外部网络可以通过DNS获取外部地址,再通过路由间接转发出去.但是在&q ...

  7. 时间模块之datatime模块、os模块、sys模块、json模块、json模块实操

    目录 一.模块的绝对导入和相对导入 二.包的概念 三.编程思想的转变 四.软件开发目录规范 五.常见的内置模块 一.时间模块之datatime模块 1.datetime.datetime.today( ...

  8. 我的sql没问题为什么还是这么慢|MySQL加锁规则

    前言 前阵子参与了字节跳动后端青训营,其中大项目编写涉及到数据持久化一般选择使用MySQL.由于时间原因,数据库使用我选择了无脑三板斧:1. 建立了索引加速查询.2. 关闭自动提交事务.3. 在需要确 ...

  9. 21条最佳实践,全面保障 GitHub 使用安全

    GitHub 是开发人员工作流程中不可或缺的一部分.无论你去哪个企业或开发团队,GitHub 都以某种形式存在.它被超过8300万开发人员,400万个组织和托管超过2亿个存储库使用.GitHub 是世 ...

  10. 电子表格分两级:Excel和WPS是一级,未来5年,75%的人将用二级

    你印象中的电子表格软件是哪些? 估计绝大多数人,都认为电子表格软件不就是Excel和WPS吗?顶多再加上永中office么,难道还有其他的电子表格软件不成? 没有错,excel和WPS,还有永中,确实 ...