案例说明:

本案例采用sys_backup.sh执行物理备份,备份使用如下逻辑架构:集群采用CentOS 7系统,repo采用kylin V10 Server。

  • 一主一备+外部备份

    此场景为主备双机常规环境设计,主要的备份信息来源于备机,极大地减少备份为主机带来的性能损耗,且增加了第三方专用存储服务器,用于存放和管理备份文件。

  • 集群节点信息:

[kingbase@node2 bin]$ ./repmgr cluster show

 ID | Name    | Role    | Status    | Upstream | Location | Priority | Timeline | Connection string
----+---------+---------+-----------+----------+----------+----------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------
1 | node200 | primary | * running | | default | 100 | 11 | host=192.168.8.200 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2 | node201 | standby | running | node200 | default | 100 | 11 | host=192.168.8.201 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
  • 数据库版本:
test=# select version();
version
------------------------------------------------------------------------------------------------------------------
KingbaseES V008R006C005B0023 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit
(1 row)

一、备份环境配置

1、首先建立repo和集群节点之间的ssh互信(kingbase和root用户)

[kingbase@srv01 bin]$ uname -a
Linux srv01 4.19.90-17.ky10.x86_64 #1 SMP Sun Jun 28 15:41:49 CST 2020 x86_64 x86_64 x86_64 GNU/Linux
[kingbase@srv01 bin]$ ssh node1
Last login: Mon May 30 21:21:11 2022
[kingbase@node1 ~]$ [root@srv01 ~]# ssh node1
Last login: Mon May 30 21:42:32 2022 from 192.168.8.100
[root@node1 ~]#

2、在repo节点建立备份相关的目录及文件(不需要安装数据库软件)

=注意:目录结构和集群节点尽量一致,并且保证sys_backup.sh能在repo节点正常执行。=

[kingbase@srv01 ~]$ mkdir -p /home/kingbase/cluster/R6C/R6HA/kingbase/

[kingbase@node2 R6HA]$ scp db.zip srv01:/home/kingbase/cluster/R6C/R6HA/kingbase/

# 将集群db.zip拷贝到repo主机后,解压
[kingbase@srv01 kingbase]$ ls -lh
total 145M
drwxr-xr-x 2 kingbase kingbase 4.0K Nov 5 2021 bin
-rwx------ 1 kingbase kingbase 145M May 31 12:21 db.zip
drwxrwxr-x 5 kingbase kingbase 8.0K Nov 5 2021 lib
drwxrwxr-x 8 kingbase kingbase 4.0K Nov 5 2021 share

二、初始化备份配置

1、在集群主备节点配置archive

=archive_command在配置文件未被注释时,执行sys_backup.sh init会自动配置=

主库:
[kingbase@node1 data]$ cat es_rep.conf |grep -i archive_
archive_mode='on'
archive_command='/home/kingbase/cluster/R6C/R6HA/kingbase/bin/sys_rman --config /home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase archive-push %p'
备库:
[kingbase@node2 data]$ cat es_rep.conf |grep -i archive_
archive_mode='on'
archive_command='/home/kingbase/cluster/R6C/R6HA/kingbase/bin/sys_rman --config /home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase archive-push %p'

2、在repo下配置sys_backup.conf文件

[kingbase@srv01 bin]$ cat sys_backup.conf |grep -v ^$|grep -v ^#
_target_db_style="cluster"
_one_db_ip="192.168.8.201"
_repo_ip="192.168.8.100"
_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
_os_ip_cmd="/sbin/ip"
_os_rm_cmd="/bin/rm"
_os_sed_cmd="/bin/sed"
_os_grep_cmd="/bin/grep"
_single_data_dir="/home/kingbase/ES/V8_single/data"
_single_bin_dir="/home/kingbase/ES/V8_single/Server/bin"
_single_db_user="system"
_single_db_port="54321"

3、执行sys_backup.sh初始化

[kingbase@srv01 bin]$ ./sys_backup.sh init

The authenticity of host '192.168.8.100 (192.168.8.100)' can't be established.
ECDSA key fingerprint is SHA256:H2wsGtepOaejo4bY8srjnztqrZY/dZosWLDf6m8oUs8.
Are you sure you want to continue connecting (yes/no)? yes
The authenticity of host '192.168.8.100 (192.168.8.100)' can't be established.
ECDSA key fingerprint is SHA256:H2wsGtepOaejo4bY8srjnztqrZY/dZosWLDf6m8oUs8.
Are you sure you want to continue connecting (yes/no)? yes
# generate local sys_rman.conf...DONE
# update all node: sys_rman.conf and archive_command with sys_rman.archive-push...
# update all node: sys_rman.conf and 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.
'sys_backup.sh start' will add CRONTAB items.
Or you can manual backup once with user-guide.

4、查看初始化配置后的信息

=注意:对于repo的存储目录,在repo和集群数据节点都会创建,只创建sys_rman.conf,备份存储在备份服务器上。=

[kingbase@srv01 ~]$ cd kbbr_repo/
[kingbase@srv01 kbbr_repo]$ cat sys_rman.conf # Genarate by script at 20220531122517, should not change manually
[kingbase]
kb1-path=/home/kingbase/cluster/R6C/R6HA/kingbase/data
kb1-port=54321
kb1-user=esrep
kb1-host=192.168.8.200
kb1-host-user=kingbase
kb2-path=/home/kingbase/cluster/R6C/R6HA/kingbase/data
kb2-port=54321
kb2-user=esrep
kb2-host=192.168.8.201
kb2-host-user=kingbase [global]
repo1-path=/home/kingbase/kbbr_repo
repo1-retention-full=5
log-path=/home/kingbase/cluster/R6C/R6HA/kingbase/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 在集群节点查看: # 主库:
[kingbase@node1 ~]$ cd kbbr_repo/
[kingbase@node1 kbbr_repo]$ cat sys_rman.conf
# Genarate by script at 20220531122523, should not change manually
[kingbase]
kb1-path=/home/kingbase/cluster/R6C/R6HA/kingbase/data
[global]
repo1-host=192.168.8.100
repo1-host-user=kingbase
repo1-host-config=/home/kingbase/kbbr_repo/sys_rman.conf
repo1-path=/home/kingbase/kbbr_repo
log-path=/home/kingbase/cluster/R6C/R6HA/kingbase/log
log-level-console=info
log-level-file=info #备库:
[kingbase@node2 ~]$ cd kbbr_repo
[kingbase@node2 kbbr_repo]$ cat sys_rman.conf
# Genarate by script at 20220531122526, should not change manually
[kingbase]
kb1-path=/home/kingbase/cluster/R6C/R6HA/kingbase/data
[global]
repo1-host=192.168.8.100
repo1-host-user=kingbase
repo1-host-config=/home/kingbase/kbbr_repo/sys_rman.conf
repo1-path=/home/kingbase/kbbr_repo
log-path=/home/kingbase/cluster/R6C/R6HA/kingbase/log
log-level-console=info
log-level-file=info

5、初始化的归档和数据库备份信息

1)归档信息

2)数据库信息

3)查看主库wal日志信息

=由以上信息,可知,初始化产生备份主要是在主库上执行了 sys_rman的备份。=

三、执行备份

1、创建备份计划任务

[kingbase@srv01 bin]$ ./sys_backup.sh start
Enable some sys_rman in crontab-daemon
Authorized users only. All activities may be monitored and reported.
Set full-backup in 7 days
Authorized users only. All activities may be monitored and reported.
Authorized users only. All activities may be monitored and reported.
Authorized users only. All activities may be monitored and reported.
Set incr-backup in 1 days
Authorized users only. All activities may be monitored and reported.
Authorized users only. All activities may be monitored and reported.
0 2 */7 * * kingbase /home/kingbase/cluster/R6C/R6HA/kingbase/bin/sys_rman --config=/home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase --archive-copy --type=full backup >> /home/kingbase/cluster/R6C/R6HA/kingbase/log/sys_rman_backup_full.log 2>&1
0 4 */1 * * kingbase /home/kingbase/cluster/R6C/R6HA/kingbase/bin/sys_rman --config=/home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase --archive-copy --type=incr backup >> /home/kingbase/cluster/R6C/R6HA/kingbase/log/sys_rman_backup_incr.log 2>&1

2、手工测试sys_rman备份

[kingbase@srv01 bin]$ /home/kingbase/cluster/R6C/R6HA/kingbase/bin/sys_rman --config=/home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase --archive-copy --type=full backup
......
2022-05-31 12:49:46.041 P04 INFO: backup file 192.168.8.200:/home/kingbase/cluster/R6C/R6HA/kingbase/data/.wallet/tbcolkey.kr (0B, 100%)
2022-05-31 12:49:46.045 P00 INFO: full backup size = 138.2MB
2022-05-31 12:49:46.045 P00 INFO: execute non-exclusive sys_stop_backup() and wait for all WAL segments to archive
2022-05-31 12:49:46.857 P00 INFO: backup stop archive = 0000000B000000010000005B, lsn = 1/5B000128
2022-05-31 12:49:47.558 P00 INFO: check archive for segment(s) 0000000B000000010000005B:0000000B000000010000005B
2022-05-31 12:49:48.930 P00 INFO: new backup label = 20220530-212601F
2022-05-31 12:49:50.223 P00 INFO: backup command end: completed successfully (294166ms)
2022-05-31 12:49:50.224 P00 INFO: expire command begin 2.27: --config=/home/kingbase/kbbr_repo/sys_rman.conf --log-level-console=info --log-level-file=info --log-path=/home/kingbase/cluster/R6C/R6HA/kingbase/log --log-subprocess --kb1-host=192.168.8.200 --kb2-host=192.168.8.201 --kb1-host-user=kingbase --kb2-host-user=kingbase --repo1-path=/home/kingbase/kbbr_repo --repo1-retention-full=5 --stanza=kingbase
2022-05-31 12:49:52.011 P00 INFO: expire command end: completed successfully (1787ms)

3、查看sys_rman备份信息

[kingbase@srv01 bin]$ /home/kingbase/cluster/R6C/R6HA/kingbase/bin/sys_rman --config=/home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase  info
stanza: kingbase
status: ok
cipher: none db (current)
wal archive min/max (V008R006C005B0023-1): 0000000B0000000100000058/0000000B000000010000005B full backup: 20220530-210642F
timestamp start/stop: 2022-05-30 21:06:42 / 2022-05-30 21:12:08
wal start/stop: 0000000B0000000100000059 / 0000000B0000000100000059
database size: 144.2MB, backup size: 144.2MB
repository size: 15.9MB, repository backup size: 15.9MB full backup: 20220530-212601F
timestamp start/stop: 2022-05-30 21:26:01 / 2022-05-30 21:30:50
wal start/stop: 0000000B000000010000005B / 0000000B000000010000005B
database size: 154.2MB, backup size: 154.2MB
repository size: 16.6MB, repository backup size: 16.6MB

四、总结

对于KingbaseES V8R6集群使用sys_backup.sh执行物理备份,可以使用专门的备份服务器repo,备份的操作在repo上,但实际上还是通过调用sys_rman在集群节点上完成物理备份。

KingbaseES V8R6集群外部备份案例的更多相关文章

  1. KingbaseES V8R6单实例外部备份案例

    案例说明: 本案例采用sys_backup.sh执行物理备份,备份使用如下逻辑架构:数据库主机采用CentOS 7系统,repo采用kylin V10 Server. 单实例+外部备份服务器 备份逻辑 ...

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

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

  3. KingbaseES V8R6集群维护之--修改数据库服务端口案例

    ​ 案例说明: 对于KingbaseES数据库单实例环境,只需要修改kingbase.conf文件的'port'参数即可,但是对于KingbaseES V8R6集群中涉及到多个配置文件的修改,并且在应 ...

  4. KingbaseES V8R6集群维护案例之---停用集群node_export进程

    案例说明: 在KingbaseES V8R6集群启动时,会启动node_exporter进程,此进程主要用于向kmonitor监控服务输出节点状态信息.在系统安全漏洞扫描中,提示出现以下安全漏洞: 对 ...

  5. KingbaseES V8R6集群管理运维案例之---repmgr standby switchover故障

    案例说明: 在KingbaseES V8R6集群备库执行"repmgr standby switchover"时,切换失败,并且在执行过程中,伴随着"repmr stan ...

  6. KingbaseES V8R6单实例外部备份故障案例

    案例说明: 在KingbaseES V8R6单实例环境,配置外部备份服务器使用sys_backup.sh物理备份时,出现以下"WAL segment xxx was not archived ...

  7. KingbaseES V8R3集群管理维护案例之---集群迁移单实例架构

    案例说明: 在生产中,需要将KingbaseES V8R3集群转换为单实例架构,可以采用以下方式快速完成集群架构的迁移. 适用版本: KingbaseES V8R3 当前数据库版本: TEST=# s ...

  8. KingbaseES V8R3集群运维案例之---主库系统down failover切换过程分析

    ​ 案例说明: KingbaseES V8R3集群failover时两个cluster都会触发,但只有一个cluster会调用脚本去执行真正的切换流程,另一个有对应的打印,但不会调用脚本,只是走相关的 ...

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

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

随机推荐

  1. SAP 定义客户端

    SCC4  定义客户端 点击新建条目按钮  Client(客户端) R 200 Client Name(客户端名称) O   City(城市) R   Logical system(逻辑系统) R   ...

  2. 嵌入式中 动态阿拉伯语字符串 转换 LCD显示字符串【感谢建国雄心】

    本文参考CSDBN:建国雄心 的博客,这里找不到该帖子,放一个类似的仅供参考https://blog.csdn.net/qiaojiongzeng6321/article/details/748572 ...

  3. POI设置列宽 自动调整列宽

    for (int i = 0; i <= totalColumn; i++) { sheet.autoSizeColumn((short)i,true); //调整列宽 } 其中totalCol ...

  4. 开发人员要学的Docker从入门到日常命令使用(通俗易懂),专业运维人员请勿点!

    一.介绍Docker  1.引言 问题1:开发人员告诉测试说自己的项目已经做好了,给你一个发布包,你去测试吧. ## 测试人员,为什么我运行会报错? ## 开发人员说,我本地运行没有问题呀!   解答 ...

  5. Tapdata 肖贝贝:实时数据引擎系列(四)-关于 Oracle 与 Oracle CDC

      摘要:想实现 Oracle 的 CDC,排除掉一些通用的比如全量比对, 标记字段获取之外, 真正的增量形式获取变更, 有三种办法: Logminer .XStream .裸日志解析,但不管哪种方法 ...

  6. 本地使用 Docker Compose 与 Nestjs 快速构建基于 Dapr 的 Redis 发布/订阅分布式应用

    Dapr(分布式应用程序运行时)介绍 Dapr 是一个可移植的.事件驱动的运行时,它使任何开发人员能够轻松构建出弹性的.无状态和有状态的应用程序,并可运行在云平台或边缘计算中,它同时也支持多种编程语言 ...

  7. 螣龙安科:威胁研究——与MAZE勒索软件事件相关的策略,技术和程序

    至少从2019年5月开始,恶意行为者就一直在积极部署MAZE勒索软件.勒索软件最初是通过垃圾邮件和漏洞利用工具包分发的,后来又转移到妥协后进行部署.根据我们在地下论坛中对涉嫌用户的观察以及整个Mand ...

  8. dynamic + shardingsphere(4.1.1) 实现动态分库分表

    1. 主要依赖: <dependency> <groupId>com.baomidou</groupId> <artifactId>dynamic-da ...

  9. 0基础就可以上手的Spark脚本开发-for Java

    前言 最近由于工作需要,要分析大几百G的Nginx日志数据.之前也有过类似的需求,但那个时候数据量不多.一次只有几百兆,或者几个G.因为数据都在Hive里面,当时的做法是:把数据从Hive导到MySQ ...

  10. 【每天学一点-04】使用脚手架搭建 React+TypeScript+umi.js+Antd 项目

    一.使用脚手架搭建项目框架 1.首先使用脚手架搭建React项目(React+TypeScript+Umi.js) 在控制台输入命令:yarn create @umijs/umi-app 2.引入An ...