案例说明:

KingbaseES V8R6C6中sys_backup.sh在通用机单实例环境,默认需要通过securecmdd工具以及kingbase和root用户之间的ssh互信,执行备份初始化(init);对于使用ssh环境,如果kingbase和root之间没有建立ssh互信,直接执行脚本初始化会产生错误,需要修改脚本后再执行。

操作系统:

适用版本:

KingbaseES V8R6C6

数据库环境:

[kingbase@node102 bin]$ ./ksql -V
ksql (Kingbase) V008R006C006B0013 [kingbase@node102 bin]$ ./sys_ctl start -D /data/kingbase/v8r6_c6/data
waiting for server to start....2022-07-26 15:33:40.262 CST [7582] LOG: sepapower extension initialized
.......
server started [kingbase@node102 bin]$ netstat -an |grep 54322
tcp 0 0 0.0.0.0:54322 0.0.0.0:* LISTEN
tcp6 0 0 :::54322 :::* LISTEN

关闭securecmdd服务:

[kingbase@node102 bin]$ ps -ef |grep secure
root 1169 1 0 09:43 ? 00:00:00 sys_securecmdd: /home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_securecmdd -f /etc/.kes/securecmdd_config [listener] 0 of 128-256 startups
kingbase 4711 9114 0 15:15 pts/0 00:00:00 grep --color=auto secure [root@node102 ~]# systemctl stop securecmdd
[root@node102 ~]# systemctl status securecmdd
● securecmdd.service - KingbaseES - sys_securecmdd daemon
Loaded: loaded (/etc/systemd/system/securecmdd.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Tue 2022-07-26 15:24:58 CST; 6s ago
Process: 1169 ExecStart=/home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_securecmdd -f /etc/.kes/securecmdd_config (code=exited, s
Main PID: 1169 (code=exited, status=0/SUCCESS) Jul 26 09:43:45 node102 systemd[1]: Started KingbaseES - sys_securecmdd daemon.
Jul 26 15:24:58 node102 systemd[1]: Stopping KingbaseES - sys_securecmdd daemon...
Jul 26 15:24:58 node102 systemd[1]: Stopped KingbaseES - sys_securecmdd daemon.

案例1: kingbase和root之间有ssh互信

1、测试kingbase和root直接ssh互信

[kingbase@node102 ~]$ ssh root@127.0.0.1
Last login: Tue Jul 26 15:51:16 2022 from 192.168.1.1
[root@node102 ~]#

2、配置sys_backup.conf

[kingbase@node102 bin]$ cat sys_backup.conf |grep -v ^$|grep -v ^#
_target_db_style="single"
_one_db_ip="127.0.0.1"
_repo_ip="127.0.0.1"
_stanza_name="kingbase"
_os_user_name="kingbase"
_repo_path="/home/kingbase/kbbr6_repo"
_repo_retention_full_count=5
_crond_full_days=7
_crond_diff_days=0
_crond_incr_days=1
_crond_full_hour=2
_crond_diff_hour=3
_crond_incr_hour=4
_band_width=0
_os_ip_cmd="/sbin/ip"
_os_rm_cmd="/bin/rm"
_os_sed_cmd="/bin/sed"
_os_grep_cmd="/bin/grep"
_single_data_dir="/data/kingbase/v8r6_c6/data"
_single_bin_dir="/opt/Kingbase/ES/V8R6_C6/Server/bin"
_single_db_user="system"
_single_db_port="54322"
_use_scmd=off
_start_fast=y
_compress_type=none
_non_archived_space=1024

2、执行sys_backup.sh init

[kingbase@node102 bin]$ ./sys_backup.sh init
./sys_backup.sh: line 1: et!/bin/bash: No such file or directory
# pre-condition: check the non-archived WAL files
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
ECDSA key fingerprint is bb:98:fe:fb:94:fc:cf:3c:99:72:7f:09:91:25:64:23.
Are you sure you want to continue connecting (yes/no)? yes
# 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)
# initial first full backup...DONE
# Initial sys_rman OK.
'sys_backup.sh start' should be executed when need back-rest feature.

=如上所示,在kingbase和root之间有ssh互信的环境下,直接可以执行备份的iniit。=

案例2: kingbase和root之间没有ssh互信

1、测试kingbase和root之间ssh互信(无互信)

[kingbase@node102 ~]$ ssh root@127.0.0.1
root@127.0.0.1's password:
Last login: Tue Jul 26 15:24:35 2022 from 127.0.0.1

2、配置sys_backup.conf

[kingbase@node102 bin]$ cat sys_backup.conf |grep -v ^$|grep -v ^#
_target_db_style="single"
_one_db_ip="127.0.0.1"
_repo_ip="127.0.0.1"
_stanza_name="kingbase"
_os_user_name="kingbase"
_repo_path="/home/kingbase/kbbr6_repo"
_repo_retention_full_count=5
_crond_full_days=7
_crond_diff_days=0
_crond_incr_days=1
_crond_full_hour=2
_crond_diff_hour=3
_crond_incr_hour=4
_band_width=0
_os_ip_cmd="/sbin/ip"
_os_rm_cmd="/bin/rm"
_os_sed_cmd="/bin/sed"
_os_grep_cmd="/bin/grep"
_single_data_dir="/data/kingbase/v8r6_c6/data"
_single_bin_dir="/opt/Kingbase/ES/V8R6_C6/Server/bin"
_single_db_user="system"
_single_db_port="54322"
_use_scmd=off
_start_fast=y
_compress_type=none
_non_archived_space=1024

3、执行sys_backup.sh init

[kingbase@node102 bin]$ ./sys_backup.sh init
# pre-condition: check the non-archived WAL files
ERROR: can not access the 127.0.0.1 /tmp/sys_rman by root

=如上所示,执行init报错。=

4、查看具体报错信息

[kingbase@node102 bin]$ sh -x sys_backup.sh init
+++ readlink -f sys_backup.sh
++ dirname /opt/Kingbase/ES/V8R6_C6/KESRealPro/V008R006C006B0013/Server/bin/sys_backup.sh
+ script_locate_folder=/opt/Kingbase/ES/V8R6_C6/KESRealPro/V008R006C006B0013/Server/bin
+ '[' '!' -f /opt/Kingbase/ES/V8R6_C6/KESRealPro/V008R006C006B0013/Server/bin/sys_backup.conf ']'
+ '[' -f /opt/Kingbase/ES/V8R6_C6/KESRealPro/V008R006C006B0013/Server/bin/sys_backup.conf ']'
......
+ '[' X1 == X0 ']'
+ ssh -t -o ConnectTimeout=30 -o PreferredAuthentications=publickey root@127.0.0.1 'ssh root@127.0.0.1 date>/dev/null 2>/dev/null'
+ _remote2local_rt=255
+ ssh -n -o ConnectTimeout=30 -o StrictHostKeyChecking=no -o PreferredAuthentications=publickey -- root@127.0.0.1 mkdir /tmp/sys_rman/
+ ssh -n -o ConnectTimeout=30 -o StrictHostKeyChecking=no -o PreferredAuthentications=publickey -- root@127.0.0.1 touch /tmp/sys_rman/_t-E_s_t
+ '[' X0 '!=' X255 ']'
+ /bin/echo 'ERROR: can not access the 127.0.0.1 /tmp/sys_rman by root'
ERROR: can not access the 127.0.0.1 /tmp/sys_rman by root
+ exit 1

5、分析sys_backup.sh脚本

如下所示:通过ssh连接后root用户创建文件。

默认的ssh认证是通过公钥方式,对于kingbase和root没有建立ssh互信的环境,则无法建立认证,所以需要

修改为password认证。

6、执行sys_backup.sh init(修改脚本后)

[kingbase@node102 bin]$ ./sys_backup.sh init
# pre-condition: check the non-archived WAL files
root@127.0.0.1's password:
root@127.0.0.1's password:
Please input password ...
root@127.0.0.1's password:
root@127.0.0.1's password: local <-> root@127.0.0.1 remote-login 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)
# 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.

=如上所示,需要输入root用户的密码后,初始化成功。=

案例3:使用securecmdd备份

secucmdd部署参考:

https://www.cnblogs.com/tiany1224/p/16302205.html

KingbaseES V8R6集群部署案例之---部署和配置securecmdd服务

1、启动securecmdd服务

[root@node102 .ssh]# systemctl start securecmdd
[root@node102 .ssh]# systemctl status securecmdd
● securecmdd.service - KingbaseES - sys_securecmdd daemon
Loaded: loaded (/etc/systemd/system/securecmdd.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2022-07-26 16:39:16 CST; 6s ago
Main PID: 15628 (sys_securecmdd)
CGroup: /system.slice/securecmdd.service
└─15628 sys_securecmdd: /home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_securecmdd -f /etc/.kes/securecmdd_config [li... Jul 26 16:39:16 node102 systemd[1]: Started KingbaseES - sys_securecmdd daemon.

2、sys_backup.conf配置

3、执行sys_backup.sh init

[kingbase@node102 bin]$ ./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)
# initial first full backup...DONE
# Initial sys_rman OK.
'sys_backup.sh start' should be executed when need back-rest feature.

=如上所示,在部署和启动了securecmdd工具后,可以直接执行备份的init。=

总结:

对于KingbaseES V8R6C6下的sys_backup.sh脚本,在通用机环境单实例下使用时,建议配置和启动securecmdd服务或配置kingbase和root之间ssh互信。

KingbaseES V8R6C6备份恢复案例之---单实例sys_baackup.sh备份的更多相关文章

  1. KingbaseES V8R3 备份恢复案例之--单实例环境sys_rman脚本备份案例

    案例说明: sys_rman是KingbaseES数据库的物理备份工具,支持数据库的全备和增量备份,由于sys_rman工具使用需要配置多个参数,对于一般用户使用不是很方便.为方便用户在Kingbas ...

  2. KingbaseES V8R6C5单实例sys_backup.sh备份案例

    ​ 案例说明: KingbaseES V8R6C5版本中使用了securecmdd工具,用于主机节点间的通讯,默认端口8890.备份工具sys_backup.sh默认使用了securecmdd工具,对 ...

  3. KingbaseES V8R6备份恢复案例之---手工清理冗余历史备份

    案例说明: 对于KingbaseES V8R6的通过sys_rman执行的物理历史备份,可以在执行备份时,备份的保留(retention)策略自动清理.不能通过手工删除备份,可以通过expire参数手 ...

  4. KingbaseES V8R6集群维护案例之--单实例数据迁移到集群案例

    案例说明: 生产环境是单实例,测试环境是集群,现需要将生产环境的数据迁移到集群中运行,本文档详细介绍了从单实例环境恢复数据到集群环境的操作步骤,可以作为生产环境迁移数据的参考. 适用版本: Kingb ...

  5. KingbaseES V8R6备份恢复案例之---同一数据库创建不同stanza备份

    案例说明: 在生产环境,有的应用需要调用数据库的sys_rman做备份,为了区分数据库自身的sys_rman备份和应用的备份,可以使用不同的stanza name创建备份.本案例介绍了,如何在King ...

  6. kingbaseES V8R6集群备份恢复案例之---备库作为repo主机执行物理备份

    ​ 案例说明: 此案例是在KingbaseES V8R6集群环境下,当主库磁盘空间不足时,执行sys_rman备份,将集群的备库节点作为repo主机,执行备份,并将备份存储在备库的磁盘空间. 集群架构 ...

  7. KingbaseES V8R6备份恢复案例之--删除test数据库后sys_backup.sh备份

    案例说明: KingbaseES V8R6通过sys_backup.sh执行物理备份,默认sys_backup.sh执行备份初始化时,需要连接test数据库进行身份的认证:在一些生产环境为了安全需求, ...

  8. KingbaseES R6 集群修改ssh端口执行sys_backup.sh备份案例

    数据库环境:** test=# select version(); version ---------------------------------------------------------- ...

  9. NBU AIX ORACLE10G RAC恢复到AIX单实例(表空间恢复)

    ln -s /usr/openv/netbackup/bin/libobk.a64 /oraclev3/product/10.2.0/lib/libobk.a不建软连接会报如下错误: using ta ...

随机推荐

  1. 从Vue源码中我学到了几点精妙方法

    话不多说,赶快试试这几个精妙方法吧!在工作中肯定会用得到. 立即执行函数 页面加载完成后只执行一次的设置函数. (function (a, b) { console.log(a, b); // 1,2 ...

  2. 《HelloGitHub》第 75 期

    兴趣是最好的老师,HelloGitHub 让你对编程感兴趣! 简介 HelloGitHub 分享 GitHub 上有趣.入门级的开源项目. https://github.com/521xueweiha ...

  3. 训练一个图像分类器demo in PyTorch【学习笔记】

    [学习源]Tutorials > Deep Learning with PyTorch: A 60 Minute Blitz > Training a Classifier   本文相当于 ...

  4. JDBC:批处理

    1.批处理: 当要执行某条SQL语句很多次时.例如,批量添加数据:使用批处理的效率要高的多. 2.如何实现批处理 实践: package com.dgd.test; import java.io.Fi ...

  5. 选择结构-扩展if-else语句和练习用if语句实现考试成绩划分

    判断语句3--if..else if...else if语句第三种格式: if...else if ...else if (判断条件1) { 执行语句1; } else if (判断条件2) { 执行 ...

  6. 攻防世界进阶区MISC ——56-60

    56.low 得到一张bmp,世纪之吻,扔进kali中,binwalk,zsteg,无果,再放进stegsolve中,虽然发现小的数据块,但是过滤通道得不到任何信息,猜测是要用脚本进行 # lsb隐写 ...

  7. 10分钟带你进入Swagger的世界,快来看一看吧

    什么是Swagger? 如下引用swagger官方的解释 Swagger is a powerful yet easy-to-use suite of API developer tools for ...

  8. linux服务器监控脚本

    #!/bin/bash #获取cpu使用率 cpuUsage=`top -n 1 | awk -F '[ %]+' 'NR==3 {print $2}'` #获取磁盘使用率 data_name=&qu ...

  9. 虚言妙诀终虚见,面试躬行是致知,Python技术面试策略与技巧实战记录

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_183 2021年,对于正在找工作的朋友来说,笼罩在新冠肺炎疫情之下,今年的就业季显得更加具有挑战性,更有意思的是,每当这个时候,各 ...

  10. SQL 字符串去除空格函数汇总

    SQL 中使用ltrim()去除左边空格 ,rtrim()去除右边空格 ,没有同时去除左右空格的函数,要去除所有空格可以用replace(字符串,' ',''),将字符串里的空格替换为空 . 例:去除 ...