Postgresql

無法使用酒保接收 WAL 文件

  • March 26, 2020

我一直在摸索解決以下錯誤,但沒有取得太大進展:

$ barman switch-wal --force --archive --archive-timeout 180 pg

The WAL file 0000000100000059000000FF has been closed on server 'pg'
Waiting for the WAL file 0000000100000059000000FF from server 'pg' (max: 180 seconds)
ERROR: The WAL file 0000000100000059000000FF has not been received in 180 seconds

我之前在一次性 VPS 上配置了酒保,一切正常。但是當我嘗試在我們的最終 EC2 實例上複製它時,我遇到了上面提到的問題。我已經確保了以下內容(即使我不記得在 VPS 上這樣做了):

  • 來自酒吧的 SSH => pg 正在工作
  • 來自 pg => barman 的 SSH 正在工作
  • ‘pg’ 上的所有防火牆規則都已暫時禁用

這裡可能是什麼問題?

**編輯:**添加輸出barman check pg

Server pg:
2017-12-08 05:56:31,841 [14559] barman.server ERROR: Check 'WAL archive' failed for server 'pg'
   WAL archive: FAILED (please make sure WAL shipping is setup)
   PostgreSQL: OK
   is_superuser: OK
   PostgreSQL streaming: OK
   wal_level: OK
2017-12-08 05:56:34,174 [14559] barman.server ERROR: Check 'replication slot' failed for server 'pg'
   replication slot: FAILED (slot 'pgbackup' not active: is 'receive-wal' running?)
   directories: OK
   retention policy settings: OK
2017-12-08 05:56:34,175 [14559] barman.server ERROR: Check 'backup maximum age' failed for server 'pg'
   backup maximum age: FAILED (interval provided: 14 days, latest backup age: No available backups)
   compression settings: OK
   failed backups: OK (there are 0 failed backups)
2017-12-08 05:56:34,175 [14559] barman.server ERROR: Check 'minimum redundancy requirements' failed for server 'pg'
   minimum redundancy requirements: FAILED (have 0 backups, expected at least 3)
   pg_basebackup: OK
   pg_basebackup compatible: OK
   pg_basebackup supports tablespaces mapping: OK
   pg_receivexlog: OK
   pg_receivexlog compatible: OK
2017-12-08 05:56:34,367 [14559] barman.server ERROR: Check 'receive-wal running' failed for server 'pg'
   receive-wal running: FAILED (See the Barman log file for more details)
   archiver errors: OK

**編輯:**添加的輸出barman receive-wal pg

$ sudo barman receive-wal pg
2017-12-10 01:48:01,129 [25410] barman.utils WARNING: Failed opening the requested log file. Using standard error instead.
Starting receive-wal for server pg
2017-12-10 01:48:01,138 [25410] barman.server INFO: Starting receive-wal for server pg
2017-12-10 01:48:03,087 [25410] barman.wal_archiver INFO: Activating WAL archiving through streaming protocol
pg: pg_receivexlog: starting log streaming at 5A/A000000 (timeline 1)
2017-12-10 01:48:03,391 [25410] barman.command_wrappers INFO: pg: pg_receivexlog: starting log streaming at 5A/A000000 (timeline 1)

^CSIGINT received. Terminate gracefully.
2017-12-10 01:50:42,512 [25410] barman.wal_archiver INFO: SIGINT received. Terminate gracefully.

**編輯:**配置文件——

; --------------------
; Contents of /etc/barman.conf after removing all commented lines.
; --------------------

[barman]
barman_user = ubuntu
path_prefix = /home/ubuntu/pg/bin
configuration_files_directory = /home/ubuntu/barman.conf.d
barman_home = /home/ubuntu/barman
log_file = /var/log/barman/barman.log
log_level = INFO
compression = bzip2
retention_policy = RECOVERY WINDOW OF 1 MONTH
last_backup_maximum_age = 2 WEEKS
minimum_redundancy = 3
retention_policy = RECOVERY WINDOW OF 4 WEEKS

/home/ubuntu/barman.conf.d/pg.conf:

; --------------------
; Contents of /home/ubuntu/barman.conf.d/pg.conf after removing all commented lines.
; --------------------

[pg]
description =  "Postgres DB"
conninfo = host=REDACTED user=REDACTED dbname=REDACTED
backup_method = postgres
archiver = off
streaming_conninfo =  host=REDACTED user=REDACTED dbname=REDACTED
streaming_archiver = on
slot_name = pgbackup

當你遇到這樣的問題時,一定要仔細檢查你的日誌,barman check命令,並確保你設置了一個barman cron條目 start barman receive-walbarman switch-wal在執行和完成設置之前需要執行它。=)

您使用的是什麼版本的 PostgreSQL 和 Barman?

在 PG 9.3 之前,沒有以 FF 結尾的 WAL 文件,它從 FE 變為 00。

您似乎使用的是 PG < 9.3,但您的 Barman 版本並沒有預料到這一點。

引用自:https://dba.stackexchange.com/questions/192162