背景:
我正在尝试在两台服务器之间设置流式复制。尽管 postgresql 在两个机器上都运行时没有任何错误,但是当我从主服务器添加或更改记录时,这些更改不会反射(reflect)在辅助服务器上。
我在主数据库服务器上进行了以下设置:
(注意:我使用的是假 IP 地址,但 10.222.22.12 代表主服务器,.21 代表辅助服务器)
主服务器 - posgresql.conf
listen_addresses = '10.222.22.12'
unix_socket_directory = '/tmp/postgresql'
wal_level = hot_standby
max_wal_senders = 5 # max number of walsender processes
# (change requires restart)
wal_keep_segments = 32 # in logfile segments, 16MB each; 0 disables
主服务器 - pg_hba.conf
host all all 10.222.22.21/32 trust
host replication postgres 10.222.22.0/32 trust
主服务器 - 防火墙
我已经检查以确保所有传入的 fw 都是开放的,并且所有的流量都被允许。
辅助服务器 - posgresql.conf
listen_addresses = '10.222.22.21'
wal_level = hot_standby
max_wal_senders = 5 # max number of walsender processes
# (change requires restart)
wal_keep_segments = 32 # in logfile segments, 16MB each; 0 disables
hot_standby = on
辅助服务器 - pg_hba.conf
host all all 10.222.22.12/32 trust
host all all 10.222.22.21/32 trust
host replication postgres 10.222.22.0/24 trust
辅助服务器 - recovery.conf
standby_mode='on'
primary_conninfo = 'host=10.222.22.12 port=5432 user=postgres'
二级服务器防火墙
这里也是开放的。
到目前为止我尝试了什么
- 更改了主要数据。没有复制过来。
- 检查了两台服务器上的防火墙设置。
- 检查了辅助框上的 arp 表以确保它可以与主框通信。
- 检查了两台服务器上的 postmaster.log 文件。它们是空的。
- 检查了两台服务器上的系统日志文件。没有发现错误。
- 在两台服务器上重新启动 postgresql 以确保它启动时没有错误。
我不确定还要检查什么。如果您有任何建议,我将不胜感激。
编辑 1
我检查了master 上的pg_stat_replication 表,得到以下结果:
psql -U postgres testdb -h 10.222.22.12 -c "select * from pg_stat_replication;"
pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | state | sent_location | write_location | flush_location | repl
ay_location | sync_priority | sync_state
-----+----------+---------+------------------+-------------+-----------------+-------------+---------------+-------+---------------+----------------+----------------+-----
------------+---------------+------------
(0 rows)
在从服务器上,注意以下查询的结果:
testdb=# select now()-pg_last_xact_replay_timestamp();
?column?
----------
(1 row)
打开器=#
最佳答案
我更改了主服务器上的 pg_hba.conf 文件并添加了我的从服务器的确切 ip 地址,如下所示:
host all all 10.222.22.21/32 trust
host replication postgres 10.222.22.0/32 trust
#added the line below
host replication postgres 10.222.22.12/32 trust
然后我重新启动了 postgresql,它成功了。 我想我期望我添加的新行上方的行可以工作,但事实并非如此。我必须做更多关于子网划分的阅读。
关于linux - postgresql 数据库未复制。没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25856873/