kingbaseES V8R6集群备份恢复案例之---备库作为repo主机执行物理备份
作者:互联网
案例说明:
此案例是在KingbaseES V8R6集群环境下,当主库磁盘空间不足时,执行sys_rman备份,将集群的备库节点作为repo主机,执行备份,并将备份存储在备库的磁盘空间。
集群架构状态:
[kingbase@node102 bin]$ ./repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+---------+---------+-----------+----------+----------+----------+----------+----------------------------------------------------------------------------------------------------------------------------------------------------
1 | node101 | primary | * running | | default | 100 | 3 | host=192.168.1.101 user=system dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2 | node102 | standby | running | node101 | default | 100 | 3 | host=192.168.1.102 user=system dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
主机节点信息:
适用版本:
KingbaseES V8R6
一、在repo主机配置sys_backup.conf
[kingbase@node102 bin]$ cat sys_backup.conf |grep -v ^$|grep -v ^#
_target_db_style="cluster"
_one_db_ip="192.168.1.101"
_repo_ip="192.168.1.102"
_stanza_name="kingbase"
_os_user_name="kingbase"
_repo_path="/home/kingbase/kbbr2_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="/home/kingbase/cluster/R6HA/kha/kingbase/data"
_single_bin_dir="/home/kingbase/cluster/R6HA/kha/kingbase/bin"
_single_db_user="system"
_single_db_port="54321"
_use_scmd=on
二、在repo主机执行初始化
[kingbase@node102 bin]$ ./sys_backup.sh init
# 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.
三、查看主备库sys_rman配置文件
# 备库(repo主机)
[kingbase@node102 bin]$ cat /home/kingbase/kbbr2_repo/sys_rman.conf
# Genarate by script at 20220714154403, should not change manually
[kingbase]
kb1-path=/home/kingbase/cluster/R6HA/kha/kingbase/data
kb1-port=54321
kb1-user=system
kb2-path=/home/kingbase/cluster/R6HA/kha/kingbase/data
kb2-port=54321
kb2-user=system
kb2-host=192.168.1.101
kb2-host-user=kingbase
[global]
repo1-path=/home/kingbase/kbbr2_repo
repo1-retention-full=5
log-path=/home/kingbase/cluster/R6HA/kha/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
band-width=0
cmd-ssh=/home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_securecmd
# 主库:
[kingbase@node101 bin]$ cd ~/kbbr2_repo/
[kingbase@node101 kbbr2_repo]$ cat sys_rman.conf
# Genarate by script at 20220714154413, should not change manually
[kingbase]
kb1-path=/home/kingbase/cluster/R6HA/kha/kingbase/data
[global]
repo1-host=192.168.1.102
repo1-host-user=kingbase
repo1-host-config=/home/kingbase/kbbr2_repo/sys_rman.conf
repo1-path=/home/kingbase/kbbr2_repo
log-path=/home/kingbase/cluster/R6HA/kha/kingbase/log
log-level-file=info
log-level-console=info
log-subprocess=y
band-width=0
cmd-ssh=/home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_securecmd
四、创建备份执行计划
[kingbase@node102 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 /home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_rman --config=/home/kingbase/kbbr2_repo/sys_rman.conf --stanza=kingbase --archive-copy --type=full backup >> /home/kingbase/cluster/R6HA/kha/kingbase/log/sys_rman_backup_full.log 2>&1
0 4 */1 * * kingbase /home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_rman --config=/home/kingbase/kbbr2_repo/sys_rman.conf --stanza=kingbase --archive-copy --type=incr backup >> /home/kingbase/cluster/R6HA/kha/kingbase/log/sys_rman_backup_incr.log 2>&1
五、备份测试
[kingbase@node102 bin]$ /home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_rman --config=/home/kingbase/kbbr2_repo/sys_rman.conf --stanza=kingbase --archive-copy --type=full backup
2022-07-14 15:53:01.160 P00 INFO: backup command begin 2.27: --archive-copy --band-width=0 --cmd-ssh=/home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_securecmd --compress-level=3 --compress-type=gz --config=/home/kingbase/kbbr2_repo/sys_rman.conf --exec-id=15493-7a6df7ff --kb2-host=192.168.1.101 --kb2-host-user=kingbase --kb1-path=/home/kingbase/cluster/R6HA/kha/kingbase/data --kb2-path=/home/kingbase/cluster/R6HA/kha/kingbase/data --kb1-port=54321 --kb2-port=54321 --kb1-user=system --kb2-user=system --log-level-console=info --log-level-file=info --log-path=/home/kingbase/cluster/R6HA/kha/kingbase/log --log-subprocess --process-max=4 --repo1-path=/home/kingbase/kbbr2_repo --repo1-retention-full=5 --stanza=kingbase --type=full
2022-07-14 15:53:04.049 P00 INFO: execute non-exclusive sys_start_backup(): backup begins after the next regular checkpoint completes
2022-07-14 15:53:04.572 P00 INFO: backup start archive = 000000030000000000000086, lsn = 0/86000028
2022-07-14 15:53:08.416 P04 INFO: backup file 192.168.1.101:/home/kingbase/cluster/R6HA/kha/kingbase/data/base/33158/2618 (1.4MB, 0%) checksum e9f6f47bab0ecdf181daaf4ca3e8c8ace1b8cb19
2022-07-14 15:53:08.644 P03 INFO: backup file 192.168.1.101:/home/kingbase/cluster/R6HA/kha/kingbase/data/base/32782/32783 (4.2MB, 1%) checksum c7127198b551567f2558772036e57782b2fd0c12
.......
2022-07-14 15:53:31.656 P02 INFO: backup file 192.168.1.101:/home/kingbase/cluster/R6HA/kha/kingbase/data/.wallet/tspkey.kr (0B, 100%)
2022-07-14 15:53:31.661 P00 INFO: execute non-exclusive sys_stop_backup() and wait for all WAL segments to archive
2022-07-14 15:53:31.882 P00 INFO: backup stop archive = 000000030000000000000086, lsn = 0/86000128
2022-07-14 15:53:31.954 P00 INFO: check archive for segment(s) 000000030000000000000086:000000030000000000000086
2022-07-14 15:53:33.235 P00 INFO: new backup label = 20220714-155307F
2022-07-14 15:53:34.135 P00 INFO: full backup size = 378.1MB, file total = 6345
2022-07-14 15:53:34.136 P00 INFO: backup command end: completed successfully (32980ms)
2022-07-14 15:53:34.136 P00 INFO: expire command begin 2.27: --config=/home/kingbase/kbbr2_repo/sys_rman.conf --exec-id=15493-7a6df7ff --log-level-console=info --log-level-file=info --log-path=/home/kingbase/cluster/R6HA/kha/kingbase/log --repo1-path=/home/kingbase/kbbr2_repo --repo1-retention-full=5 --stanza=kingbase
2022-07-14 15:53:34.150 P00 INFO: expire command end: completed successfully (14ms)
#查看sys_log日志:
2022-07-14 15:53:07.573 P00 INFO: archive-push command begin 2.27: [sys_wal/000000030000000000000085] --cmd-ssh=/home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_securecmd --config=/home/kingbase/kbbr2_repo/sys_rman.conf --exec-id=27339-d8902e1f --kb1-path=/home/kingbase/cluster/R6HA/kha/kingbase/data --log-level-console=info --log-level-file=info --log-path=/home/kingbase/cluster/R6HA/kha/kingbase/log --log-subprocess --repo1-host=192.168.1.102 --repo1-host-config=/home/kingbase/kbbr2_repo/sys_rman.conf --repo1-host-user=kingbase --repo1-path=/home/kingbase/kbbr2_repo --stanza=kingbase
2022-07-14 15:53:08.685 P00 INFO: pushed WAL file '000000030000000000000085' to the archive
2022-07-14 15:53:08.787 P00 INFO: archive-push command end: completed successfully (1222ms)
2022-07-14 15:53:35.166 P00 INFO: archive-push command begin 2.27: [sys_wal/000000030000000000000086] --cmd-ssh=/home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_securecmd --config=/home/kingbase/kbbr2_repo/sys_rman.conf --exec-id=27616-b01c4eab --kb1-path=/home/kingbase/cluster/R6HA/kha/kingbase/data --log-level-console=info --log-level-file=info --log-path=/home/kingbase/cluster/R6HA/kha/kingbase/log --log-subprocess --repo1-host=192.168.1.102 --repo1-host-config=/home/kingbase/kbbr2_repo/sys_rman.conf --repo1-host-user=kingbase --repo1-path=/home/kingbase/kbbr2_repo --stanza=kingbase
2022-07-14 15:53:36.398 P00 INFO: pushed WAL file '000000030000000000000086' to the archive
2022-07-14 15:53:36.498 P00 INFO: archive-push command end: completed successfully (1351ms)
2022-07-14 15:53:36.510 P00 INFO: archive-push command begin 2.27: [sys_wal/000000030000000000000086.00000028.backup] --cmd-ssh=/home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_securecmd --config=/home/kingbase/kbbr2_repo/sys_rman.conf --exec-id=27646-f3dd0a5f --kb1-path=/home/kingbase/cluster/R6HA/kha/kingbase/data --log-level-console=info --log-level-file=info --log-path=/home/kingbase/cluster/R6HA/kha/kingbase/log --log-subprocess --repo1-host=192.168.1.102 --repo1-host-config=/home/kingbase/kbbr2_repo/sys_rman.conf --repo1-host-user=kingbase --repo1-path=/home/kingbase/kbbr2_repo --stanza=kingbase
2022-07-14 15:53:37.641 P00 INFO: pushed WAL file '000000030000000000000086.00000028.backup' to the archive
2022-07-14 15:53:37.741 P00 INFO: archive-push command end: completed successfully (1235ms)
六、查看备份
[kingbase@node102 bin]$ /home/kingbase/cluster/R6HA/kha/kingbase/bin/sys_rman --config=/home/kingbase/kbbr2_repo/sys_rman.conf --stanza=kingbase info
stanza: kingbase
status: ok
cipher: none
db (current)
wal archive min/max (V008R006C005B0041): 000000030000000000000083/000000030000000000000086
full backup: 20220714-154428F
timestamp start/stop: 2022-07-14 15:44:28 / 2022-07-14 15:44:52
wal start/stop: 000000030000000000000084 / 000000030000000000000084
database size: 394.1MB, database backup size: 394.1MB
repo1: backup set size: 30.7MB, backup size: 30.7MB
full backup: 20220714-155307F
timestamp start/stop: 2022-07-14 15:53:07 / 2022-07-14 15:53:35
wal start/stop: 000000030000000000000086 / 000000030000000000000086
database size: 394.1MB, database backup size: 394.1MB
repo1: backup set size: 30.7MB, backup size: 30.7MB
标签:sys,备库,log,--,备份,kingbase,repo,home,backup 来源: https://www.cnblogs.com/tiany1224/p/16478357.html