KingbaseES V8R6C5单实例sys_backup.sh备份案例
案例说明:
KingbaseES V8R6C5版本中使用了securecmdd工具,用于主机节点间的通讯,默认端口8890。备份工具sys_backup.sh默认使用了securecmdd工具,对于通用机单实例环境,在执行“sys_backup.sh init”后,会调用securecmd工具连接主机节点备份,导致在执行“sys_backup.sh start”启动备份时,无法创建KINGBASECRON文件,建立cron计划任务。需要配置sys_backup.conf文件解决此问题。
本案例是在通用机的单实例环境下测试。
测试版本:
test=# select version();
version
----------------------------------------------------------------------------------------------------------------------
KingbaseES V008R006C005B0054 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit
(1 行记录)
一、模拟生产生成测试数据
test=# create database prod;
CREATE DATABASE
test=# \c prod
prod=# create table t1(id int ,name varchar(10));
CREATE TABLE
prod=# insert into t1 values(generate_series(1,10000),'usr'||generate_series(1,10000));
INSERT 0 10000
prod=# select count(*) from t1;
count
-------
10000
(1 行记录)
二、备份前的配置
1、编辑sys_backup.conf文件
[kingbase@#localhost 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/kbbr_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_054/data"
_single_bin_dir="/opt/Kingbase/ES/V8R6_054/Server/bin"
_single_db_user="system"
_single_db_port="54321"
_use_scmd=on

2、归档配置
[kingbase@#localhost data]$ cat kingbase.conf |grep -i archive_
archive_mode = on # enables archiving; off, on, or always
archive_command='export TZ=Asia/Shanghai;/opt/Kingbase/ES/V8R6_054/Server/bin/sys_rman --config /home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase archive-push %p'
#archive_timeout = 0 # force a logfile segment switch after this
#archive_cleanup_command = '' # command to execute at every restartpoint
#max_standby_archive_delay = 30s # max delay before canceling queries
test=# show archive_command ;
archive_command
-----------------------------------------------------------------------------------------------------------------------------------------
----------------
export TZ=Asia/Shanghai;/opt/Kingbase/ES/V8R6_054/Server/bin/sys_rman --config /home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase
archive-push %p
(1 行记录)
三、备份初始化(init)
[kingbase@#localhost bin]$ ./sys_backup.sh init
Please input password ...
# 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@#localhost kbbr_repo]$ cat sys_rman.conf
# Genarate by script at 20220420100146, should not change manually
[kingbase]
kb1-path=/data/kingbase/v8r6_054/data
kb1-port=54321
kb1-user=system
[global]
repo1-path=/home/kingbase/kbbr_repo
repo1-retention-full=5
log-path=/opt/Kingbase/ES/V8R6_054/Server/log
log-level-file=info
log-level-console=info
log-subprocess=y
process-max=4
#### default gz, support: gz none
compress-type=gz
compress-level=3
band-width=0
cmd-ssh=/opt/Kingbase/ES/V8R6_054/Server/bin/sys_securecmd

四、启动备份创建cron任务
1、启动备份
[kingbase@#localhost bin]$ ./sys_backup.sh start
Enable some sys_rman in crontab-daemon
Set full-backup in 7 days
Set incr-backup in 1 days
2、查看生成的cron任务执行文件
[kingbase@#localhost bin]$ ls /etc/cron.d/ -lh
总用量 12K
-rw-r--r--. 1 root root 128 4月 11 2018 0hourly
-rw-r--r--. 1 root root 108 10月 30 2018 raid-check
-rw-------. 1 root root 235 10月 31 2018 sysstat
=== 如上所示,在指定目录下无KINGBASECRON文件生成===
五、问题处理
1、配置sys_backup.conf文件
kingbase@#localhost bin]$ cat sys_backup.conf |grep use_
_use_scmd=off

2、重新执行备份初始化
[kingbase@#localhost bin]$ ./sys_backup.sh init
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:DZ21yge2aNDlVquhwFF4OWd36KwtdvmLYgrzwQILI5A.
ECDSA key fingerprint is MD5:f6:14:e3:de:0f:42:29:ed:1e:5f:66:d6:da:86:ed:ea.
Are you sure you want to continue connecting (yes/no)? yes
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:DZ21yge2aNDlVquhwFF4OWd36KwtdvmLYgrzwQILI5A.
ECDSA key fingerprint is MD5:f6:14:e3:de:0f:42:29:ed:1e:5f:66:d6:da:86:ed:ea.
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.

3、查看备份配置文件
[kingbase@#localhost kbbr_repo]$ cat sys_rman.conf
# Genarate by script at 20220420100618, should not change manually
[kingbase]
kb1-path=/data/kingbase/v8r6_054/data
kb1-port=54321
kb1-user=system
[global]
repo1-path=/home/kingbase/kbbr_repo
repo1-retention-full=5
log-path=/opt/Kingbase/ES/V8R6_054/Server/log
log-level-file=info
log-level-console=info
log-subprocess=y
process-max=4
#### default gz, support: gz none
compress-type=gz
compress-level=3
band-width=0
=== 如上所示,不再使用securecmdd作为节点间的通讯,直接使用ssh用于节点间通讯===
4、启动备份并创建cron任务
[kingbase@#localhost bin]$ ./sys_backup.sh start
Enable some sys_rman in crontab-daemon
Set full-backup in 7 days
Set incr-backup in 1 days
0 2 */7 * * kingbase /opt/Kingbase/ES/V8R6_054/Server/bin/sys_rman --config=/home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase --archive-copy --type=full backup >> /opt/Kingbase/ES/V8R6_054/Server/log/sys_rman_backup_full.log 2>&1
0 4 */1 * * kingbase /opt/Kingbase/ES/V8R6_054/Server/bin/sys_rman --config=/home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase --archive-copy --type=incr backup >> /opt/Kingbase/ES/V8R6_054/Server/log/sys_rman_backup_incr.log 2>&1
# 查看cron任务
[kingbase@#localhost bin]$ cat /etc/cron.d/KINGBASECRON
0 2 */7 * * kingbase /opt/Kingbase/ES/V8R6_054/Server/bin/sys_rman --config=/home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase --archive-copy --type=full backup >> /opt/Kingbase/ES/V8R6_054/Server/log/sys_rman_backup_full.log 2>&1
0 4 */1 * * kingbase /opt/Kingbase/ES/V8R6_054/Server/bin/sys_rman --config=/home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase --archive-copy --type=incr backup >> /opt/Kingbase/ES/V8R6_054/Server/log/sys_rman_backup_incr.log 2>&1
5、查看备份信息
[kingbase@#localhost bin]$ ./sys_rman --stanza=kingbase --config=/home/kingbase/kbbr_repo/sys_rman.conf info stanza: kingbase
status: ok
cipher: none
db (current)
wal archive min/max (V008R006C005B0054): 000000010000000000000004/000000010000000000000005
full backup: 20220420-100622F
timestamp start/stop: 2022-04-20 10:06:22 / 2022-04-20 10:06:25
wal start/stop: 000000010000000000000005 / 000000010000000000000005
database size: 78.3MB, database backup size: 78.3MB
repo1: backup set size: 9MB, backup size: 9MB
[kingbase@#localhost bin]$ ./sys_rman --stanza=kingbase --config=/home/kingbase/kbbr_repo/sys_rman.conf check
2022-04-20 10:17:43.328 P00 INFO: check command begin 2.27: --config=/home/kingbase/kbbr_repo/sys_rman.conf --exec-id=22425-af209cdf --kb1-path=/data/kingbase/v8r6_054/data --kb1-port=54321 --kb1-user=system --log-level-console=info --log-level-file=info --log-path=/opt/Kingbase/ES/V8R6_054/Server/log --log-subprocess --repo1-path=/home/kingbase/kbbr_repo --stanza=kingbase
2022-04-20 10:17:44.453 P00 INFO: check repo1 configuration (primary)
2022-04-20 10:17:44.958 P00 INFO: check repo1 archive for WAL (primary)
2022-04-20 10:17:45.059 P00 INFO: WAL segment 000000010000000000000006 successfully archived to '/home/kingbase/kbbr_repo/archive/kingbase/12-1/0000000100000000/000000010000000000000006-487da779cc4fcf6822f6d6c82116b1823700471e.gz' on repo1
2022-04-20 10:17:45.059 P00 INFO: check command end: completed successfully (1738ms)
KingbaseES V8R6C5单实例sys_backup.sh备份案例的更多相关文章
- KingbaseES V8R6C6备份恢复案例之---单实例sys_baackup.sh备份
案例说明: KingbaseES V8R6C6中sys_backup.sh在通用机单实例环境,默认需要通过securecmdd工具以及kingbase和root用户之间的ssh互信,执行备份初始化(i ...
- KingbaseES R6 集群修改ssh端口执行sys_backup.sh备份案例
数据库环境:** test=# select version(); version ---------------------------------------------------------- ...
- KingbaseES V8R6单实例外部备份故障案例
案例说明: 在KingbaseES V8R6单实例环境,配置外部备份服务器使用sys_backup.sh物理备份时,出现以下"WAL segment xxx was not archived ...
- KingbaseES V8R6单实例外部备份案例
案例说明: 本案例采用sys_backup.sh执行物理备份,备份使用如下逻辑架构:数据库主机采用CentOS 7系统,repo采用kylin V10 Server. 单实例+外部备份服务器 备份逻辑 ...
- KingbaseES V8R6备份恢复案例之--删除test数据库后sys_backup.sh备份
案例说明: KingbaseES V8R6通过sys_backup.sh执行物理备份,默认sys_backup.sh执行备份初始化时,需要连接test数据库进行身份的认证:在一些生产环境为了安全需求, ...
- kingbaseES R3 集群备库转换为单实例库案例
案例说明: 在生产环境需要将集群中架构转换为单实例环境,本案例以备库转换为单实例库为案例,介绍了两种方案,一种在数据库数据量小的环境下采用 sys_dumpall 导出导入方式建立单实例库:另外一种是 ...
- Oracle RAC备份异机单实例恢复演练
本文只节选了操作方案的部分章节: 3. 操作步骤 3.1. 异机单实例Oracle数据库软件安装 在异机上进行单实例Oracle数据库软件安装.该步骤过程不再本文中重复描述,如果对安装过程存在疑问 ...
- 【RAC】将单实例备份集恢复为rac数据库
[RAC]将单实例备份集恢复为rac数据库 一.1 BLOG文档结构图 一.2 前言部分 一.2.1 导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识, ...
- KingbaseES V8R6C5B041 sys_backup.sh单实例备份案例
数据库版本: test=# select version(); version ---------------------------------------------------------- ...
随机推荐
- SAP BOM 读取
1.查找 物料号.工厂.物料描述. 表:MARA MARC MAKT 逻辑: 输入物料(选择选项)中的物料编号(MARA-MATNR)和 输入工厂(选择选项 ...
- gitlab备份迁移与升级
升级计划: https://docs.gitlab.com/ee/update/index.html#upgrade-paths 1. 安装gitlab(和源版本必须保持一致) wget https: ...
- ArrayList分析1-循环、扩容、版本
ArrayList分析1-循环.扩容.版本 转载请注明出处 https://www.cnblogs.com/funnyzpc/p/16407733.html 前段时间抽空看了下ArrayList的源码 ...
- 【转载】vscode配置C/C++环境
VScode中配置 C/C++ 环境 Tip:请在电脑端查看 @零流@火星动力猿 2022.4.12 1. 下载编辑器VScode 官网:https://code.visualstudio.com/( ...
- Codeforces Round #804 (Div. 2)
题目链接 A The Third Three Number Problem 题意 给你一个n,让你求满足的a,b,c. 如果不存在则输出-1. 思路 显然任意a,b,c是不可能得到奇数. 只考虑偶数 ...
- Neural Networks
神经网络能够使用torch.nn包构建神经网络. 现在你已经对autogard有了初步的了解,nn基于autograd来定义模型并进行微分.一个nn.Module包含层,和一个forward(inpu ...
- 交替方向乘子法(Alternating Direction Multiplier Method,ADMM)
交替方向乘子法(Alternating Direction Multiplier Method,ADMM)是一种求解具有可分结构的凸优化问题的重要方法,其最早由Gabay和Mercier于1967年提 ...
- 利用MATLAB仿真最小发射功率下WSN的连通性和覆盖率
一.目的 (1)在固定节点个数的前提下,仿真求得使网络保持连通的最小通信半径(最低能级). (2)在上述节点个数和通信半径的前提下,计算随机布撒的节点的覆盖率. 二.方法描述 (1)首先假设通信半径都 ...
- 20170622日行一记之PHP函数
fread() 函数读取文件(可安全用于二进制文件) fread(file,length) 参数 描述 file 必需.规定要读取打开文件. length 必需.规定要读取的最大字节数. 该函数在读取 ...
- 用js获取当前页面的url
1.获取当前或者指定页面的文件名或路径 window.location.pathname 2.设置或获取整个URl字符串 window.location.href 3.设置或获取URL相关的端口号 w ...