KingbaseES集群运维案例之---集群架构拆分为单实例操作

案例说明:
生产环境,将原KingbaseES V8R6集群架构,拆分为单实例环境,以下为具体的操作步骤。

适用版本:
KingbaseES V8R6

一、集群节点信息

1、集群节点状态

[kingbase@node202 bin]$ ./repmgr cluster show
.......
 ID | Name  | Role    | Status    | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string                                                                                                         
----+-------+---------+-----------+----------+----------+----------+----------+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 1  | node1 | primary | * running |          | default  | 100      | 41       |         | host=192.168.1.201 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3 tcp_user_timeout=9000
 2  | node2 | standby |   running | node1    | default  | 100      | 41       | 0 bytes | host=192.168.1.202 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3 tcp_user_timeout=9000

2、流复制状态

test=# select * from sys_stat_replication;
 pid  | usesysid | usename | application_name |  client_addr  | client_hostname | client_port |         ba
ckend_start         | backend_xmin |   state   | sent_lsn | write_lsn  | flush_lsn  | replay_lsn | write_l
ag | flush_lag | replay_lag | sync_priority | sync_state |          reply_time
------+----------+---------+------------------+---------------+-----------------+-------------+-----------
--------------------+--------------+-----------+----------+------------+------------+------------+--------
---+-----------+------------+---------------+------------+-------------------------------
 2385 |    16384 | esrep   | node2            | 192.168.1.202 |                 |       58911 | 2024-06-17
 14:28:36.615195+08 |              | streaming |          | 2/81000EC8 | 2/81000EC8 | 2/81000EC8 |
   |           |            |             1 | sync       | 2024-06-17 14:29:13.826223+08
(1 row)

二、拆分集群节点管理

1、暂停主备节点repmgrd服务

[kingbase@node201 bin]$ ./repmgr service pause

[kingbase@node201 bin]$ ./repmgr service status
 ID | Name  | Role    | Status    | Upstream | repmgrd | PID  | Paused? | Upstream last seen
----+-------+---------+-----------+----------+---------+------+---------+--------------------
 1  | node1 | primary | * running |          | running | 2334 | yes     | n/a
 2  | node2 | standby |   running | node1    | running | 2618 | yes     | 0 second(s) ago

2、注销备库节点注册

[kingbase@node202 bin]$ ./repmgr standby unregister

[kingbase@node202 bin]$ ./repmgr cluster show
 ID | Name  | Role    | Status    | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string                                                                                                         
----+-------+---------+-----------+----------+----------+----------+----------+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 1  | node1 | primary | * running |          | default  | 100      | 41       |         | host=192.168.1.201 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3 tcp_user_timeout=9000

3、停止备库节点数据库服务
[kingbase@node202 bin]$ ./sys_ctl stop -D ../data

删除备库standby.signal文件:

[kingbase@node202 data]$ ls -lh standby.signal
-rw------- 1 kingbase kingbase 20 Jun 12 15:33 standby.signal
[kingbase@node202 data]$ mv standby.signal standby.signal.bk

4、注销主库节点注册

[kingbase@node201 bin]$ ./repmgr primary unregister --force

[kingbase@node201 bin]$ ./repmgr cluster show
[ERROR] no node records were found
[HINT] ensure at least one node is registered

三、拆分流复制架构

1、查看复制槽信息

test=# select * from sys_replication_slots;
   slot_name   | plugin | slot_type | datoid | database | temporary | active | active_pid | xmin  | catalo
g_xmin | restart_lsn | confirmed_flush_lsn
---------------+--------+-----------+--------+----------+-----------+--------+------------+-------+-------
-------+-------------+---------------------
 repmgr_slot_2 |        | physical  |        |          | f         | f      |            | 15499 |
       | 2/81001C48  |
(1 row)

2、删除备库复制槽(需先关闭备库数据库服务)

test=# select sys_drop_replication_slot('repmgr_slot_2');
 sys_drop_replication_slot('repmgr_slot_2')
--------------------------------------------

(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
-----------+--------+-----------+--------+----------+-----------+--------+------------+------+------------
--+-------------+---------------------
(0 rows)

四、修改流复制配置
1、修改synchronous_commit参数(主备库)

# 可以修改kingbase.conf或kingbase.auto.conf、es_rep.conf配置:
test=# show synchronous_commit ;
 synchronous_commit
--------------------
 remote_apply
(1 row)

test=# alter system set synchronous_commit=on;
ALTER SYSTEM
test=# select sys_reload_conf();
 sys_reload_conf()
-------------------
 t
(1 row)

test=# show synchronous_commit ;
 synchronous_commit
--------------------
 on
(1 row)

2、删除或注释集群连接串和复制槽配置

[kingbase@node202 data]$ cat kingbase.auto.conf
# Do not edit this file manually!
# It will be overwritten by the ALTER SYSTEM command.
.......
primary_conninfo = 'user=esrep connect_timeout=10 host=192.168.1.201 port=54321 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3 tcp_user_timeout=9000 application_name=node2'
primary_slot_name = 'repmgr_slot_2'

3、禁用kbha进程的启动项

[root@node201 ~]# cat /etc/cron.d/KINGBASECRON

#*/1 * * * * kingbase . /etc/profile;/home/kingbase/cluster/R6/R6HA/kingbase/bin/kbha -A daemon -f /home/kingbase/cluster/R6/R6HA/kingbase/bin/../etc/repmgr.conf

五、总结
完成以上操作步骤后,将原集群架构拆分为两个独立的单实例环境(支持RW),对于原集群管理的目录及配置,可以清理或保存,并不影响实例的正常运行。

posted @   天涯客1224  阅读(47)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
历史上的今天:
2021-06-17 kingbaseES V8R6集群运维案例之---“双主”故障解决案例
点击右上角即可分享
微信分享提示