KingbaseES V8R6备份恢复案例之---sys_backup.sh init无法创建stanza
案例说明:
KingbaseES V8R6数据库执行物理备份初始化操作,出现以下故障“ERROR: create stanza failed, check log file...",初始化失败。
适用版本:
KingbaseES V8R6
一、问题现象
如下所示,执行sys_backup.sh init,出现”ERROR: create stanza failed, check log file..."故障:
+ /bin/echo 'ERROR: create stanza failed, check log file /home/kingbase/cluster/R6C8/HAC8/kingbase/log/sys_rman_stanza-create.log'
ERROR: create stanza failed, check log file /home/kingbase/cluster/R6C8/HAC8/kingbase/log/sys_rman_stanza-create.log
+ exit 2
二、问题分析
1、执行sh -x sys_backup.sh init
......
+ /bin/sed -i -e 's:archive_command.*:archive_command='\''export TZ=Asia/Shanghai;/home/kingbase/cluster/R6C8/HAC8/kingbase/bin/sys_rman --config /home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase archive-push %p'\'':' /home/kingbase/cluster/R6C8/HAC8/kingbase/data/kingbase.conf
+ /bin/sed -i -e 's:archive_command.*:archive_command='\''export TZ=Asia/Shanghai;/home/kingbase/cluster/R6C8/HAC8/kingbase/bin/sys_rman --config /home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase archive-push %p'\'':' /home/kingbase/cluster/R6C8/HAC8/kingbase/data/es_rep.conf
+ /home/kingbase/cluster/R6C8/HAC8/kingbase/bin/sys_ctl -D /home/kingbase/cluster/R6C8/HAC8/kingbase/data reload
+ /bin/echo '# create stanza and check...(maybe 60+ seconds)'
# create stanza and check...(maybe 60+ seconds)
+ /bin/rm -rf /home/kingbase/kbbr_repo/archive
+ /bin/rm -rf /home/kingbase/kbbr_repo/backup
+ /home/kingbase/cluster/R6C8/HAC8/kingbase/bin/sys_rman --config=/home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase --log-level-console=info stanza-create
+ '[' X0 '!=' X58 ']'
+ /bin/echo 'ERROR: create stanza failed, check log file /home/kingbase/cluster/R6C8/HAC8/kingbase/log/sys_rman_stanza-create.log'
ERROR: create stanza failed, check log file /home/kingbase/cluster/R6C8/HAC8/kingbase/log/sys_rman_stanza-create.log
+ exit 2
2、执行脚本报错语句
如下所示,提示数据库实例数据存储路径data和备份指定的data路径不一致:
[kingbase@node201 bin]$ /home/kingbase/cluster/R6C8/HAC8/kingbase/bin/sys_rman --config=/home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase --log-level-console=info stanza-create
2024-08-20 17:27:09.910 P00 INFO: stanza-create command begin 2.27: --band-width=0 --config=/home/kingbase/kbbr_repo/sys_rman.conf --exec-id=5547-ec957ae7 --kb1-path=/home/kingbase/cluster/R6C8/HAC8/kingbase/data --kb1-port=64325 --kb1-user=system --log-level-console=info --log-level-file=info --log-path=/home/kingbase/cluster/R6C8/HAC8/kingbase/log --log-subprocess --process-max=4 --repo1-path=/home/kingbase/kbbr_repo --stanza=kingbase
WARN: set process-max 4 is too large, auto set to CPU core count 1
ERROR: [058]: version '12' and path '/home/kingbase/db/r6_c8/data' queried from cluster do not match version '12' and '/home/kingbase/cluster/R6C8/HAC8/kingbase/data' read from '/home/kingbase/cluster/R6C8/HAC8/kingbase/data/global/sys_control'
HINT: the kb1-path and kb1-port settings likely reference different clusters.
2024-08-20 17:27:10.053 P00 INFO: stanza-create command end: aborted with exception [058]
如下所示:
当前实例data存储路径:
[kingbase@node201 bin]$ ps -ef |grep 'kingbase -D'
kingbase 6881 1 0 09:50 ? 00:00:00 /home/kingbase/cluster/R6C8/HAC8/kingbase/bin/kingbase
-D /home/kingbase/db/r6_c8/data
3、检查sys_backup.conf配置
如下所示,配置文件指定的备份的data路径和实例的data路径不一致:
[kingbase@node201 bin]$ cat sys_backup.conf|grep _single_data
_single_data_dir="/home/kingbase/cluster/R6C8/HAC8/kingbase/data"
如下所示,备份采用single模式,需要读取sys_backup.conf配置:
[kingbase@node201 bin]$ cat sys_backup.conf |grep db_style
# target db style enum: single/cluster/single-pro
_target_db_style="single"
---由以上分析可知,由于在sys_backup.conf参数_single_data_dir配置有误,导致备份指定的data路径和实例的data路径不一致,从而备份初始化失败。
三、问题解决
配置sys_backup.conf将_single_data_dir配置正确,初始化成功:
[kingbase@node201 bin]$ cat sys_backup.conf |grep data_dir
_single_data_dir="/home/kingbase/db/r6_c8/data"
四、问题总结
sys_backup.conf中的配置在‘single’模式下,需要读取变量配置,如果变量配置错误,将导致备份初始化异常。