我在VMWARE上有2个ubuntu-20.04 VM,在ip 192.168.1.131上的每个pgprimary上安装了Postgres 12 ip 192.168.1.130上的pgbackup
barman CLI 工具安装在 pgprimary 上 barman 安装在 pgbackup 上
我想以 Postgress 用户的身份从 pgbackupsame 2 用户上的 pgprimary 备份数据
在每台机器上我创建了 2 个 Linux sudoist 用户
useradd barman
useradd streaming_barman
还创建了与 Postgress 用户相同的两个用户
createuser --superuser --replication -P barman
createuser --superuser --replication -P streaming_barman
这是配置文件的相关部分
在 pgprimary 上
postgressql.conf
listen_addresses = '*' # what IP address(es) to listen on;
port = 5432
archive_mode = on
archive_command = 'cp %p /var/lib/postgresql/12/arc/%f'
wal_level = replica
restore_command = 'cp /var/lib/postgresql/12/arc/%f %p'
recovery_target_time = '2021-03-24 16:18:11.319298+05:30'
recovery_target_inclusive = false
pg_hba.conf
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
local all all peer
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
#local replication all peer
#host replication all 127.0.0.1/32 md5
#host replication all ::1/128 md5
# FOR TESTING
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
也做了
firewall-cmd --permanent --add-port=5432/tcp
firewall-cmd --reload
======================== con pgbackup
sudo cat <<'EOF' >> /etc/barman.d/pgprimary.conf
[pgprimary]
description = "Example of PostgreSQL Database (Streaming-Only)"
conninfo = host=192.168.1.131 user=barman dbname=training
streaming_conninfo = host=192.168.1.131 user=streaming_barman dbname=training
backup_method = postgres
streaming_archiver = on
slot_name = barman
create_slot = auto
EOF
pg_hba.conf
cat <<'EOF' >>~/.pgpass
pgprimary:*:*:barman:barman
pgprimary:*:*:streaming_barman:barman
EOF
然后我做了
barman cron
输出
Starting WAL archiving for server pgprimary
Starting streaming archiver for server pgprimary
barman check pgprimary
然后我得到这个错误
[13643] barman.utils WARNING: Failed opening the requested log file. Using standard error instead.
Server pgprimary:
2021-10-30 21:39:15,982 [13643] barman.server ERROR: Check 'WAL archive' failed for server 'pgprimary'
WAL archive: FAILED (please make sure WAL shipping is setup)
2021-10-30 21:39:37,006 [13643] barman.postgres WARNING: Error retrieving PostgreSQL status: connection to server at "192.168.131" (192.168.0.131), port 5432 failed: Connection refused
2021-10-30 21:39:58,021 [13643] barman.server ERROR: Check 'check timeout' failed for server 'pgprimary'
check timeout: FAILED (barman check command timed out)
为什么无法将酒保连接到服务器?
更新:
psql -h 192.168.1.131 -U barman -d training
Password for user barman:
psql (12.8 (Ubuntu 12.8-0ubuntu0.20.04.1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.
我也可以通过 netstat 连接到服务器