案例说明:

KingbaseES R6集群可以通过图形化方式在线添加新节点,但是在添加新节点clone环节时,是从主库copy数据到新的节点,这样在生产环境,如果数据量大,将会对主库的网络I/O造成压力。可以通过‘repmgr standby clone’指定从已有的备库进行克隆,减轻主库压力。

数据库版本:

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

集群架构:

[kingbase@node1 bin]$ cat /etc/hosts
......
192.168.7.248 node1 #主库节点
192.168.7.249 node2 #新增备库节点
192.168.7.243 node3 #备库节点 [kingbase@node1 bin]$ ./repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+---------+---------+-----------+----------+----------+----------+----------+---------------
1 | node243 | standby | running | node248 | default | 100 | 12 | 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 | node248 | primary | * running | | default | 100 | 12 | 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

一、新节点准备工作

=新节点的系统配置的准备,可以参考集群部署的要求。建立和集群其他节点相同的集群管理路径,并从其他节点上传相关的目录和文件(除了data目录)到新节点=

[kingbase@node2 R6C5R]$ pwd
/home/kingbase/cluster/R6C5/R6C5R
[kingbase@node2 R6C5R]$ ls -lh
total 145M
-rw-rw-r--. 1 kingbase kingbase 62 Mar 22 13:24 control.so
-rwxr-xr-x. 1 kingbase root 145M Mar 22 13:20 db.zip
drwxrwxr-x. 9 kingbase kingbase 99 Mar 22 13:25 kingbase
-rwxrwxrwx. 1 kingbase kingbase 3.4K Mar 22 13:24 license.dat
[kingbase@node2 R6C5R]$ cd kingbase/
[kingbase@node2 kingbase]$ ls -lh
total 32K
drwxrwxr-x. 2 kingbase kingbase 6 Mar 22 13:24 archive
drwxr-xr-x. 2 kingbase kingbase 4.0K Mar 22 13:24 bin
-rw-------. 1 kingbase kingbase 8.0K Mar 22 16:25 copy_file
drwxrwxr-x. 2 kingbase kingbase 101 Mar 22 13:25 etc
drwxrwxr-x. 5 kingbase kingbase 8.0K Nov 5 17:20 lib
drwxr-xr-x. 2 kingbase kingbase 37 Mar 22 13:25 log
drwxrwxr-x. 8 kingbase kingbase 4.0K Mar 22 13:25 share

二、在新节点执行在线clone

1、首先在主库上建立新备库的replication slot

test=# select sys_create_physical_replication_slot('repmgr_slot_3');
sys_create_physical_replication_slot
--------------------------------------
(repmgr_slot_3,)
(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_1 | | physical | | | f | t | 8229 | 68604 | | 0/44004000 |
repmgr_slot_3 | | physical | | | f | f | | | | 0/44003100 |
(2 rows)

2、在新节点执行clone预演

[kingbase@node2 bin]$ ./repmgr standby clone -h 192.168.7.243 -U esrep -d esrep --dry-run
NOTICE: destination directory "/home/kingbase/cluster/R6C5/R6C5R/kingbase/data" provided
INFO: connecting to source node
DETAIL: connection string is: host=192.168.7.243 user=esrep dbname=esrep
DETAIL: current installation size is 108 MB
INFO: "repmgr" extension is installed in database "esrep"
INFO: parameter "max_replication_slots" set to 32
INFO: parameter "max_wal_senders" set to 32
NOTICE: checking for available walsenders on the source node (2 required)
INFO: sufficient walsenders available on the source node
DETAIL: 2 required, 32 available
NOTICE: checking replication connections can be made to the source server (2 required)
INFO: required number of replication connections could be made to the source server
DETAIL: 2 replication connections required
NOTICE: standby will attach to upstream node 2
HINT: consider using the -c/--fast-checkpoint option
INFO: all prerequisites for "standby clone" are met

3、在新节点执行clone

[kingbase@node2 bin]$ ./repmgr standby clone -h 192.168.7.243 -U esrep -d esrep
# 注:-h ,指定已有的备库的ip地址。 NOTICE: destination directory "/home/kingbase/cluster/R6C5/R6C5R/kingbase/data" provided
INFO: connecting to source node
DETAIL: connection string is: host=192.168.7.243 user=esrep dbname=esrep
DETAIL: current installation size is 108 MB
NOTICE: checking for available walsenders on the source node (2 required)
NOTICE: checking replication connections can be made to the source server (2 required)
INFO: creating directory "/home/kingbase/cluster/R6C5/R6C5R/kingbase/data"...
NOTICE: starting backup (using sys_basebackup)...
HINT: this may take some time; consider using the -c/--fast-checkpoint option
INFO: executing:
/home/kingbase/cluster/R6C5/R6C5R/kingbase/bin/sys_basebackup -l "repmgr base backup" -D /home/kingbase/cluster/R6C5/R6C5R/kingbase/data -h 192.168.7.243 -p 54321 -U esrep -X stream -S repmgr_slot_3
NOTICE: standby clone (using sys_basebackup) complete
NOTICE: you can now start your Kingbase server
HINT: for example: sys_ctl -D /home/kingbase/cluster/R6C5/R6C5R/kingbase/data start
HINT: after starting the server, you need to register this standby with "repmgr standby register"

4、启动新节点数据库服务

[kingbase@node2 bin]$ ./sys_ctl -D /home/kingbase/cluster/R6C5/R6C5R/kingbase/data start
waiting for server to start....2022-03-22 12:14:15.746 CST [3450] LOG: sysaudit extension initialized
.......
server started

5、注册新备库到集群

[kingbase@node2 bin]$ ./repmgr standby register --force
INFO: connecting to local node "node249" (ID: 3)
INFO: connecting to primary database
WARNING: --upstream-node-id not supplied, assuming upstream node is primary (node ID 2)
INFO: standby registration complete
NOTICE: standby node "node249" (ID: 3) successfully registered

6、查看集群节点状态

[kingbase@node2 bin]$ ./repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+---------+---------+-----------+----------+----------+----------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------
1 | node243 | standby | running | node248 | default | 100 | 12 | 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 | node248 | primary | * running | | default | 100 | 12 | 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
3 | node249 | standby | running | node248 | default | 100 | 12 | 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

=由以上获知,新的备库节点添加成功。=

三、备库clone错误案例

=在从指定备库clone前,如果未创建replication slot 出现以下错误=

错误日志:

[kingbase@node2 bin]$ ./repmgr standby clone -h 192.168.7.243 -U esrep -d esrep
NOTICE: destination directory "/home/kingbase/cluster/R6C5/R6C5R/kingbase/data" provided
INFO: connecting to source node
DETAIL: connection string is: host=192.168.7.243 user=esrep dbname=esrep
DETAIL: current installation size is 108 MB
NOTICE: checking for available walsenders on the source node (2 required)
NOTICE: checking replication connections can be made to the source server (2 required)
INFO: creating directory "/home/kingbase/cluster/R6C5/R6C5R/kingbase/data"...
NOTICE: starting backup (using sys_basebackup)...
HINT: this may take some time; consider using the -c/--fast-checkpoint option
INFO: executing:
/home/kingbase/cluster/R6C5/R6C5R/kingbase/bin/sys_basebackup -l "repmgr base backup" -D /home/kingbase/cluster/R6C5/R6C5R/kingbase/data -h 192.168.7.243 -p 54321 -U esrep -X stream -S repmgr_slot_3
NOTICE: creating replication slot "repmgr_slot_3" on upstream node 2
ERROR: drop_replication_slot(): unable to drop replication slot "repmgr_slot_3"
DETAIL:
ERROR: replication slot "repmgr_slot_3" does not exist DETAIL: query text is:
SELECT pg_catalog.pg_drop_replication_slot('repmgr_slot_3')
ERROR: unable to delete replication slot "repmgr_slot_3" on source node
NOTICE: standby clone (using sys_basebackup) complete
NOTICE: you can now start your Kingbase server
HINT: for example: sys_ctl -D /home/kingbase/cluster/R6C5/R6C5R/kingbase/data start
HINT: after starting the server, you need to register this standby with "repmgr standby register"

KingbaseES R6 集群通过备库clone在线添加新节点的更多相关文章

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

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

  2. KingbaseES R3 集群删除test库导致主备无法切换问题

    案例说明: 在KingbaseES R3集群中,kingbasecluster进程会通过test库访问,连接后台数据库服务测试:如果删除test数据库,导致后台数据库服务访问失败,在集群主备切换时,无 ...

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

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

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

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

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

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

  6. KingbaseES R6 集群修改data目录

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

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

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

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

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

  9. KingbaseES R6 集群物理copy方式手工添加新备库节点

    案例说明: 对于主库数据量比较大的环境,在添加新节点是可以采用在线clone方式创建新的备库节点,也可以在离线的状态下,直接拷贝其中一个备库的所有集群相关目录来创建新的备库节点.本案例介绍了通过离线物 ...

随机推荐

  1. UiPath条件判断活动If的介绍和使用

    if的介绍 if语句是指编程语言(包括c语言.C#.Python.Java.汇编语言等)中用来判定所给定的条件是否满足,根据判定的结果(真或假)决定执行给出的两种操作之一. if在UiPath中的使用 ...

  2. Jenkins+Svn+Docker搭建持续集成环境 自动部署

    一.准备工作: 两台服务器:192.168.206.212,192.168.206.213 自己新建一个maven项目 其中两台机子做下面的软件配置 212机子: 安装expect并配置: 安装jen ...

  3. Windows下maven配置环境变量

    右键 "计算机",选择 "属性",之后点击 "高级系统设置",点击"环境变量",来设置环境变量,有以下系统变量需要配置: ...

  4. 6. RDD综合练习:更丰富的操作

    集合运算练习 union(), intersection(),subtract(), cartesian() 内连接与外连接 join(), leftOuterJoin(), rightOuterJo ...

  5. Tapdata 实时数据融合平台解决方案(四):技术选型

    作者介绍:TJ,唐建法,Tapdata 钛铂数据CTO,MongoDB中文社区主席,原MongoDB大中华区首席架构师,极客时间MongoDB视频课程讲师. 常见搭建数据中台的技术产品 数据中台包括: ...

  6. 项目git commit时卡主不良代码:husky让Git检查代码规范化工作

    看完 <前端规范之Git工作流规范(Husky + Commitlint + Lint-staged) https://www.cnblogs.com/Yellow-ice/p/15349873 ...

  7. 「Python实用秘技09」更好用的函数运算缓存

    本文完整示例代码及文件已上传至我的Github仓库https://github.com/CNFeffery/PythonPracticalSkills 这是我的系列文章「Python实用秘技」的第9期 ...

  8. 从零开始Blazor Server(1)--项目搭建

    项目介绍 本次项目准备搭建一个使用Furion框架,Blazor的UI使用BootstrapBlazor.数据库ORM使用Freesql的后台管理系统. 目前的规划是实现简单的注册,登录.增加管理员跟 ...

  9. 彻底弄清楚session,cookie,sessionStorage,localStorage的区别及应用场景(面试向)

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_94 客户端状态保持是一个老生常谈的问题了,归根结底追踪浏览器的用户身份及其相关数据无非就是以下四种方式:session,cooki ...

  10. 面试突击71:GET 和 POST 有什么区别?

    GET 和 POST 是 HTTP 请求中最常用的两种请求方法,在日常开发的 RESTful 接口中,都能看到它们的身影.而它们之间的区别,也是一道常见且经典的面试题,所以我们本文就来详细的聊聊. H ...