自动创建复制槽不适用于 Barman 2.11?

Automatic creation of replication slot not working on Barman 2.11?

我在我的设置中使用 barman 2.11 和 postgres 9.5。如文档中所述,我在服务器配置中指定了“create_slot = auto”以自动创建复制槽,但不幸的是,它似乎没有效果,酒保检查报告的问题如下,

我的服务器配置:

[postgres-source-db]
; Configuration options for the server named 'postgres-source-db'

description =  "Config for PostgreSQL Database Backup via rsync/SSH with WAL streaming"
ssh_command = ssh -q postgres@postgres-source-db
conninfo = host=postgres-source-db user=barman dbname=dcmdb
backup_method = rsync
parallel_jobs = 1
reuse_backup = link
archiver = on
backup_options = exclusive_backup

streaming_conninfo = host=postgres-source-db user=barman
streaming_archiver = on
slot_name = barman
create_slot = auto

===

酒保检查输出:

barman@4f5c93878899:~$ barman check postgres-source-db
Server postgres-source-db:
    WAL archive: FAILED (please make sure WAL shipping is setup)
    PostgreSQL: OK
    superuser or standard user with backup privileges: OK
    PostgreSQL streaming: OK
    wal_level: OK
    replication slot: FAILED (replication slot 'barman' doesn't exist. Please execute 'barman receive-wal --create-slot postgres-source-db')
    directories: OK
    retention policy settings: OK
    backup maximum age: FAILED (interval provided: 1 day, latest backup age: No available backups)
    compression settings: OK
    failed backups: OK (there are 0 failed backups)
    minimum redundancy requirements: FAILED (have 0 backups, expected at least 1)
    ssh: OK (PostgreSQL server)
    not in recovery: OK
    systemid coherence: OK (no system Id stored on disk)
    pg_receivexlog: OK
    pg_receivexlog compatible: OK
    receive-wal running: FAILED (See the Barman log file for more details)
    archive_mode: OK
    archive_command: OK
    archiver errors: OK
barman@4f5c93878899:~$

我应该注意到测试检查成功,如下所示,

barman@4f5c93878899:~$ psql -U barman -h postgres-source-db   -c "IDENTIFY_SYSTEM"   replication=1
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
      systemid       | timeline |  xlogpos  | dbname
---------------------+----------+-----------+--------
 6854705426793291833 |        1 | 0/3000AE0 |
(1 row)

barman@4f5c93878899:~$

我是不是漏掉了什么?

更新(取得部分进展,但仍未走出困境):

再添加一个更新和信息。我在 docker 容器上设置它,请注意尽管我从 PostgreSQL apt-repository 安装它,但 cron 设置丢失了。一旦我登录到容器 & 运行

'/usr/bin/barman -q cron'

启动 WAL 接收器,我看到状态已更改为成功。不确定为什么它没有自动 运行,有什么线索吗?

看起来不像是权限问题,但 '/etc/cron.d/barman' 中内容的语法对我来说似乎是 st运行ge,

barman@bef22f0beec3:~$ cat /etc/cron.d/barman 
# /etc/cron.d/barman: crontab entries for the barman package
MAILTO=root
* * * * * barman [ -x /usr/bin/barman ] && /usr/bin/barman -q cron
barman@bef22f0beec3:~$ 

下面是终端输出,

barman@4f5c93878899:~$ crontab -l
no crontab for barman
barman@4f5c93878899:~$ su root
Password:
root@4f5c93878899:/var/lib/barman# crontab -l
no crontab for root
root@4f5c93878899:/var/lib/barman# exit
exit
barman@4f5c93878899:~$ id
uid=102(barman) gid=103(barman) groups=103(barman)
barman@4f5c93878899:~$ pwd
/var/lib/barman

barman@4f5c93878899:~$ cat /etc/cron.d/barman
# /etc/cron.d/barman: crontab entries for the barman package
MAILTO=root
* * * * * barman [ -x /usr/bin/barman ] && /usr/bin/barman -q cron
barman@4f5c93878899:~$ ls -ltr /etc/cron.d/barman
-rw-r--r-- 1 root root 140 Jul  9 11:18 /etc/cron.d/barman
barman@4f5c93878899:~$ /usr/bin/barman -q cron
barman@4f5c93878899:~$ ps -aef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 05:00 ?        00:00:00 /bin/bash /docker-entrypoint.sh barman
root        24     1  0 05:00 ?        00:00:00 /usr/sbin/sshd -D
root        27    24  0 05:03 ?        00:00:00 sshd: barman [priv]
barman      33    27  0 05:03 ?        00:00:00 sshd: barman@pts/0
barman      34    33  0 05:03 pts/0    00:00:00 -bash
barman     107     1  4 05:18 ?        00:00:00 /usr/bin/python3 /usr/bin/barman -c /etc/barman.conf -q receive-wal postgres-source-db
barman     111   107  1 05:18 ?        00:00:00 /usr/lib/postgresql/12/bin/pg_receivewal --dbname=dbname=replication host=postgres-source-db options=-cdatestyle=iso replication=true user=barman application_name
barman     114    34  0 05:18 pts/0    00:00:00 ps -aef
barman@4f5c93878899:~$

barman@4f5c93878899:~$ barman check postgres-source-db
Server postgres-source-db:
    PostgreSQL: OK
    superuser or standard user with backup privileges: OK
    PostgreSQL streaming: OK
    wal_level: OK
    replication slot: OK
    directories: OK
    retention policy settings: OK
    backup maximum age: FAILED (interval provided: 1 day, latest backup age: No available backups)
    compression settings: OK
    failed backups: OK (there are 0 failed backups)
    minimum redundancy requirements: FAILED (have 0 backups, expected at least 1)
    ssh: OK (PostgreSQL server)
    not in recovery: OK
    systemid coherence: OK (no system Id stored on disk)
    pg_receivexlog: OK
    pg_receivexlog compatible: OK
    receive-wal running: OK
    archive_mode: OK
    archive_command: OK
    continuous archiving: OK
    archiver errors: OK
barman@4f5c93878899:~$

谢谢

为了其他可能面临同样问题的人,我已经解决了。

问题似乎是由于 barman 中的两个错误(我在 Debian 上看到的,其他人不确定),

  1. cron.d 条目 (/etc/cron.d/barman) 在末尾缺少一个新行,事实证明 cron 需要它来执行它们 at-least在 Debian 上。
  2. cron 默认情况下不会自动启动,我必须从我的入口点脚本启动它。

以上两个固定后,它就像一个魅力。