KingbaseES V8R6集群运维案例之---single-pro模式备份

案例说明:
KingbaseES V8R6集群物理备份配置参数_target_db_style,可选single或cluster或single-pro。 single对应单机模式的目标数据库实例,cluster对应集群模式的目标数据库实例,single-pro对应集群模式的每个DB节点独立备份。本案例详细描述集群架构在singl-pro模式下的备份。
适用版本:
KingbaseES V8R6

集群架构:

 ID | Name  | Role    | Status    | Upstream | repmgrd | PID   | Paused? | Upstream last seen
----+-------+---------+-----------+----------+---------+-------+---------+--------------------
 1  | node1 | primary | * running |          | running | 9511  | no      | n/a
 2  | node2 | standby |   running | node1    | running | 25083 | no      | 1 second(s) ago

一、主库物理备份配置

如下所示,采用‘single-pro’模式备份,数据库信息需要在配置文件中指定:

[kingbase@node101 bin]$ cat sys_backup.conf|grep -v ^#|grep -v ^$
_target_db_style="single-pro"
_one_db_ip="192.168.1.101"
_repo_ip="192.168.1.101"
_stanza_name="kingbase"
_os_user_name="kingbase"
_repo_path="/home/kingbase/kbbr8_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/hac7/data"
_single_bin_dir="/home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/bin"
_single_db_user="system"
_single_db_port="54321"
_use_scmd=off
_start_fast=y
_compress_type=none
_non_archived_space=1024

二、主库执行备份初始化
如下图所示,在初始化过程,执行‘rpmgr cluster show’获取所有集群节点信息:

如下所示,将修改集群所有节点‘archive_mode=always’,并且将重启集群所有节点(生产环境需注意!)。

[kingbase@node101 bin]$ ./sys_backup.sh init
# pre-condition: check the non-archived WAL files
# Check 192.168.1.101 archive-mode == always
# WARNING: archive-mode on 192.168.1.101 is not always
sys_backup.conf target_db_style=single-pro: require the archive-mode=always.
Yes/Y: sys_backup.sh auto set all node archive-mode=always and restart databse cluster.
No/N: abort sys_backup.sh, set archive-mode manually, execute sys_backup.sh again.
Are you sure to set all node to archive-mode=always and restart databse?[Y/n]: y
# WARNING: set archive-mode on 192.168.1.101
# WARNING: set archive-mode on 192.168.1.102
# restart the whole database cluster...
# restart the whole database cluster...DONE
# 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
# create stanza and check on 192.168.1.102 ...(maybe 60+ seconds)
# create stanza and check on 192.168.1.102 ...DONE
# initial first full backup on 192.168.1.102 ...(maybe several minutes)
# initial first full backup on 192.168.1.102 ...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.

三、检查集群节点配置
1、归档配置

#主库:
[kingbase@node101 bin]$ cat /data/kingbase/hac7/data/es_rep.conf |grep -i archive_
archive_mode=always
archive_command='export TZ=Asia/Shanghai;/home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/bin/sys_rman --config /home/kingbase/kbbr8_repo/sys_rman.conf --stanza=kingbase archive-push %p'

#备库:
[kingbase@node102 ~]$ cat /data/kingbase/hac7/data/es_rep.conf |grep -i archive_
archive_mode=always
archive_command='export TZ=Asia/Shanghai;/home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/bin/sys_rman --config /home/kingbase/kbbr8_repo/sys_rman.conf --stanza=kingbase archive-push %p'

2、查看节点repo-path配置

主库:
[kingbase@node101 ~]$ ls -lh kbbr8_repo/
total 4.0K
drwxr-x--- 3 kingbase kingbase  21 Jul 14 15:04 archive
drwxr-x--- 3 kingbase kingbase  21 Jul 14 15:04 backup
-rw-r--r-- 1 kingbase kingbase 854 Jul 14 15:04 sys_rman.conf
备库:
[kingbase@node102 ~]$  ls -lh kbbr8_repo/
total 4.0K
drwxr-x--- 3 kingbase kingbase  21 Jul 14 15:04 archive
drwxr-x--- 3 kingbase kingbase  21 Jul 14 15:04 backup
-rw-rw-r-- 1 kingbase kingbase 621 Jul 14 15:04 sys_rman.conf

3、在主库执行初始化后,主备库节点都执行全量备份

主库:
[kingbase@node101 kbbr8_repo]$ /home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/bin/sys_rman --config=/home/kingbase/kbbr8_repo/sys_rman.conf --stanza=kingbase info
stanza: kingbase
    status: ok
    cipher: none
    db (current)
        wal archive min/max (V008R006C007B0012): 0000001400000001000000CD/0000001400000001000000D2

        full backup: 20230714-150404F
            timestamp start/stop: 2023-07-14 15:04:04 / 2023-07-14 15:04:10
            wal start/stop: 0000001400000001000000CE / 0000001400000001000000CF
            database size: 1.2GB, database backup size: 1.2GB
            repo1: backup set size: 1.2GB, backup size: 1.2GB

备库:
[kingbase@node102 ~]$ /home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/bin/sys_rman --config=/home/kingbase/kbbr8_repo/sys_rman.conf --stanza=kingbase info
stanza: kingbase
    status: ok
    cipher: none
    db (current)
        wal archive min/max (V008R006C007B0012): 0000001400000001000000CD/0000001400000001000000D2

        full backup: 20230714-150436F
            timestamp start/stop: 2023-07-14 15:04:36 / 2023-07-14 15:04:48
            wal start/stop: 0000001400000001000000D2 / 0000001400000001000000D2
            database size: 1.1GB, database backup size: 1.1GB
            repo2: backup set size: 1.1GB, backup size: 1.1GB

四、主库启动备份

1、执行sys_backup.sh start

[kingbase@node101 bin]$ ./sys_backup.sh start
# pre-condition: check the non-archived WAL files
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/ha7/kingbase/kingbase/bin/sys_rman --config=/home/kingbase/kbbr8_repo/sys_rman.conf --stanza=kingbase --archive-copy --type=full backup >> /home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/log/sys_rman_backup_full.log 2>&1
0 4 */1 * * kingbase /home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/bin/sys_rman --config=/home/kingbase/kbbr8_repo/sys_rman.conf --stanza=kingbase --archive-copy --type=incr backup >> /home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/log/sys_rman_backup_incr.log 2>&1

2、主库建立crond备份任务

[kingbase@node101 bin]$ cat /etc/cron.d/KINGBASECRON

0 2 */7 * * kingbase /home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/bin/sys_rman --config=/home/kingbase/kbbr8_repo/sys_rman.conf --stanza=kingbase --archive-copy --type=full backup >> /home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/log/sys_rman_backup_full.log 2>&1
0 4 */1 * * kingbase /home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/bin/sys_rman --config=/home/kingbase/kbbr8_repo/sys_rman.conf --stanza=kingbase --archive-copy --type=incr backup >> /home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/log/sys_rman_backup_incr.log 2>&1

3、查看备库crond备份任务
检查发现在备库并没有创建crond的备份任务。

五、总结

集群架构下,支持在每个节点单独执行single-pro模式执行物理备份,相比single模式有以下特点:

1、只需要在集群任意一个节点配置sys_backup.conf,并执行初始化。
2、每个节点都会作为repo节点,并创建repo存储目录和相关配置。
3、初始化后,每个节点都会执行一次全量备份。
4、初始化后,将修改每个节点的archive_mode为always,每个节点都将会产生归档日志。
5、每个节点需要单独执行sys_backup.sh start | stop。
posted @ 2024-04-01 15:32  KINGBASE研究院  阅读(112)  评论(0编辑  收藏  举报