[英]Cannot connect PostgreSQL cluster though replication user
I am replicating multiple PostgreSQL clústers in single server using streaming replication and dedicated replication slot. 我正在使用流复制和专用复制插槽在单个服务器中复制多个PostgreSQL类。
We also want to monitor some parameters such as the status of replication slots on each master and, for this reason, we want to be able to connect the master using replication user just to query slot status so no need to setup any user having privileges to access any database. 我们还希望监视一些参数,例如每个主服务器上的复制插槽的状态,因此,我们希望能够使用复制用户连接主服务器,只是为了查询插槽状态,因此无需设置任何具有特权的用户访问任何数据库。
I successfully achieved it in many servers. 我在许多服务器上都成功实现了它。 For example:
例如:
joanmi@standby:~$ PGPASSWORD=supersecret psql -h serverA.example.com -U replication -c "select slot_name, active from pg_replication_slots" postgres
slot_name | active
-----------------+--------
pasifae_replica | t
(1 fila)
But the exact same statement against another server throws an error message claiming about non allowed access. 但是针对另一台服务器的完全相同的语句将引发一条错误消息,声称不允许访问。 Concretely it says that there isn't any row in
pg_hba.conf
file allowing replication
user from our standby server to connect postgres
database. 具体来说,它表示
pg_hba.conf
文件中没有任何行,允许来自备用服务器的replication
用户连接postgres
数据库。
joanmi@standby:~$ PGPASSWORD=supersecret psql -h serverB.example.com -U replication -c "select slot_name, active from pg_replic
ation_slots" postgres
psql: FATAL: no hay una línea en pg_hba.conf para «172.30.100.190», usuario «replication», base de datos «postgres», SSL activo
FATAL: no hay una línea en pg_hba.conf para «172.30.100.190», usuario «replication», base de datos «postgres», SSL inactivo
In fact that is true. 实际上是真的。 But in both master servers and it only fails in one of them.
但是在两个主服务器中,只有其中一个发生故障。
I checked both pg_hba.conf and below are the (unique) rows for replication
user in both: 我检查了pg_hba.conf和以下两个都是
replication
用户的(唯一)行:
Server A: 服务器A:
host replication replication 172.30.100.190/32 md5
Server B: 服务器B:
host replication replication 172.30.100.0/24 md5
...and both are Postgresql 9.4. ...而且都是Postgresql 9.4。 Concretely:
具体来说:
Server A: 9.4.6 服务器A:9.4.6
Server B: 9.4.3 服务器B:9.4.3
The pg_hba.conf
lines that you show only allow replication connections for the user replication
. 您显示的
pg_hba.conf
行仅允许用户replication
复制连接。
You need a line like 你需要像这样的线
host postgres replication 172.30.100.0/24 md5
If it works on one of the servers, there must be another line in pg_hba.conf
that allows the connection. 如果它可以在其中一台服务器上运行,则
pg_hba.conf
中必须存在允许连接的另一行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.