openGauss作为一款高性能、高可靠的开源数据库系统,支持全量备份和增量备份,以满足不同场景下的数据保护需求。本文将详细介绍openGauss的增量备份与恢复的实现方法,并提供详细的实现代码、配置说明以及如何实现定时触发增量备份操作。
0、前言
查看磁盘信息
通过df -lh
命令查看
我这里将备份数据到<font style="color:rgb(18, 18, 18);">/media/user/D</font>
盘符下。
查看系统信息
通过<font style="color:rgb(18, 18, 18);">cat /etc/os-release</font>
命令查看
查看CPU架构信息
通过<font style="color:rgb(18, 18, 18);">lscpu</font>
命令查看
一、openGauss增量备份概述
openGauss的增量备份通过gs_probackup
工具实现。gs_probackup
是openGauss提供的一个独立的二进制程序,支持全量备份、增量备份、对备份元数据进行管理、设置备份的留存策略、合并增量备份、删除过期备份等功能。
二、增量备份配置与实现
1. 配置参数
在openGauss中,要启用增量备份,需要在postgresql.conf
配置文件中添加参数enable_cbm_tracking = on
。这个参数用于启动数据库服务器对脏页数据修改的跟踪。
执行<font style="color:rgb(18, 18, 18);">gsql -d postgres -p 5432 -r</font>
命令登录数据库,修改配置文件。
# 修改postgresql.conf
alter system set enable_cbm_tracking = on;
select pg_reload_conf();
执行完上面SQL代码后再次查看postgresql.conf
配置文件,发现已经添加enable_cbm_tracking = on
配置。
2. 初始化备份目录和实例
使用gs_probackup
工具初始化备份目录和实例:
# 初始化备份目录
gs_probackup init -B /media/user/D/gs_backup/increment
# 添加备份实例
gs_probackup add-instance -B /media/user/D/gs_backup/increment -D /media/user/D/datanode/gsdn --instance=rscnode
3. 备份命令与参数解释
创建全量备份
# 创建全量备份
gs_probackup backup -B /media/user/D/gs_backup/increment --instance=rscnode -b full -d electric
参数说明:
-B /media/user/D/gs_backup/increment
:指定备份路径。--instance=rscnode
:指定备份实例。-b full
:指定备份模式为全量备份。-d electric
:指定要备份的数据库名
上面的命令执行后会输出如下信息:
omm@user-pc:/media/user/D/datanode/gsdn$ gs_probackup backup -B /media/user/D/gs_backup/increment --instance=rscnode -b full -d electric
INFO: Backup start, gs_probackup version: 2.4.2, instance: rscnode, backup ID: SJMVRR, backup mode: FULL, wal mode: STREAM, remote: false, compress-algorithm: none, compress-level: 1
LOG: Backup destination is initialized
LOG: This openGauss instance was initialized with data block checksums. Data block corruption will be detected
LOG: Database backup start
LOG: started streaming WAL at 6/9F000000 (timeline 1)
[2024-09-11 13:40:44]: check identify system success
[2024-09-11 13:40:44]: send START_REPLICATION 6/9F000000 success
[2024-09-11 13:40:44]: keepalive message is received
[2024-09-11 13:40:44]: keepalive message is received
INFO: PGDATA size: 13GB
INFO: Start backing up files
LOG: Creating page header map "/media/user/D/gs_backup/increment/backups/rscnode/SJMVRR/page_header_map"
[2024-09-11 13:40:49]: keepalive message is received
[2024-09-11 13:40:54]: keepalive message is received ] 42% (2653/6221, done_files/t
[2024-09-11 13:40:59]: keepalive message is received
[2024-09-11 13:41:04]: keepalive message is received ]
[2024-09-11 13:41:09]: keepalive message is received
[2024-09-11 13:41:14]: keepalive message is received
[2024-09-11 13:41:19]: keepalive message is received backup file
[2024-09-11 13:41:24]: keepalive message is received
[2024-09-11 13:41:29]: keepalive message is received==== ] 90% (5626/6221, done_files/to
[2024-09-11 13:41:34]: keepalive message is received
[2024-09-11 13:41:39]: keepalive message is received===== ]
[2024-09-11 13:41:45]: keepalive message is received
[2024-09-11 13:41:50]: keepalive message is received
[2024-09-11 13:41:55]: keepalive message is received ackup file
[2024-09-11 13:42:00]: keepalive message is received
[2024-0
标签:11,13,备份,09,2024,详解,openGauss,message
From: https://blog.csdn.net/u010490822/article/details/142141197