开头还是介绍一下群,如果感兴趣PolarDB ,MongoDB ,MySQL ,PostgreSQL ,Redis, Oceanbase, Sql Server等有问题,有需求都可以加群群内,可以解决你的问题。加群请联系 liuaustin3 ,(共1730人左右 1 + 2 + 3 + 4 +5) 4群(240+),另欢迎 OpenGauss 的技术人员加入。
前两期介绍了关于pgbackrest 的基本搭建和一些设置以及日常的使用,在实际的工作中,pgbackrest本身是可以进行集中化管理的,通过集中化的管理方式来进行批量的大范围的数据库管理如何进行相关的操作和配置。实际上pgbackrest 在单机备份的简便性还是不如pgrman的的便利性,但是在下图的备份方案中,则pgbackrest 是好的备份的方案选择。
同时这篇文章,和上两篇之间有很大时间的差距的原因在,这篇在测试中失败N次,各种问题,各种参数在文档中未说明等问题。
问题的难点,在于中文,英文,没有一篇文档说明了其中还包含了操作的顺序,最后找到其中的奥秘还是通过某个繁体字的网站的一点信息发现其中一直没有成功的原因。
这里需要将pgbackrest 单独进行安装到一台服务器中,并部署pgbackrest的主机,同时打通主机与各个postgresql数据库的SSH 免密连接。
下面是整个搭建的过程
postgresql IP 地址 192.168.198.101
2 账号
pgbackrest 账号为 pgbackrest
postgresql 账号为 postgres
pgbackrest@pgbackrest:~$
pgbackrest@pgbackrest:~$ ssh postgres@192.168.198.101
Last login: Thu Feb 16 20:54:36 2023
[postgres@postgre14 ~]$复制
[postgres@postgre14 ~]$ ssh pgbackrest@192.168.198.150
Welcome to Ubuntu 22.04 LTS (GNU/Linux 5.15.0-87-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Wed Dec 6 06:18:53 AM UTC 2023复制
[test]
pg1-path=/pgdata/data
pg1-socket-path=/tmp
[global]
repo1-host=192.168.198.150
log-level-file=detail
log-path=/var/log/pgbackrest复制
[test]
pg1-path=/pgdata/data
pg1-port=5432
pg1-socket-path=/tmp
pg1-host=192.168.198.101
pg1-user=backup
pg1-pgpass=/home/postgres/.pgpass
[global]
repo1-path=/pgbackrest/backup
repo1-retention-full=2
log-level-console=info
log-level-file=debug
buffer-size=16MiB
compress-type=gz
[global:archive-push]
compress-level=3复制
pgbackrest@pgbackrest:~$ pgbackrest --stanza=test stanza-create
WARN: configuration file contains invalid option 'pg1-pgpass'
2023-12-06 07:38:07.986 P00 INFO: stanza-create command begin 2.48: --buffer-size=16MiB --exec-id=45679-3c58b42b --log-level-console=info --log-level-file=debug --pg1-host=192.168.198.101 --pg1-host-config-path=/etc/pgbackrest --pg1-host-port=22 --pg1-host-user=postgres --pg1-path=/pgdata/data --pg1-port=5432 --pg1-user=postgres --repo1-path=/pgbackrest/backup --stanza=test
WARN: unable to check pg1: [DbConnectError] raised from remote-0 ssh protocol on '192.168.198.101': unable to connect to 'dbname='postgres' port=5432 user='postgres'': could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
ERROR: [056]: unable to find primary cluster - cannot proceed
HINT: are all available clusters in recovery?复制
[postgres@postgre14 pgbackrest]$ pgbackrest --stanza=test stanza-create
WARN: unable to check pg1: [DbConnectError] unable to connect to 'dbname='postgres' port=5432': could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
ERROR: [056]: unable to find primary cluster - cannot proceed复制
pgbackrest --stanza=test stanza-create
WARN: configuration file contains invalid option 'pg1-pgpass'
2023-12-06 07:52:26.993 P00 INFO: stanza-create command begin 2.48: --buffer-size=16MiB --exec-id=47078-8289a622 --log-level-console=info --log-level-file=debug --pg1-host=192.168.198.101 --pg1-path=/pgdata/data --pg1-port=5432 --pg1-socket-path=/tmp --pg1-user=backup --repo1-path=/pgbackrest/backup --stanza=test
2023-12-06 07:52:27.799 P00 INFO: stanza-create for stanza 'test' on repo1
ERROR: [055]: archive.info exists but backup.info is missing on repo1
HINT: this may be a symptom of repository corruption!
2023-12-06 07:52:27.801 P00 INFO: stanza-create command end: aborted with exception [055]复制
[postgres@postgre14 pgbackrest]$ pgbackrest --stanza=test stanza-create
ERROR: [055]: archive.info exists but backup.info is missing on repo1
HINT: this may be a symptom of repository corruption!复制
pgbackrest --stanza=test stanza-create
WARN: configuration file contains invalid option 'pg1-pgpass'
2023-12-06 07:52:54.849 P00 INFO: stanza-create command begin 2.48: --buffer-size=16MiB --exec-id=47087-9c19c49c --log-level-console=info --log-level-file=debug --pg1-host=192.168.198.101 --pg1-path=/pgdata/data --pg1-port=5432 --pg1-socket-path=/tmp --pg1-user=backup --repo1-path=/pgbackrest/backup --stanza=test
2023-12-06 07:52:55.620 P00 INFO: stanza-create for stanza 'test' on repo1
2023-12-06 07:52:55.731 P00 INFO: stanza-create command end: completed successfully (885ms)复制
[postgres@postgre14 pgbackrest]$ pgbackrest --stanza=test stanza-create
复制
pgbackrest@pgbackrest:/pgbackrest$ pgbackrest --stanza=test check
WARN: configuration file contains invalid option 'pg1-pgpass'
2023-12-06 07:53:19.995 P00 INFO: check command begin 2.48: --buffer-size=16MiB --exec-id=47148-5c776784 --log-level-console=info --log-level-file=debug --pg1-host=192.168.198.101 --pg1-path=/pgdata/data --pg1-port=5432 --pg1-socket-path=/tmp --pg1-user=backup --repo1-path=/pgbackrest/backup --stanza=test
2023-12-06 07:53:20.836 P00 INFO: check repo1 configuration (primary)
2023-12-06 07:53:21.500 P00 INFO: check repo1 archive for WAL (primary)
2023-12-06 07:53:22.106 P00 INFO: WAL segment 00000001000000070000000D successfully archived to '/pgbackrest/backup/archive/test/14-1/0000000100000007/00000001000000070000000D-46144492923763da2d73d3b681abb903320a3f24.gz' on repo1
2023-12-06 07:53:22.210 P00 INFO: check command end: completed successfully (2218ms)
pgbackrest@pgbackrest:/pgbackrest$
pgbackrest@pgbackrest:/pgbackrest$
pgbackrest@pgbackrest:/pgbackrest$ pgbackrest --stanza=test --log-level-console=info backup
WARN: configuration file contains invalid option 'pg1-pgpass'
2023-12-06 08:10:38.578 P00 INFO: backup command begin 2.48: --buffer-size=16MiB --compress-type=gz --exec-id=47204-2ecf5294 --log-level-console=info --log-level-file=debug --pg1-host=192.168.198.101 --pg1-path=/pgdata/data --pg1-port=5432 --pg1-socket-path=/tmp --pg1-user=backup --repo1-path=/pgbackrest/backup --repo1-retention-full=2 --stanza=test
WARN: no prior backup exists, incr backup has been changed to full
2023-12-06 08:10:39.684 P00 INFO: execute non-exclusive backup start: backup begins after the next regular checkpoint completes
2023-12-06 08:10:41.103 P00 INFO: backup start archive = 00000001000000070000000F, lsn = 7/3C000060
2023-12-06 08:10:41.103 P00 INFO: check archive for prior segment 00000001000000070000000E
2023-12-06 08:14:40.153 P00 INFO: execute non-exclusive backup stop and wait for all WAL segments to archive
2023-12-06 08:14:40.811 P00 INFO: backup stop archive = 00000001000000070000000F, lsn = 7/3C000170
2023-12-06 08:14:40.815 P00 INFO: check archive for segment(s) 00000001000000070000000F:00000001000000070000000F
2023-12-06 08:14:42.051 P00 INFO: new backup label = 20230217-035638F
2023-12-06 08:14:42.108 P00 INFO: full backup size = 12.7GB, file total = 2860
2023-12-06 08:14:42.109 P00 INFO: backup command end: completed successfully (243533ms)
2023-12-06 08:14:42.109 P00 INFO: expire command begin 2.48: --buffer-size=16MiB --exec-id=47204-2ecf5294 --log-level-console=info --log-level-file=debug --repo1-path=/pgbackrest/backup --repo1-retention-full=2 --stanza=test
2023-12-06 08:14:42.112 P00 INFO: expire command end: completed successfully (3ms)
pgbackrest@pgbackrest:/pgbackrest$
pgbackrest@pgbackrest:/pgbackrest$
pgbackrest@pgbackrest:/pgbackrest$ pgbackrest --stanza=test --log-level-console=info --type=diff
ERROR: [030]: no command found
pgbackrest@pgbackrest:/pgbackrest$ pgbackrest --stanza=test --log-level-console=info --type-diff
ERROR: [031]: invalid option '--type-diff'
pgbackrest@pgbackrest:/pgbackrest$ pgbackrest --stanza=test --log-level-console=info --type-diff backup
ERROR: [031]: invalid option '--type-diff'
pgbackrest@pgbackrest:/pgbackrest$ pgbackrest --stanza=test --type-diff backup
ERROR: [031]: invalid option '--type-diff'
pgbackrest@pgbackrest:/pgbackrest$ pgbackrest --stanza=test --type=diff backup
WARN: configuration file contains invalid option 'pg1-pgpass'
2023-12-06 08:27:07.388 P00 INFO: backup command begin 2.48: --buffer-size=16MiB --compress-type=gz --exec-id=47390-89b37813 --log-level-console=info --log-level-file=debug --pg1-host=192.168.198.101 --pg1-path=/pgdata/data --pg1-port=5432 --pg1-socket-path=/tmp --pg1-user=backup --repo1-path=/pgbackrest/backup --repo1-retention-full=2 --stanza=test --type=diff
2023-12-06 08:27:08.322 P00 INFO: last backup label = 20230217-035638F, version = 2.48
2023-12-06 08:27:08.322 P00 INFO: execute non-exclusive backup start: backup begins after the next regular checkpoint completes
2023-12-06 08:27:09.279 P00 INFO: backup start archive = 000000010000000700000011, lsn = 7/44000028
2023-12-06 08:27:09.280 P00 INFO: check archive for prior segment 000000010000000700000010
2023-12-06 08:27:11.620 P00 INFO: execute non-exclusive backup stop and wait for all WAL segments to archive
2023-12-06 08:27:12.279 P00 INFO: backup stop archive = 000000010000000700000011, lsn = 7/44000100
2023-12-06 08:27:12.284 P00 INFO: check archive for segment(s) 000000010000000700000011:000000010000000700000011
2023-12-06 08:27:13.010 P00 INFO: new backup label = 20230217-035638F_20230217-041429D
2023-12-06 08:27:13.070 P00 INFO: diff backup size = 8.3KB, file total = 2860
2023-12-06 08:27:13.071 P00 INFO: backup command end: completed successfully (5686ms)
2023-12-06 08:27:13.071 P00 INFO: expire command begin 2.48: --buffer-size=16MiB --exec-id=47390-89b37813 --log-level-console=info --log-level-file=debug --repo1-path=/pgbackrest/backup --repo1-retention-full=2 --stanza=test
2023-12-06 08:27:13.074 P00 INFO: expire command end: completed successfully (3ms)复制
文章转载自AustinDatabases,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
王炸!OGG 23ai 终于支持从PostgreSQL备库抽取数据了
曹海峰
409次阅读
2025-03-09 12:54:06
玩一玩系列——玩玩login_hook(一款即将停止维护的PostgreSQL登录插件)
小满未满、
376次阅读
2025-03-08 18:19:28
明明想执行的SQL是DELETE、UPDATE,但为什么看到的是SELECT(FDW的实现原理解析)
小满未满、
356次阅读
2025-03-19 23:11:26
PostgreSQL初/中/高级认证考试(3.15)通过考生公示
开源软件联盟PostgreSQL分会
310次阅读
2025-03-20 09:50:36
IvorySQL 4.4 发布 - 基于 PostgreSQL 17.4,增强平台支持
通讯员
199次阅读
2025-03-20 15:31:04
套壳论
梧桐
196次阅读
2025-03-09 10:58:17
命名不规范,事后泪两行
xiongcc
185次阅读
2025-03-13 14:26:08
PG vs MySQL 执行计划解读的异同点
进击的CJR
125次阅读
2025-03-21 10:50:08
版本发布| IvorySQL 4.4 发布
IvorySQL开源数据库社区
115次阅读
2025-03-13 09:52:33
宝藏PEV,助力你成为SQL优化高手
xiongcc
115次阅读
2025-03-09 23:34:23