案例说明:
KingbaseES V8R6数据库执行sys_backup.sh init初始化时,出现“ERROR: can not connect the primary node...."错误,初始化失败。
适用版本:
KingbaseES V8R6
一、问题现象
如下所示,执行sys_backup.sh init时,出现以下错误”ERROR: can not connect the primary node..." 。
[kingbase@node201 bin]$ ./sys_backup.sh init
./sys_backup.sh: line 12: /home/kingbase/cluster/R6C8/HAC8/kingbase/bin: Is a directory
# pre-condition: check the non-archived WAL files
ERROR: can not connect the primary node 192.168.1.201 by ksql
HINT: may use sys_encpwd to setup .encpwd
二、问题分析
1、测试ksql免密连接
如下所示,ksql可以免密连接到数据库:
[kingbase@node201 bin]$ ./ksql -U system test -p 64325
Type "help" for help.
test=#
2、执行sh -x sys_backup.sh init
[kingbase@node201 bin]$ sh -x sys_backup.sh init
+ eval '_single_data_dir="/home/kingbase/db/r6_c8/data"'
++ _single_data_dir=/home/kingbase/db/r6_c8/data
+ read t_one_line
+ eval '#' bin dir of single
+ read t_one_line
+ eval _single_bin_dir= '"/home/kingbase/cluster/R6C8/HAC8/kingbase/bin"'
++ _single_bin_dir=
++ /home/kingbase/cluster/R6C8/HAC8/kingbase/bin
sys_backup.sh: line 12: /home/kingbase/cluster/R6C8/HAC8/kingbase/bin: Is a directory
........
++ /ksql --no-password --tuples-only 'dbname=test user=system port=64325 application_name=internal_rman'
+ _t_db_dir=
+ _rt_tmp=127
+ '[' X == X ']'
+ /bin/echo -e '\nERROR: can not connect the primary node 192.168.1.201 by ksql\nHINT: may use sys_encpwd to setup .encpwd'
ERROR: can not connect the primary node 192.168.1.201 by ksql
HINT: may use sys_encpwd to setup .encpwd
+ exit 1
如下所示,_single_bin_dir变量读取错误,变量从sys_backup.conf配置中读取:
如下所示,ksql执行路径错误,导致访问数据库失败:
如下所示,实际ksql可以免密访问数据库:
[kingbase@node201 bin]$ ./ksql --no-password --tuples-only 'dbname=test user=system port=64325 application_name=internal_rman'
Type "help" for help.
test=#
3、检查sys_backup.conf配置
如下所示,备份使用‘single’模式,变量配置通过sys_backup.conf配置获取:
[kingbase@node201 bin]$ cat sys_backup.conf
# target db style enum: single/cluster/single-pro
_target_db_style="single"
# data dir of single
_single_data_dir="/home/kingbase/db/r6_c8/data"
# bin dir of single
_single_bin_dir= "/home/kingbase/cluster/R6C8/HAC8/kingbase/bin"
如下所示,变量_single_bin_dir配置有空格,导致脚本读取变量异常:
三、问题解决
正确配置sys_backup.conf变量_single_bin_dir后,初始化正常:
[kingbase@node201 bin]$ cat sys_backup.conf|grep _bin_dir
_single_bin_dir="/home/kingbase/cluster/R6C8/HAC8/kingbase/bin"
四、问题总结
sys_backup.conf中的配置在‘single’模式下,需要读取变量配置,如果变量配置错误,将导致备份初始化异常。