概述
KingbaseES V8支持使用RMAN物理备份在异机环境恢复,通过重新克隆方式完扩展主备集群。
原集群环境:演示用例,仅供参考
查看原集群备份和物理备份路径
异机恢复
前置条件
*获取原集群物理备份文件,包括全量备份、增量备份和历史归档*
*异机平台架构与原环境架构一致,包括CPU、操作系统版本、数据库版本*
基于RMAN备份集恢复
异机节点创建备份文件存储路径,将原集群备份拷贝至异机节点。(建议与原集群备份路径一致):如有差异需修改sys_rman.conf
异机节点查看备份信息
基于物理备份集还原
#创建data目录,授权700权限
$ pwd
/home/kingbase/cluster/7B0012/kingbase
$ mkdir data_new
$ chmod 700 data_new #数据目录权限为700
##/home/kingbase/cluster/7B0012/kingbase 为集群安装路径
修改备份配置文件sys_rman.conf
kb1-path=/home/kingbase/cluster/7B0012/kingbase/data_new
#还原命令
$ ./sys_rman --config=/home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase --set="20231109-112858F" restore
还原过程
物理备份异机还原完成,启动data验证,登录数据库执行select pg_wal_replay_resume();此操作是让数据库由只读变换成可读可写状态。
启动单机库
设置数据库可读可写
删除原集群配置信息,登录数据库esrep
单节点扩展为集群
修改配置文件
调整集群配置文件/etc/repmgr.conf,修改data_directory
异机集群主机repmgr.conf
$ cat ../etc/repmgr.conf
node_id='1'
node_name='node1'
promote_command='/home/kingbase/cluster/7B0012/kingbase/bin/repmgr standby promote -f /home/kingbase/cluster/7B0012/kingbase/etc/repmgr.conf'
follow_command='/home/kingbase/cluster/7B0012/kingbase/bin/repmgr standby follow -f /home/kingbase/cluster/7B0012/kingbase/etc/repmgr.conf -W --upstream-node-id=%n'
conninfo='host=192.168.2.155 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3'
log_file='/home/kingbase/cluster/7B0012/kingbase/log/hamgr.log'
kbha_log_file='/home/kingbase/cluster/7B0012/kingbase/log/kbha.log'
data_directory='/home/kingbase/cluster/7B0012/kingbase/data_new'
sys_bindir='/home/kingbase/cluster/7B0012/kingbase/bin'
scmd_options='-q -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ServerAliveInterval=2 -o ServerAliveCountMax=5 -p 8890'
reconnect_attempts=10
reconnect_interval=6
failover='automatic'
recovery='standby'
monitoring_history='no'
trusted_servers='192.168.2.14'
synchronous='all'
repmgrd_pid_file='/home/kingbase/cluster/7B0012/kingbase/etc/hamgrd.pid'
kbha_pid_file='/home/kingbase/cluster/7B0012/kingbase/etc/kbha.pid'
ping_path='/usr/bin'
auto_cluster_recovery_level=1
use_check_disk=off
use_scmd='on'
running_under_failure_trusted_servers=on
connection_check_type='mix'
异机主机节点启动集群管理进程
$ /home/kingbase/cluster/7B0012/kingbase/bin/kbha -A daemon -f /home/kingbase/cluster/7B0012/kingbase/bin/../etc/repmgr.conf
异机集群主节点加入集群,注册为主服务节点primary
异机集群备机节点,通过克隆方式加入集群
同理异机备机节点也需要启动集群管理进程
$ /home/kingbase/cluster/7B0012/kingbase/bin/kbha -A daemon -f /home/kingbase/cluster/7B0012/kingbase/bin/../etc/repmgr.conf
备机节点上克隆data
/home/kingbase/cluster/7B0012/kingbase/bin/repmgr -Uesrep -desrep -h 192.168.2.155 -p54321 standby clone -D /home/kingbase/cluster/7B0012/kingbase/data_new -F
备机集群配置文件
node_id=2
node_name='node2'
promote_command='/home/kingbase/cluster/7B0012/kingbase/bin/repmgr standby promote -f /home/kingbase/cluster/7B0012/kingbase/etc/repmgr.conf'
follow_command='/home/kingbase/cluster/7B0012/kingbase/bin/repmgr standby follow -f /home/kingbase/cluster/7B0012/kingbase/etc/repmgr.conf -W --upstream-node-id=%n'
conninfo='host=192.168.2.152 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3'
log_file='/home/kingbase/cluster/7B0012/kingbase/log/hamgr.log'
kbha_log_file='/home/kingbase/cluster/7B0012/kingbase/log/kbha.log'
data_directory='/home/kingbase/cluster/7B0012/kingbase/data_new'
sys_bindir='/home/kingbase/cluster/7B0012/kingbase/bin'
scmd_options='-q -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ServerAliveInterval=2 -o ServerAliveCountMax=5 -p 8890'
reconnect_attempts=10
reconnect_interval=6
failover='automatic'
recovery='standby'
monitoring_history='no'
trusted_servers='192.168.2.14'
synchronous='all'
repmgrd_pid_file='/home/kingbase/cluster/7B0012/kingbase/etc/hamgrd.pid'
kbha_pid_file='/home/kingbase/cluster/7B0012/kingbase/etc/kbha.pid'
ping_path='/usr/bin'
auto_cluster_recovery_level=1
use_check_disk=off
use_scmd='on'
running_under_failure_trusted_servers=on
connection_check_type='mix'
克隆备机
根据提示启动备机库,注册到集群