kingbase V8R6 流复制配置

说明:r6安装配置流复制和r3有些区别,以下主要介绍r6流复制的安装配置

主节点:192.168.120.118

备节点:192168.120.112

两个节点保证都安装了r6的数据,下面开始配置

1、开启流复制所需配置

cat kingbase.conf

wal_level = replica

archive_mode = on

archive_command=''

synchronous_commit = remote_apply

archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'

synchronous_standby_names = 'ANY 1(node1)'

control_file_copy = '/home/kingbase/cluster/kingbase/copy_file'

2、主库上创建复制槽

test=# select  sys_create_physical_replication_slot('slot_node1');

test=# select  sys_create_physical_replication_slot('slot_node2');

3、主库配置访问权限

vi sys_hba.conf

host    replication    all            0.0.0.0/0              scram-sha-256

4、备库从主库clone数据

./sys_basebackup -h

192.168.120.118  -U SYSTEM  -D /data/kingbas/data -P -v -X stream -F p -S slot_node1

5、在备库上创建备库标识文件

cd /home/kingbase/data

touch standby.signal

6、配置备库连接主库字符串文件

[root@node1 V8R6_clusterdata]# cat kingbase.auto.conf

primary_conninfo = 'host=192.168.120.112 user=system password=123456  port=6666 application_name=node1 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3'  primary_slot_name = 'slot_node1'

#流复制中的配置:参考

primary_conninfo = 'user=esrep connect_timeout=10 host=192.168.120.112 port=54321 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3 application_name=node2'

primary_slot_name = 'repmgr_slot_2'

2023-08-02 16:13:34] [INFO] [thread pid:116725] do_nodes_recovery thread begin. The pthread_t tid is 0x7f7483d50700

[2023-08-02 16:13:35] [NOTICE] [thread pid:116725] node (ID: 1; host: "192.168.120.112") is not attached, ready to auto-recovery

[2023-08-02 16:13:35] [NOTICE] [thread pid:116725] Now, the primary host ip: 192.168.120.113

[2023-08-02 16:13:35] [INFO] [thread pid:116725] ES connection to host "192.168.120.112" succeeded, ready to do auto-recovery

[2023-08-02 16:13:38] [NOTICE] kbha: node (ID: 1) is running as standby, stop it and do rejoin.

[2023-08-02 16:13:43] [INFO] unlink file /tmp/.s.KINGBASE.54326.lock

[2023-08-02 16:13:43] [NOTICE] executing repmgr command"/home/kingbase/cluster_v8r6/kingbase/bin/repmgr --dbname="host=192.168.120.113 dbname=esrep user=esrep port=54326" node rejoin --force-rewind --upstream-node-id 2"

NOTICE: rejoin target is node "node2" (ID: 2)

NOTICE: sys_rewind execution required for this node to attach to rejoin target node 2

DETAIL: rejoin target server's timeline 2 forked off current database system timeline 1 before current recovery point 0/40000A0

NOTICE: executing sys_rewind

DETAIL: sys_rewind command is "/home/kingbase/cluster_v8r6/kingbase/bin/sys_rewind -D '/home/kingbase/cluster_v8r6/kingbase/data' --source-server='host=192.168.120.113 user=esrep dbname=esrep port=54326 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3'"

sys_rewind: servers diverged at WAL location 0/3004048 on timeline 1

sys_rewind: rewinding from last common checkpoint at 0/2000088 on timeline 1

sys_rewind: find last common checkpoint start time from 2023-08-02 16:13:43.329898 CST to 2023-08-02 16:13:43.368738 CST, in "0.038840" seconds.

sys_rewind: update the control file: minRecoveryPoint is '0/3014B80', minRecoveryPointTLI is '2', and database state is 'in archive recovery'

sys_rewind: rewind start wal location 0/2000028 (file 000000010000000000000002), end wal location 0/3014B80 (file 000000020000000000000003). time from 2023-08-02 16:13:43.329898 CST to 2023-08-02 16:13:44.294702 CST, in "0.964804" seconds.

sys_rewind: Done!

NOTICE: 0 files copied to /home/kingbase/cluster_v8r6/kingbase/data

INFO: creating replication slot as user "esrep"

NOTICE: setting node 1's upstream to node 2

WARNING: unable to ping "host=192.168.120.112 user=esrep dbname=esrep port=54326 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3"

DETAIL: PQping() returned "PQPING_NO_RESPONSE"

NOTICE: begin to start server at 2023-08-02 16:13:44.320031

NOTICE: starting server using "/home/kingbase/cluster_v8r6/kingbase/bin/sys_ctl  -w -t 90 -D '/home/kingbase/cluster_v8r6/kingbase/data' -l /home/kingbase/cluster_v8r6/kingbase/bin/logfile start"

NOTICE: start server finish at 2023-08-02 16:13:44.425808

NOTICE: NODE REJOIN successful

DETAIL: node 1 is now attached to node 2

[2023-08-02 16:13:44] [NOTICE] kbha: node (ID: 1) rejoin success.

7、启动流复制

启动备库数据库

sys_ctl -D /data/kingbase/data start

查看流复制状态

select * from sys_stat_replication;

查看复制槽状态:

select * from sys_replication_slots;

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容