简介
在 Greenplum 中,进行数据的异地备份(即将数据备份到不同的地理位置)是确保数据安全和灾难恢复的一种重要策略。
以下是几种实现 Greenplum 异地备份的几种方法:
1、使用pg_dump工具
pg_dump
是 PostgreSQL 和 Greenplum 都支持的备份工具,它可以直接将数据库数据导出到异地备份服务器,可以在其他服务器上恢复。
2、使用gpbackup
工具
Greenplum 提供了 gpbackup
和 gprestore
工具来备份和恢复数据库数据。可以使用这些工具在本地备份数据库数据,然后将这些备份文件复制到远程位置。复制方式包括ftp、sftp、scp、rsync等命令。
3、使用对象存储(如Amazon S3)
S3存储插件应用程序允许在运行gpbackup和gprestore时使用Amazon Simple Storage Service(Amazon S3)位置来存储和检索备份。Amazon S3提供安全,持久,高度可扩展的对象存储。这种方法不需要手动复制备份文件,并且可以提供更好的冗余和持久性。
☆ 对于GP的 异地备份,推荐方式3!!!
MinIO搭建S3简介
MinIO 的名称来源于 "Minimal Object Storage"(最小化对象存储)的缩写,体现了其设计理念——提供一个简单、高效的对象存储系统。名称中的 "Min" 代表 "Minimal"(最小的),而 "IO" 代表 "Input/Output"(输入/输出)。
MinIO 是一个高性能的对象存储系统,采用 Go 语言编写,设计上与 Amazon S3 兼容,支持 S3 API。MinIO 主要用于存储海量的非结构化数据,比如图片、视频、日志文件和备份等。它可以部署在本地数据中心、公有云或混合云环境中,并且通过 S3 API 实现与现有工具和应用的兼容性。
GitHub:https://github.com/minio/
官网:https://www.minio.org.cn/
官方文档:https://min.io/docs/minio/linux/index.html
对于MinIO有如下几点总结:
1、minio服务器版有Linux也有windows版,临时搭建非常方便
2、无论是Linux还是Windows,磁盘都应该先挂载
3、可以使用普罗米修斯prometheus来监控MinIO
4、若是多磁盘模式,则不会用到100%空间。若要使用所有空间,则使用LVM创建卷组,最后用一条路径即可。
5、PG备份恢复工具之pgbackrest也支持S3存储。
接下来,麦老师就给大家简单演示一下,在GreenPlum中,使用gpbackup将数据备份到S3中,然后使用gprestore从S3中进行恢复的过程。
示例
下载需要的镜像:
1docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/greenplum:6.27.0_v2
2docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/greenplum:7.3.0
3docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/minio:1.0
GP6和GP7环境准备
1-- GP6
2docker rm -f gpdb6
3docker run -itd --name gpdb6 -h gpdb6270 \
4 -v /sys/fs/cgroup:/sys/fs/cgroup \
5 --privileged=true lhrbest/greenplum:6.27.0_v2 \
6 /usr/sbin/init
7
8docker exec -it gpdb6 bash
9su - gpadmin
10gpstart -a
11gpcc start
12
13gpcc status
14gpstate
15
16[gpadmin@gpdb6270 soft]$ psql -c "select version()"
17 version
18-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
19 PostgreSQL 9.4.26 (Greenplum Database 6.27.0 build commit:482d4e839d519dcfde9cddf03807787d9d91d015) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Apr 4 2024 11:00:20
20(1 row)
21
22
23
24
25-- GP7
26docker rm -f gpdb7
27docker run -itd --name gpdb7 -h gpdb7 \
28 -v /sys/fs/cgroup:/sys/fs/cgroup \
29 --privileged=true lhrbest/greenplum:7.3.0 \
30 /usr/sbin/init
31
32docker exec -it gpdb7 bash
33su - gpadmin
34gpstart -a
35gpcc start
36
37gpcc status
38gpstate
39
40[gpadmin@gpdb7 soft]$ psql -c "select version()"
41 version
42----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
43 PostgreSQL 12.12 (Greenplum Database 7.3.0 build commit:ebf6c7db0034f8928f20252a306c4ecdb9324d81) on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22), 64-bit compiled on Aug 1 2024 08:31:42 Bhuvnesh C.
44(1 row)
45
46[gpadmin@gpdb7 soft]$
安装gpbackup软件:
1-- GPDB 6
2[gpadmin@gpdb6270 soft]$ gppkg -i greenplum_backup_restore-1.30.6-gp6-rhel7-x86_64.gppkg
320240830:14:24:03:001173 gppkg:gpdb6270:gpadmin-[INFO]:-Starting gppkg with args: -i greenplum_backup_restore-1.30.6-gp6-rhel7-x86_64.gppkg
420240830:14:24:03:001173 gppkg:gpdb6270:gpadmin-[INFO]:-Installing package greenplum_backup_restore-1.30.6-gp6-rhel7-x86_64.gppkg
520240830:14:24:03:001173 gppkg:gpdb6270:gpadmin-[INFO]:-Validating rpm installation cmdStr='rpm --test -i /usr/local/greenplum-db-6.27.0/.tmp/gpbackup_tools_RHEL7-1.30.6-1.x86_64.rpm --dbpath /usr/local/greenplum-db-6.27.0/share/packages/database --prefix /usr/local/greenplum-db-6.27.0'
620240830:14:24:06:001173 gppkg:gpdb6270:gpadmin-[INFO]:-Installing greenplum_backup_restore-1.30.6-gp6-rhel7-x86_64.gppkg locally
720240830:14:24:07:001173 gppkg:gpdb6270:gpadmin-[INFO]:-Validating rpm installation cmdStr='rpm --test -i /usr/local/greenplum-db-6.27.0/.tmp/gpbackup_tools_RHEL7-1.30.6-1.x86_64.rpm --dbpath /usr/local/greenplum-db-6.27.0/share/packages/database --prefix /usr/local/greenplum-db-6.27.0'
820240830:14:24:07:001173 gppkg:gpdb6270:gpadmin-[INFO]:-greenplum_backup_restore-1.30.6-gp6-rhel7-x86_64.gppkg is already installed.
920240830:14:24:07:001173 gppkg:gpdb6270:gpadmin-[INFO]:-gpbackup 1.30.6 successfully installed
1020240830:14:24:07:001173 gppkg:gpdb6270:gpadmin-[INFO]:-greenplum_backup_restore-1.30.6-gp6-rhel7-x86_64.gppkg successfully installed.
11[gpadmin@gpdb6270 soft]$
12
13
14-- GPDB 7
15[gpadmin@gpdb7 soft]$ gppkg install greenplum_backup_restore-1.30.6-gp7-rhel8-x86_64.gppkg
16Detecting network topology: [==============================================================] [OK]
172 coordinators and 4 segment instances are detected on 1 unique host.
18Distributing package: [==============================================================] [OK]
19Decoding package: [==============================================================] [OK]
20Verifying package installation:[==============================================================] [OK]
21Verifying package integrity: [==============================================================] [OK]
22You are going to install the following packages:
23 Install 'greenplum_backup_restore@1.30.6-gp7'
24Continue? [y/N] y
25Allocating disk space: [==============================================================] [OK]
26Install 'greenplum_backup_rest:[==============================================================] [OK]
27Result:
28 greenplum_backup_restore has been successfully installed
29Clean Up: [==============================================================] [OK]
30[gpadmin@gpdb7 soft]$
31
MinIO的S3环境准备
1docker rm -f lhrminio
2docker run -d --name lhrminio -h lhrminio \
3 -p 9000:9000 -p 9001:9001 -p 922:22 -p 39389:3389 \
4 -p 29990:9090 -p 29300:3000 \
5 -v /sys/fs/cgroup:/sys/fs/cgroup --restart=always \
6 --privileged=true lhrbest/minio:1.0 \
7 /usr/sbin/init
8
9docker exec -it lhrminio bash
10
11
12-- 用户名和密码:minioadmin/minioadmin
13-- 9000端口指的是minio的WebUI端口,9001是API的端口
14-- 默认buket桶为gpbk
15-- 默认ak和sk都为:12345678
16http://192.16.7.162:9000/login
该环境自带有MinIO、prometheus、grafana等环境。
gpbackup备份
1-- 产生数据
2createdb sbtest;
3sysbench /usr/share/sysbench/oltp_common.lua --db-driver=pgsql --pgsql-host=127.0.0.1 --pgsql-port=5432 \
4--pgsql-user=gpadmin --pgsql-password=lhr --pgsql-db=sbtest \
5--time=300 --table-size=10000 --tables=10 --threads=16 \
6--events=999999999 prepare
7
8
9-- 备份
10cat > /home/gpadmin/s3_config.yaml <<"EOF"
11executablepath: $GPHOME/bin/gpbackup_s3_plugin
12options:
13 region:
14 endpoint: http://192.16.7.162:9001
15 aws_access_key_id: 12345678
16 aws_secret_access_key: 12345678
17 bucket: gpbk
18 folder: sbtest
19EOF
20
21gpbackup --dbname sbtest --jobs=16 --plugin-config /home/gpadmin/s3_config.yaml
这个命令创建了一个配置文件
/home/gpadmin/s3_config.yaml
,用于配置gpbackup
的 S3 存储插件。通过配置s3_config.yaml
文件,可以将gpbackup
和gprestore
的备份数据直接保存到 S3 兼容的存储服务中。此配置文件定义了 S3 插件的位置和存储选项(如存储端点、访问凭证和目标存储桶和文件夹)。下面是配置文件中每个参数的详细介绍:
·
executablepath
说明: 指定
gpbackup
使用的 S3 插件的路径。用途: 这个路径指向
gpbackup_s3_plugin
,这是 Greenplum 提供的一个插件,允许gpbackup
和gprestore
直接与 S3 兼容的存储进行交互。默认值: 在示例中,它被设置为
$GPHOME/bin/gpbackup_s3_plugin
,其中$GPHOME
是 Greenplum 安装目录的环境变量。·
options
说明: 包含一组键值对,这些选项用于配置 S3 插件的行为。
·
region
说明: S3 存储区域(Region)。
用途: 用于指定 AWS S3 存储所在的区域(如
us-east-1
、us-west-2
等)。示例: 如果你使用的是 AWS 的 S3 服务,你需要在此处填上区域名称(例如
us-east-1
)。如果你使用的是其他兼容 S3 的存储系统(如 MinIO),你可以忽略此参数或将其留空。·
endpoint
说明: S3 兼容存储的端点(Endpoint)URL。
用途: 这是存储服务的访问地址。在 AWS S3 的情况下,这通常是一个 URL,例如
https://s3.amazonaws.com
。·
aws_access_key_id
说明: 访问 S3 兼容存储的访问密钥 ID。
用途: 用于身份验证。它是一个唯一的标识符,允许用户访问 S3 服务或兼容的存储。
示例:
12345678
是示例中的访问密钥 ID。你应将其替换为实际的 AWS Access Key 或 MinIO Access Key。·
aws_secret_access_key
说明: 访问 S3 兼容存储的访问密钥。
用途: 与
aws_access_key_id
配合使用,用于身份验证。它是一个秘密密钥,不能与他人分享。示例:
12345678
是示例中的访问密钥。你应将其替换为实际的 AWS Secret Key 或 MinIO Secret Key。·
bucket
说明: S3 兼容存储中的存储桶(Bucket)名称。
用途: 指定备份文件将存储到的 S3 存储桶的名称。
示例:
gpbk
是用于存储备份的存储桶名称。你应将其替换为实际的存储桶名称。·
folder
说明: 存储桶中的文件夹名称。
用途: 指定备份文件存储在存储桶中的哪个文件夹。
示例:
sbtest
是在存储桶gpbk
中的文件夹名称。备份将存储在此文件夹中。
日志:
1-- GPDB6
2[gpadmin@gpdb6270 ~]$ gpbackup --dbname sbtest --jobs=16 --plugin-config /home/gpadmin/s3_config.yaml
320240830:14:41:13 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-gpbackup version = 1.30.6
420240830:14:41:14 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Greenplum Database Version = 6.27.0 build commit:482d4e839d519dcfde9cddf03807787d9d91d015
520240830:14:41:14 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Starting backup of database sbtest
620240830:14:41:14 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Reading Plugin Config /home/gpadmin/s3_config.yaml
720240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Backup Timestamp = 20240830144113
820240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Backup Database = sbtest
920240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Gathering table state information
1020240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Acquiring ACCESS SHARE locks on tables
11Locks acquired: 10 / 10 [==============================================================] 100.00% 0s
1220240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Gathering additional table metadata
1320240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Getting partition definitions
1420240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Getting storage information
1520240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Getting child partitions with altered schema
1620240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Metadata will be written to /opt/greenplum/data/master/gpseg-1/backups/20240830/20240830144113/gpbackup_20240830144113_metadata.sql
1720240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Writing global database metadata
1820240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Global database metadata backup complete
1920240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Writing pre-data metadata
2020240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Pre-data metadata metadata backup complete
2120240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Writing post-data metadata
2220240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Post-data metadata backup complete
2320240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Writing data to file
24Tables backed up: 10 / 10 [============================================================] 100.00% 0s
2520240830:14:41:15 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Data backup complete
2620240830:14:41:17 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Found neither /usr/local/greenplum-db-6.27.0/bin/gp_email_contacts.yaml nor /home/gpadmin/gp_email_contacts.yaml
2720240830:14:41:17 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Email containing gpbackup report /opt/greenplum/data/master/gpseg-1/backups/20240830/20240830144113/gpbackup_20240830144113_report will not be sent
2820240830:14:41:17 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Beginning cleanup
2920240830:14:41:17 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Cleanup complete
3020240830:14:41:17 gpbackup:gpadmin:gpdb6270:002868-[INFO]:-Backup completed successfully
31[gpadmin@gpdb6270 ~]$
32[gpadmin@gpdb6270 ~]$ gpbackup_manager list-backups
33
34 timestamp date status database type object filtering plugin duration
35 20240830144113 Fri Aug 30 2024 14:41:13 Success sbtest full gpbackup_s3_plugin 00:00:04
36[gpadmin@gpdb6270 ~]$
37
38
39
40-- GPDB7
41[gpadmin@gpdb7 soft]$ gpbackup --dbname sbtest --jobs=16 --plugin-config /home/gpadmin/s3_config.yaml
4220240830:14:41:55 gpbackup:gpadmin:gpdb7:003322-[INFO]:-gpbackup version = 1.30.6
43
4420240830:14:41:55 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Greenplum Database Version = 7.3.0 build commit:ebf6c7db0034f8928f20252a306c4ecdb9324d81
4520240830:14:41:55 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Starting backup of database sbtest
4620240830:14:41:55 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Reading Plugin Config /home/gpadmin/s3_config.yaml
4720240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Backup Timestamp = 20240830144155
4820240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Backup Database = sbtest
4920240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Gathering table state information
5020240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Acquiring ACCESS SHARE locks on tables
51Locks acquired: 10 / 10 [==============================================================] 100.00% 0s
5220240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Gathering additional table metadata
5320240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Getting storage information
5420240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Metadata will be written to /opt/greenplum/data/master/gpseg-1/backups/20240830/20240830144155/gpbackup_20240830144155_metadata.sql
5520240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Writing global database metadata
5620240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Global database metadata backup complete
5720240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Writing pre-data metadata
5820240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Pre-data metadata metadata backup complete
5920240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Writing post-data metadata
6020240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Post-data metadata backup complete
6120240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Writing data to file
62Tables backed up: 10 / 10 [============================================================] 100.00% 0s
6320240830:14:41:56 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Data backup complete
6420240830:14:41:57 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Found neither /usr/local/greenplum-db-7.3.0/bin/gp_email_contacts.yaml nor /home/gpadmin/gp_email_contacts.yaml
6520240830:14:41:57 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Email containing gpbackup report /opt/greenplum/data/master/gpseg-1/backups/20240830/20240830144155/gpbackup_20240830144155_report will not be sent
6620240830:14:41:58 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Beginning cleanup
6720240830:14:41:58 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Cleanup complete
6820240830:14:41:58 gpbackup:gpadmin:gpdb7:003322-[INFO]:-Backup completed successfully
69[gpadmin@gpdb7 soft]$
70[gpadmin@gpdb7 soft]$ gpbackup_manager list-backups
71
72 timestamp date status database type object filtering plugin duration
73 20240830144155 Fri Aug 30 2024 14:41:55 Success sbtest full gpbackup_s3_plugin 00:00:02
74[gpadmin@gpdb7 soft]$
数据可正常备份:
gprestore还原
1gprestore --plugin-config /home/gpadmin/s3-test-config.yaml --timestamp=20240830144113 \
2--jobs 8 --create-db --redirect-db sbtest2 --on-error-continue
日志:
1-- GP6
2[gpadmin@gpdb6270 ~]$ dropdb sbtest
3[gpadmin@gpdb6270 ~]$ gprestore --plugin-config /home/gpadmin/s3_config.yaml --timestamp=20240830144113 --jobs 8 --create-db --redirect-db sbtest2 --on-error-continue
420240830:14:46:07 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Restore Key = 20240830144113
520240830:14:46:07 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Reading Plugin Config /home/gpadmin/s3_config.yaml
620240830:14:46:07 gprestore:gpadmin:gpdb6270:004346-[INFO]:-plugin config path: /tmp/20240830144607_s3_config.yaml
720240830:14:46:08 gprestore:gpadmin:gpdb6270:004346-[INFO]:-gpbackup version = 1.30.6
820240830:14:46:08 gprestore:gpadmin:gpdb6270:004346-[INFO]:-gprestore version = 1.30.6
920240830:14:46:08 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Greenplum Database Version = 6.27.0 build commit:482d4e839d519dcfde9cddf03807787d9d91d015
1020240830:14:46:08 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Creating database
1120240830:14:46:08 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Database creation complete for: sbtest2
1220240830:14:46:09 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Restoring pre-data metadata
13Pre-data objects restored: 54 / 54 [===================================================] 100.00% 0s
1420240830:14:46:09 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Pre-data metadata restore complete
15Table data loads restored: 10 / 10 [===================================================] 100.00% 0s
1620240830:14:46:09 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Data restore complete
1720240830:14:46:09 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Restoring post-data metadata
18Post-data objects restored: 20 / 20 [==================================================] 100.00% 0s
1920240830:14:46:09 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Post-data metadata restore complete
2020240830:14:46:09 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Found neither /usr/local/greenplum-db-6.27.0/bin/gp_email_contacts.yaml nor /home/gpadmin/gp_email_contacts.yaml
2120240830:14:46:09 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Email containing gprestore report /opt/greenplum/data/master/gpseg-1/backups/20240830/20240830144113/gprestore_20240830144113_20240830144607_report will not be sent
2220240830:14:46:09 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Beginning cleanup
2320240830:14:46:09 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Cleanup complete
2420240830:14:46:09 gprestore:gpadmin:gpdb6270:004346-[INFO]:-Restore completed successfully
25[gpadmin@gpdb6270 ~]$ psql -c '\l+ sbtest*'
26 List of databases
27 Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description
28---------+---------+----------+------------+------------+-------------------+-------+------------+-------------
29 sbtest2 | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | | 82 MB | pg_default |
30(1 row)
31
32-- GP7
33[gpadmin@gpdb7 soft]$ dropdb sbtest
34[gpadmin@gpdb7 soft]$ gprestore --plugin-config /home/gpadmin/s3_config.yaml --timestamp=20240830144155 --jobs 8 --create-db --redirect-db sbtest2 --on-error-continue
3520240830:14:47:00 gprestore:gpadmin:gpdb7:004311-[INFO]:-Restore Key = 20240830144155
3620240830:14:47:00 gprestore:gpadmin:gpdb7:004311-[INFO]:-Reading Plugin Config /home/gpadmin/s3_config.yaml
3720240830:14:47:00 gprestore:gpadmin:gpdb7:004311-[INFO]:-plugin config path: /tmp/20240830144700_s3_config.yaml
3820240830:14:47:00 gprestore:gpadmin:gpdb7:004311-[INFO]:-gpbackup version = 1.30.6
3920240830:14:47:00 gprestore:gpadmin:gpdb7:004311-[INFO]:-gprestore version = 1.30.6
4020240830:14:47:00 gprestore:gpadmin:gpdb7:004311-[INFO]:-Greenplum Database Version = 7.3.0 build commit:ebf6c7db0034f8928f20252a306c4ecdb9324d81
4120240830:14:47:00 gprestore:gpadmin:gpdb7:004311-[INFO]:-Creating database
4220240830:14:47:01 gprestore:gpadmin:gpdb7:004311-[INFO]:-Database creation complete for: sbtest2
4320240830:14:47:01 gprestore:gpadmin:gpdb7:004311-[INFO]:-Restoring pre-data metadata
44Pre-data objects restored: 36 / 56 [==================================>-------------------] 64.29%
4520240830:14:47:01 gprestore:gpadmin:gpdb7:004311-[ERROR]:-Encountered 2 errors during metadata restore; see log file /home/gpadmin/gpAdminLogs/gprestore_20240830.log for a list of failed statements.
46Pre-data objects restored: 56 / 56 [===================================================] 100.00% 0s
4720240830:14:47:01 gprestore:gpadmin:gpdb7:004311-[INFO]:-Pre-data metadata restore completed with failures
48Table data loads restored: 10 / 10 [===================================================] 100.00% 0s
4920240830:14:47:01 gprestore:gpadmin:gpdb7:004311-[INFO]:-Data restore complete
5020240830:14:47:01 gprestore:gpadmin:gpdb7:004311-[INFO]:-Restoring post-data metadata
51Post-data objects restored: 20 / 20 [==================================================] 100.00% 0s
5220240830:14:47:01 gprestore:gpadmin:gpdb7:004311-[INFO]:-Post-data metadata restore complete
5320240830:14:47:01 gprestore:gpadmin:gpdb7:004311-[INFO]:-Found neither /usr/local/greenplum-db-7.3.0/bin/gp_email_contacts.yaml nor /home/gpadmin/gp_email_contacts.yaml
5420240830:14:47:01 gprestore:gpadmin:gpdb7:004311-[INFO]:-Email containing gprestore report /opt/greenplum/data/master/gpseg-1/backups/20240830/20240830144155/gprestore_20240830144155_20240830144700_report will not be sent
5520240830:14:47:01 gprestore:gpadmin:gpdb7:004311-[INFO]:-Beginning cleanup
5620240830:14:47:01 gprestore:gpadmin:gpdb7:004311-[INFO]:-Cleanup complete
57[gpadmin@gpdb7 soft]$ psql -c '\l+ sbtest*'
58 List of databases
59 Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description
60---------+---------+----------+-------------+-------------+-------------------+-------+------------+-------------
61 sbtest2 | gpadmin | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 90 MB | pg_default |
62(1 row)
可以看到,数据也可以正常还原。
相关监控数据
备份和还原都可以使用S3存储,实现了异地备份恢复,非常方便,效率方面也不错。
总结
1、可以使用MinIO软件快速部署兼容的S3环境,作为GP的异地备份环境。
2、使用pg_dump进行远程备份,对于1T文件,大概10小时,备份后800GB
3、gpbackup+S3方式进行远程备份,对于1T文件,大概30分钟,备份后700GB
4、gpbackup+S3方式对GP6和GP7都支持
使用PG备份恢复工具之pgbackrest在S3中的操作,我们在PG的培训认证课程上进行详细讲解,欢迎大家报名。
参考
https://www.bookstack.cn/read/greenplum-admin_guide-6.0-zh/153957ce5c5ca161.md