成都市住房和城乡建设局官方网站,互联网app开发,网站上线稳定后工作,wordpress添加微信扫码支付此场景为单机数据库节点内部备份#xff0c;方便部署和操作#xff0c;但备份REPO与数据库实例处于同一个物理主机#xff0c;冗余度较低。
前期准备
配置ksql免密登录(必须)
在Kingbase数据库运行维护中#xff0c;经常用到ksql工具登录数据库#xff0c;本地免密登录…此场景为单机数据库节点内部备份方便部署和操作但备份REPO与数据库实例处于同一个物理主机冗余度较低。
前期准备
配置ksql免密登录(必须)
在Kingbase数据库运行维护中经常用到ksql工具登录数据库本地免密登录可以让维护数据库时摆脱每次登库输入用户名密码下面介绍KingbaseES V8数据库2种配置免密登录的方法。 ksql登录时会去数据库安装用户家目录下的密码文件.encpwd中读取账户从而登入数据库密码文件为普通文本文件可以vi创建也可以使用kingbase提供的工具sys_encpwd工具来生成密码文件。 本案例采用system用户做演示若需其他用户视情况更改。
配置环境变量
su - kingbase
vi .bash_profile
export KINGBASE_USERsystem
export KINGBASE_PORT54326
export KINGBASE_DATABASEtest.encpwd内容解析
每一行代表一条访问规则记录可以配置多条记录每条记录包含5个字段字段与字段之间用冒号“”分隔5个字段分别为主机地址、端口号、库名、用户名、密码加密格式 .encpwd若不存在会创建若已存在会追加记录。 例
127.0.0.1:54321:test:u1:MTIzNDU2sys_encpwd配置工具使用方法
该工具包含5个参数5个参数均需要输入才能配置成功 参数说明
-H, --hostname主机地址允许单主机地址匹配和全匹配全匹配时使用*指定
-P, --portnum端口号仅允许单端口匹配
-D, --database数据库名允许单数据库匹配和全匹配全匹配时使用*指定
-U, --user用户名仅允许单用户匹配
-W, --password用户对应的密码仅允许单用户匹配注意当前四个参数输入与原文件中的某一条记录完全相同时会修改该条记录相应的密码否则生成一条新的记录。
示例1将新创建用户登录信息加入密码文件
--创建用fuwa并指定密码用ksql测试登录需要输入密码
[kingbasenode1 ~]$ ksql -Usystem -W test
口令
ksql (V8.0)
输入 help 来获取帮助信息.
test# create user fuwa with password fuwa;
CREATE ROLE
test# \q
[kingbasenode1 ~]$ ksql -Ufuwa test
ksql (V8.0)
输入 help 来获取帮助信息.
test --使用sys_encpwd工具配置密码指定fuwa用户可以从任意主机、任意端口登录任意数据库
[kingbasenode1 ~]$ sys_encpwd -H \* -P \* -D \* -U fuwa -W fuwa
[kingbasenode1 ~]$ cat .encpwd
*:*:*:fuwa:ZnV3YQ参数说明-H 指定任意主机-P指定任意端口-D指定任意库*“*”为特殊字符需要加\转义**--测试用户fuwa免密登录
[kingbasenode1 ~]$ ksql -Ufuwa test
ksql (V8.0)
输入 help 来获取帮助信息.test 示例2对system用户登录信息加入密码文件
[kingbasenode1 ~]$ sys_encpwd -H \* -P \* -D \* -U system -W kingbase
[kingbasenode1 ~]$ cat .encpwd
*:*:*:fuwa:ZnV3YQ
*:*:*:system:a2luZ2Jhc2U问题免密登录配置后登录失败
--问题描述
免密登录配置后登录失败
[kingbaseguanxishujukufuwuqi2 ~]$ cat .encpwd
*:*:*:system:dG9wYWhwY18xMjM
[kingbaseguanxishujukufuwuqi2 ~]$ ksql
ksql: error: could not connect to server: could not connect to server: No such file or directoryIs the server running locally and acceptingconnections on Unix domain socket /tmp/.s.KINGBASE.54321?
[kingbaseguanxishujukufuwuqi2 ~]$ ps -ef | grep Kingbase
kingbase 2044 1 0 Dec20 ? 00:00:08 /KingbaseV8R6/KESRealPro/V008R006C008B0014/Server/bin/kingbase -D /topsoft/kbdata
kingbase 563074 555702 0 19:45 pts/0 00:00:00 grep Kingbase--解决办法数据库开启归档模式(必须)
--开启归档模式
[kingbasenode1 ~]$ vi /data/kingbase.conf
#archive_mode off # enables archiving; off, on, or always
#archive_command
改为
archive_mode on # enables archiving; off, on, or always
archive_command --重启库
[kingbasenode1 ~]$ sys_ctl restart -D /data/补充archive_command 没有被注释内容将被脚本自动修改
规划备份目录
[rootnode1 bin]# mkdir -p /kbrmanbak
[rootnode1 bin]# chown -R kingbase:kingbase /kbrmanbak/
[rootnode1 bin]# chmod -R 755 /kbrmanbak/sys_rman的初始化配置
准备初始配置文件
sys_backup.conf初始化配置文件供操作人员修改的配置文件 sys_rman.conf运行时配置文件由初始化动作自动生成不推荐人为后续的修改。 工具按照如下顺序寻找初始化配置文件
cd /KingbaseES/V8/Server
# bin/sys_backup.conf
# share/sys_backup.conf生成sys_backup.conf并更改
V008R006C005B0023之后的版本支持securecmdd或sshd之前的版本支持sshd。
--查找sys_backup.conf模板位置
[kingbasenode1 bin]$ find / -name sys_backup.conf
/KingbaseES/V8/Server/share/sys_backup.conf
/KingbaseES/V8/ClientTools/share/sys_backup.conf
/KingbaseES/V8/ManagerTools/share/sys_backup.conf--生成正式sys_backup.conf文件
[kingbasenode1 bin]$ cp /KingbaseES/V8/Server/share/sys_backup.conf /KingbaseES/V8/Server/bin/sys_backup.conf--正式sys_backup.conf文件 追加以下内容
# 网络限速单位固定为 MB/s, 默认为0代表不限速配置文件仅接受纯数字
# band witdh limit, fixed in MB/s, default 0 means no limit
_band_width0
# 使用通讯协议默认使用securecmdd可选使用ssh视生产环境版本更改参数值
# V008R006C005B0023之后的版本支持securecmdd或sshd之前的版本支持sshd。
# on means securecmdd, off means normal ssh
_use_scmdon
# 是否快速启动备份立即生成checkpoint默认y
# whether to sys_start_backup() fastly, y or n
_start_fasty
#可在指定备份时、还原时并行处理可使用的并发进程数量
--process-max4
# 是否在备份时使用压缩存储默认为none不压缩 若指定压缩级别可选范围 [ 0 - 9 ]
# whether to gz the target file, none or gz
_compress_typegz
--compress-level3
# 在init过程中检查未归档的WAL的容量
# 如果超过设置值报错并退出init过程
# 单位固定为MB可选 128 ~ 1024
# if the non archived WAL files , more than this setting
# show ERROR and break the backup-init, unit be fixed in MB, 128 ~ 1024
_non_archived_space1024
# 不启用归档统计功能
_archive_statisticsn--更改正式sys_backup.conf文件,更改后内容如下
[kingbasenode1 bin]$ cat /KingbaseES/V8/Server/bin/sys_backup.conf
#file: sys_backup.conf
#dest dir: cluster_dir/kingbase/bin/sys_backup.conf
#dest dir: cluster_dir/kingbase/share/sys_backup.conf#单机 single 集群 cluster 集群各节点独立备份 single-pro
# target db style enum: single/cluster
_target_db_stylesingle
#一个数据库节点的IP支持主机名、IPv4、IPv6地址
# one kingbase node IP
# just provide one IP, script will use repmgr cluster show get other node IP
_one_db_ip192.168.40.110
#REPO备份节点的IP 本配置项支持主机名、IPv4、IPv6地址
# local repo IP, inner-REPO, must be same as one_db_ip, means repo located in one db node
# outer repo IP, outer-REPO, means repo located in outer node
_repo_ip192.168.40.110
# 备份服务器的标签仅在备份范畴内使用
# label of this cluster
_stanza_namekingbase
# 操作系统的用户名
# OS user name of database
_os_user_namekingbase
# 实际保存备份集的目录
# !!!! dir to store the backup files
# should be accessable for the OS user
_repo_path/kbrmanbak/kbbr_repo
# 保存全量备份的数目超过此数目的全量备份将被自动移除
# count of keep, over the count FULL-backup will be remove
_repo_retention_full_count5
# 自动执行全量备份的间隔天数
# count of days, interval to do FULL-backup
_crond_full_days1
# 自动执行差异备份的间隔天数0表示不执行
# count of days, interval to do DIFF-backup
_crond_diff_days0
# 自动执行增量备份的间隔天数0表示不执行
# count of days, interval to do INCR-backup
_crond_incr_days0
# 自动执行全量备份的时间点2表示凌晨2点
# HOUR to do the FULL-backup
_crond_full_hour2
# 自动执行差异备份的时间点3表示凌晨3点
# HOUR to do the DIFF-backup
_crond_diff_hour3
# 自动执行增量备份的时间点4表示凌晨4点
# HOUR to do the INCR-backup
_crond_incr_hour4
# 操作系统常见命令的全路径文件名
# OS cmd define
_os_ip_cmd/sbin/ip
_os_rm_cmd/bin/rm
_os_sed_cmd/bin/sed
_os_grep_cmd/bin/grep
# 以下四个参数仅用于单机模式
# !!! these follow 4 parameter ONLY for single style
# 单机数据库节点的数据目录
# data dir of single
_single_data_dir/data
# 单机数据库节点的二进制目录
# bin dir of single
_single_bin_dir/KingbaseES/V8/Server/bin
# 单机数据库节点的数据库登录用户名
# database user of single
_single_db_usersystem
# 单机数据库节点的端口
# database port of single
_single_db_port54321
# 网络限速单位固定为 MB/s, 默认为0代表不限速配置文件仅接受纯数字
# band witdh limit, fixed in MB/s, default 0 means no limit
_band_width0
# 使用通讯协议默认使用securecmdd可选使用ssh视生产环境版本更改参数值
# V008R006C005B0023之后的版本支持securecmdd或sshd之前的版本支持sshd。
# on means securecmdd, off means normal ssh
_use_scmdon
# 是否快速启动备份立即生成checkpoint默认y
# whether to sys_start_backup() fastly, y or n
_start_fasty
#可在指定备份时、还原时并行处理可使用的并发进程数量
--process-max4
# 是否在备份时使用压缩存储默认为none不压缩 若指定压缩级别可选范围 [ 0 - 9 ]
# whether to gz the target file, none or gz
_compress_typegz
--compress-level3
# 在init过程中检查未归档的WAL的容量
# 如果超过设置值报错并退出init过程
# 单位固定为MB可选 128 ~ 1024
# if the non archived WAL files , more than this setting
# show ERROR and break the backup-init, unit be fixed in MB, 128 ~ 1024
_non_archived_space1024
# 不启用归档统计功能
_archive_statisticsn注意事项
[kingbasenode1 bin]$ vi /KingbaseES/V8/Server/bin/sys_backup.conf
....
# 使用通讯协议默认使用securecmdd可选使用ssh视生产环境版本更改参数值
# V008R006C005B0023之后的版本支持securecmdd或sshd之前的版本支持sshd。
# on means securecmdd, off means normal ssh
_use_scmdoff
...--查看版本方法
[kingbasenode1 bin]$ ksql -V
ksql (Kingbase) V008R006C005B0023sys_rman初始化
初始化步骤
kingbasenode1 kbrmanbak]$ sys_backup.sh init
The authenticity of host 192.168.40.110 (192.168.40.110) cant be established.
ECDSA key fingerprint is b8:54:e0:74:c5:e2:33:46:0d:7d:39:91:e3:b5:5a:6d.
Are you sure you want to continue connecting (yes/no)? yes
root192.168.40.110s password:
# generate single sys_rman.conf...DONE
# update single archive_command with sys_rman.archive-push...DONE
# create stanza and check...(maybe 60 seconds)
2023-12-22 13:43:32.069 CST [12140] 警告: max_connections should be less than or equal than 10 (restricted by license)
2023-12-22 13:43:32.069 CST [12140] 提示: the value of max_connect is set 10
# create stanza and check...DONE
# initial first full backup...(maybe several minutes)
# initial first full backup...DONE
# Initial sys_rman OK.
sys_backup.sh start should be executed when need back-rest feature.问题处理
check stanza failed
--问题描述
sys_rman初始化报错
[kingbasenode1 bin]$ sys_backup.sh init
The authenticity of host 192.168.40.110 (192.168.40.110) cant be established.
ECDSA key fingerprint is b8:54:e0:74:c5:e2:33:46:0d:7d:39:91:e3:b5:5a:6d.
Are you sure you want to continue connecting (yes/no)? yes
Please input password ...
root192.168.40.110s password: local - root192.168.40.110 ssh pwd-less OK.
# generate single sys_rman.conf...DONE
# update single archive_command with sys_rman.archive-push...DONE
# create stanza and check...(maybe 60 seconds)
ERROR: check stanza failed, check log file /KingbaseES/V8/Server/log/sys_rman_check.log--分析过程
[kingbasenode1 bin]$ tail -300f /KingbaseES/V8/Server/log/sys_rman_check.log
2023-12-22 13:38:56.493 P00 INFO: check command begin 2.27: --config/kbrmanbak/kbbr_repo/sys_rman.conf --log-level-consoleinfo --log-level-fileinfo --log-path/KingbaseES/V8/Server/log --log-subprocess --kb1-path/data --kb1-port54321 --kb1-usersystem --repo1-path/kbrmanbak/kbbr_repo --stanzakingbase
ERROR: [068]: archive_command [null] must contain sys_rman
2023-12-22 13:38:57.009 P00 INFO: check command end: aborted with exception [068]--解决办法
去掉archive_command前的#标识去掉后如下
archive_command/KingbaseES/V8/Server/bin/sys_rman --config /kbrmanbak/kbbr_repo/sys_rman.conf --stanzakingbase archive-push %p重启库
sys_backup.sh init删除目录
cd /kbrmanbak/
rm -rf kbbr_repo/再次sys_rman初始化成功
kingbasenode1 kbrmanbak]$ sys_backup.sh init
The authenticity of host 192.168.40.110 (192.168.40.110) cant be established.
ECDSA key fingerprint is b8:54:e0:74:c5:e2:33:46:0d:7d:39:91:e3:b5:5a:6d.
Are you sure you want to continue connecting (yes/no)? yes
root192.168.40.110s password:
# generate single sys_rman.conf...DONE
# update single archive_command with sys_rman.archive-push...DONE
# create stanza and check...(maybe 60 seconds)
2023-12-22 13:43:32.069 CST [12140] 警告: max_connections should be less than or equal than 10 (restricted by license)
2023-12-22 13:43:32.069 CST [12140] 提示: the value of max_connect is set 10
# create stanza and check...DONE
# initial first full backup...(maybe several minutes)
# initial first full backup...DONE
# Initial sys_rman OK.
sys_backup.sh start should be executed when need back-rest feature.
securecmdd does not work
--问题描述
[kingbaseguanxishujukufuwuqi2 share]$ sys_backup.sh init
ERROR: securecmdd does not work, please check--解决办法[rootguanxishujukufuwuqi2 ~]# cd /KingbaseV8R6/KESRealPro/V008R006C008B0014/ClientTools/guitools/DeployTools/zip
[rootguanxishujukufuwuqi2 zip]$ ls -l
total 232164
-rwxrwxr-x 1 root root 179967 Sep 2 04:15 cluster_install.sh
-rw-rw-r-- 1 root root 234974045 Sep 2 04:15 db.zip
-rw-rw-r-- 1 root root 14409 Sep 2 04:15 install.conf
-rw-rw-r-- 1 root root 2552788 Sep 2 04:15 securecmdd.zip
-rwxrwxr-x 1 root root 7374 Sep 2 04:15 trust_cluster.sh
[rootguanxishujukufuwuqi2 zip]$ unzip securecmdd.zip
Archive: securecmdd.zipcreating: securecmdd/creating: securecmdd/lib/inflating: securecmdd/lib/libcrypt.so.1 inflating: securecmdd/lib/libcrypto.so.1.1 inflating: securecmdd/lib/libssl.so.1.1 creating: securecmdd/bin/inflating: securecmdd/bin/sys_securecmd inflating: securecmdd/bin/sys_secureftp inflating: securecmdd/bin/sys_HAscmdd.sh inflating: securecmdd/bin/sys_securecmdd creating: securecmdd/share/inflating: securecmdd/share/sys_HAscmdd.conf inflating: securecmdd/share/key_file inflating: securecmdd/share/securecmdd_config inflating: securecmdd/share/securecmdd.service inflating: securecmdd/share/securecmd_config inflating: securecmdd/share/accept_hosts [rootguanxishujukufuwuqi2 zip]$ cd securecmdd/bin/
[rootguanxishujukufuwuqi2 bin]$ ls -l
total 2032
-rwxr-xr-x 1 root root 34468 Sep 2 04:15 sys_HAscmdd.sh
-rwxr-xr-x 1 root root 854936 Sep 2 04:15 sys_securecmd
-rwxr-xr-x 1 root root 986600 Sep 2 04:15 sys_securecmdd
-rwxr-xr-x 1 root root 198976 Sep 2 04:15 sys_secureftp说明必须root下启动[rootguanxishujukufuwuqi2 bin]# sh sys_HAscmdd.sh init
successfully initialized the sys_securecmdd, please use sys_HAscmdd.sh start to start the sys_securecmdd
[rootguanxishujukufuwuqi2 bin]# sh sys_HAscmdd.sh start
Created symlink /etc/systemd/system/multi-user.target.wants/securecmdd.service → /etc/systemd/system/securecmdd.service.--问题描述
[kingbaseguanxishujukufuwuqi2 ~]$ sys_backup.sh init
# pre-condition: check the non-archived WAL files
# generate single sys_rman.conf...DONE
# update single archive_command with sys_rman.archive-push...DONE
# create stanza and check...(maybe 60 seconds)
# create stanza and check...DONE
# initial first full backup...(maybe several minutes)
ERROR: full backup failed, check log file /KingbaseV8R6/KESRealPro/V008R006C008B0014/Server/log/sys_rman_backup.log[kingbaseguanxishujukufuwuqi2 ~]$ tail -300f /KingbaseV8R6/KESRealPro/V008R006C008B0014/Server/log/sys_rman_backup.log
2023-12-29 14:53:23.955 P01 INFO: backup file /topsoft/kbdata/base/1/1177 (0B, 99%)
2023-12-29 14:53:23.955 P02 INFO: backup file /topsoft/kbdata/.wallet/userkey.kr (0B, 99%)
2023-12-29 14:53:24.057 P03 INFO: backup file /topsoft/kbdata/.wallet/tspkey.kr (0B, 99%)
2023-12-29 14:53:24.257 P01 INFO: backup file /topsoft/kbdata/.wallet/tbcolkey.kr (0B, 99%)
2023-12-29 14:53:24.257 P02 INFO: backup file /topsoft/kbdata/.wallet/method.md (0B, 99%)
ERROR: [041]: raised from local-4 protocol: unable to open file /topsoft/kbdata/kingbase.conf_back_2023-12-20_14_11_44 for read: [13] Permission denied[file_open_err] on retry after 0ms[file_open_err] on retry after 15000ms
2023-12-29 14:53:32.616 P00 INFO: backup command end: aborted with exception [041]备份管理与优化
性能优化-并行处理
工具支持多进程并发拷贝物理文件请根据当前环境的主库的性能情况合理设置多进程数量。 可指定备份时、还原时并行处理可使用的并发进程数量。 –process-max4 # 默认指定可并发4个进程来备份或还原 可选范围是1~999
性能优化-压缩优化
压缩将节约空间、消耗时间不压缩将节约时间、消耗空间请根据场景需要设置是否压缩存储备份集和归档WAL日志文件。 指定备份文件实际存储时压缩算法和压缩级别
--compress-type none # none 不压缩默认设置可选 none / gz
--compress-level3 # 指定压缩级别可选范围 [ 0 - 9 ]备份还原时限速
备份和还原时工具可以进行限速单位固定为MB/s可以在sys_rman.conf中动态调整。 限速功能在还原场景时因为逐个文件进行checksum校验和比对限速精度受到影响实际均速低于设定速度。建议在还原时不开启限速功能 REPO_PATH/sys_rman.conf 配置 band-width0 。 在单机和集群内部备份场景时限速行为将生效
备份任务的启停
sys_backup.sh start
脚本使用crontab命令增加定时任务使用sys_rman进行定时备份可以通过crontab -l 查看定时任务。 全量备份、差异备份、增量备份均为可选。 备份类型、备份周期和备份时间由配置文件sys_backup.conf指定。
[kingbasenode1 ~]$ sys_backup.sh start
Enable some sys_rman in crontab-daemon
Set full-backup in 1 days
0 2 */1 * * kingbase /KingbaseES/V8/Server/bin/sys_rman --config/kbrmanbak/kbbr_repo/sys_rman.conf --stanzakingbase --archive-copy --typefull backup /KingbaseES/V8/Server/log/sys_rman_backup_full.log 21[kingbasenode1 ~]$ crontab -l
0 2 */1 * * /KingbaseES/V8/Server/bin/sys_rman --config/kbrmanbak/kbbr_repo/sys_rman.conf --stanzakingbase --archive-copy --typefull backup /KingbaseES/V8/Server/log/sys_rman_backup_full.log 21说明
需要去掉以下中的kingbase不然备份提示/bin/sh: kingbase: 未找到命令
[kingbasenode1 ~]$ crontab -l
0 2 */1 * * kingbase /KingbaseES/V8/Server/bin/sys_rman --config/kbrmanbak/kbbr_repo/sys_rman.conf --stanzakingbase --archive-copy --typefull backup /KingbaseES/V8/Server/log/sys_rman_backup_full.log 21sys_backup.sh stop
从系统CRONTAB中移除所有sys_rman相关的备份条目。
[kingbasenode1 ~]$ sys_backup.sh stop
Disable all sys_rman in crontab-daemon[kingbasenode1 kingbase]$ crontab -l
no crontab for kingbase
sys_backup.sh pause
暂时停止定时备份动作。
sys_backup.sh pause
Puase the sys_rman...DONEsys_backup.sh unpause
恢复被暂停的定时备份动作。
sys_backup.sh unpause
Un-Puase the sys_rman...DONEsys_backup.conf信息变化处理
如果sys_backup.conf中关于数据库的信息包含IP、数据库名、端口等有所修改需要重新初始化备份,执行 sys_backup.sh init重新初始化备份功能。 如果sys_backup.conf中关于备份周期和时间点的信息有所修改重新配置即可执行sys_backup.sh start重新配置自动备份周期。
sys_rman.conf配置说明
运行时配置文件sys_rman.conf不推荐手动修改如果需要进行修改请参考此段落
以下参数修改后需要重新初始化生效
# DB节点的data目录
kb*-path/home/kingbase/kingbase/data
# DB节点的监听端口
kb*-port54321
# DB节点的数据库用户
kb*-useresrep
# DB节点的IP地址
kb*-host10.11.12.13
# DB节点的OS用户名
kb*-host-userkingbase
# REPO节点的实际备份目录
repo1-path/home/kingbase/kbbr_repo修改完成后执行以下命令完成重新初始化
/home/kingbase/cluster/project/cluster/kingbase/bin/sys_rman --config/home/kingbase/kbbr_repo/sys_rman.conf --stanzakingbase stanza-create
/home/kingbase/cluster/project/cluster/kingbase/bin/sys_rman --config/home/kingbase/kbbr_repo/sys_rman.conf --stanzakingbase check
/home/kingbase/cluster/project/cluster/kingbase/bin/sys_rman --config/home/kingbase/kbbr_repo/sys_rman.conf --stanzakingbase --typefull backup以下参数修改后需要一次全量备份生效
# 是否压缩备份的数据默认none不压缩可选 none / gz
# 压缩将节约空间、消耗时间不压缩将节约时间、消耗空间。
compress-typenone
# 压缩级别 默认3 1~99代表最大压缩同时也最耗时
compress-level3修改完成后执行以下命令完成一次全量备份:
/home/kingbase/cluster/project/cluster/kingbase/bin/sys_rman --config/home/kingbase/kbbr_repo/sys_rman.conf --stanzakingbase --typefull backup以下参数修改后直接生效
# REPO节点保留至多的全量备份
repo*-retention-full5
# REPO节点的sys_rman工具日志保存路径
log-path/home/kingbase/kingbase/log
# 写入到日志文件的日志级别, info debug trace
log-level-fileinfo
# 执行命令时屏幕的日志级别, info debug trace
log-level-consoleinfo
# 是否记录子进程的日志 y / n
log-subprocessy
# 多进程的至多数目
process-max4
# 是否快速生成checkpoint在开启实际备份之前
start-fasty
# 是否保留目录下的软链接
link-ally
# 未归档的WAL文件容量的警告阈值
non-archived-space1024
# 归档单个WAL的超时时间
archive-timeout600
# 限速单位固定为MB/s
band-width0
# 备份过程中遇到校验和等问题时会执行的自定义命令如发送告警邮件等
alert-command( cd /opt/Kingbase/ES/Server/bin; ./sys_mail -s %t -b %c )常见异常处理
1、ERROR RMAN-00500: Non archived WAL files more than 1024 M , Please check the user-guide
原因在初始化阶段未归档的WAL文件超过了设定的容忍值 解决
确保这些WAL日志是否有被其他第三方使用若有请尽快联系第三方转移这些归档。确保这些WAL日志是否被不恰当使用后造成积压例如归档目录意外删除存储掉线等。若有将其积压文件用scp/cp等方式转移。在确认这些日志无用后进入数据库子目录默认data/sys_wal/archive_status/rm -rf *.ready 。随后进入数据库执行checkpoint此时会清理这些积压日志此操作会引起IO高峰选择在可维护时间段内进行。重新执行初始化 sys_backup.sh init
2、ERROR: [058]: version ‘12’ and path ‘…/data’ queried from cluster do not match version ‘12’ and ‘/home/kingbase/cluster/project/cluster/kingbase/data’ read from ‘/home/kingbase/cluster/project/cluster/kingbase/data/global/sys_control’
原因备份工具需要绝对路径来寻找data目录 解决启动数据库时应该使用绝对路径来指定data目录
3、ERROR: sys_backup.conf does not exist
原因在相应目录不存在sys_backup.conf文件 解决确认./kingbase/bin/ 或 kingbase/share/ 存在此文件
4、ERROR: /home/kingbase/cluster/project/cluster/kingbase/bin/sys_backup.conf invalid.
原因指明配置文件具有无效的配置内容 解决请根据模板确认配置文件的内容
5、ERROR: Configured repo-path [/home/kingbase/kbbr_repo] be NOT accessable by current user
原因当前数据库用户不能有效访问配置文件指定的repo-path目录 解决通过高权限用户比如ROOT去修改目标目录的权限或重新指定目录
6、ERROR: Configured repo-retention-full invalid.
原因配置文件中的repo-retention-full不是有效的数字 解决该配置项repo-retention-full需要大于0的数字
7、ERROR: Configured crond-full-days invalid.
原因配置文件中的crond-full-days不是有效的数字 解决该配置项crond-full-days需要大于或等于0的数字
8、ERROR: Configured crond-diff-days invalid.
原因配置文件中的crond-diff-days不是有效的数字 解决该配置项crond-diff-days需要大于或等于0的数字
9、ERROR: Configured crond-incr-days invalid.
原因配置文件中的crond-incr-days不是有效的数字 解决该配置项crond-incr-days需要大于或等于0的数字
10、ERROR: Configured crond-full-hour invalid.
原因配置文件中的crond-full-hour不是有效的数字 解决该配置项crond-full-hour需要大于0
11、ERROR: Configured crond-diff-hour invalid.
原因配置文件中的crond-diff-hour不是有效的数字 解决该配置项crond-diff-hour需要大于0
12、ERROR: Configured crond-incr-hour invalid.
原因配置文件中的crond-incr-hour不是有效的数字 解决该配置项crond-incr-hour需要大于0
13、ERROR: sys_backup.sh init must executed firstly
原因尚未初始化工具的环境 解决执行其他命令之前执行init初始化命令
14、ERROR: sys_backup.sh must be executed by db-specify user
原因本脚本不能由非数据库OS用户执行 解决使用数据库关联的OS用户执行
15、ERROR: repo_ip must located in local, and sys_backup.sh be executed at REPO host.
原因配置文件sys_backup.conf指定的repo_ip不存在于本地 解决初始化动作必须在REPO本机执行
16、ERROR: local ssh-keygen fail,please check /tmp/ssh-keygen.log
原因REPO节点与数据库节点的SSH免密配置失败 解决检查日志文件确认系统原因
17、ERROR: config file ‘/home/kingbase/cluster/project/cluster/kingbase/etc/repmgr.conf’ does not exist
原因不能找到需要的第三方工具配置文件repmgr.conf 解决确认目录下存在repmgr.conf文件
18、ERROR: ‘/home/kingbase/cluster/project/cluster/kingbase/etc/repmgr.conf’ at ‘192.168.28.121’ invalid
原因在数据库节点192.168.28.121上的repmgr.conf文件内容有误 解决确认此节点上的repmgr文件
19、ERROR: sys_backup.sh init must be executed by db-specify user ‘kingbase’
原因初始化命令只能由数据库关联用户执行 解决使用数据库关联用户执行
20、ERROR: can not connect to db at 192.168.28.37,please check /home/kingbase/cluster/project/cluster/kingbase/data/sys_log/
原因不能访问节点的数据库服务 解决检查本信息给出的日志目录确认原因
21、ERROR: at 192.168.28.37, user ‘kingbase’ can not access the repo-path [/home/kingbase/kbbr_repo]
原因在数据节点上指定OS用户不能有效访问repo-path 解决在此节点确保指定OS用户的访问权限。
22、ERROR: create stanza failed, check log file /tmp/sys_rman_stanza-create.log
原因创建stanza失败 解决检查本信息给出的日志文件
23、ERROR: check stanza failed, check log file /tmp/sys_rman_check.log
原因创建后的隐式check命令失败 解决检查本信息给出的日志文件
24、ERROR: full backup failed, check log file /tmp/sys_rman_backup.log
原因创建后的隐式第一次全量备份失败 解决检查本信息给出的日志文件
25、ERROR: [050]: unable to acquire lock on file ‘/tmp/sys_rman/kbbr-backup.lock’:
原因有另外的sys_rman进程在本地环境中运行或上一个进程没有正常退出 解决删除 /tmp/sys_rman/ *.lock
26、ERROR: [082]: WAL segment 000000010000000000000001 was not archived before the 60000ms timeout HINT: check the archive_command to ensure that all options are correct (especially --stanza). HINT: check the Kingbase server log for errors.
原因之一可能在互相ssh认证中需要首次执行一遍YES/NO以过StrictHostKeyChecking的检测。 The authenticity of host ‘10.10.11.xxx (10.10.11.xxx)’ can’t be established. ECDSA key fingerprint is SHA256:dpXDPJcv1S0J8Iy1hpwk2jYi1z5ZxI5eCyKa72LnrYo. Are you sure you want to continue connecting (yes/no)? 解决要求管理员在数据库节点与外部备份节点之间以相应的OS用户互相进行SSH登录以验证SSH登录场景。 原因之二可能此时数据库业务量较大造成的WAL日志文件很多导致WAL日志文件归档超时默认60s 解决在所有节点的_repo_path/sys_rman.conf文件内的[global]下新增一行“archive-timeout600”增大超时时间
27、ERROR:Uncaught FileMissingError: unable to open missing file ‘/home/kingbase/kbbr_repo/backup/kingbase/20201022-141202F/backup.manifest’ for read
原因因为上一次备份被意外中断导致上一次备份的某些文件没有正常规整。 解决进入此错误信息所示目录找到backup.manifest.copy文件重新命名为backup.manifest即可再次备份。
28、ERROR: Configured repo-path [/backup/kbbr_repo] already exists
原因sys_backup.conf内repo-path目录设置不变时不允许多次执行init操作 解决将现有的repo-path目录删除请确认无重要备份数据可以删除或重命名或移动到其他位置或者更改sys_backup.conf内repo-path目录设置
29、ERROR: [029]: new backup label ‘20210713-182300F_20210713-144328I’ is not later than latest backup label ‘20210713-182300F_20210713-225102I.manifest.gz’ HINT: has the timezone changed? HINT: is there clock skew?
原因可能是集群节点时钟不同步 解决集群中所有节点必须做时钟同步系统时间需保持一致要求至少误差范围在2s以内
30、WARN: unable to check kb-1: [DbConnectError] unable to connect to ‘dbname‘test’ port54321 user‘system’’: FATAL: database “test” does not exist
ERROR: [056]: unable to find primary cluster - cannot proceed 原因可能是执行sys_rman备份等操作时连接的数据库默认为test库不存在或者是 --kb1-database 参数指定了不存在的数据库 解决重新创建test库 create database test 或执行备份等操作时通过 --kb1-database 指定一个存在的数据库例如 --kb1-databasetest1
31、WARN: unable to check kb-1: [DbConnectError] unable to connect to ‘dbname‘test’ port54321 user‘system’’: FATAL: database “test” does not exist
ERROR: [027]: no database found 原因可能是执行sys_rman check等操作时连接的数据库默认为test库不存在或者是 --kb1-database 参数指定了不存在的数据库 解决重新创建test库 create database test 或执行check等操作时通过 --kb1-database 指定一个存在的数据库例如 --kb1-databasetest1
32、ERROR: [055]: sys_control must be present in all online backups HINT: is something wrong with the clock or filesystem timestamps?
原因可能是sys_control文件自上次备份后一直未被更新导致的正常情况下该文件应被频繁地或周期性地修改对于集群的场景可能是主节点异常导致备节点上sys_control停止更新 解决确认sys_control文件的最后修改时间并调查sys_control停止更新的原因如问题发生在备节点上请检查集群状态是否正常在集群状态正常后再次进行备份
33、FATAL: hot standby is not possible because max_connections 100 is a lower setting than on the master server (its value was 200)
原因生成备份集后某时刻又将max_connections等参数改大sys_rman restore将其还原成原小值在hot_standbyon的场景下执行sys_ctl start启动重放WAL日志时禁止将max_connections等参数重放成一个更大的值导致数据库无法启动sys_log目录下日志显示以上报错 解决启动数据库前手动把max_connections等报错的参数改大后再启动数据库此外修改配置后即时备份可预防此类报错