致命:无法连接到主服务器:预期来自服务器的身份验证请求,但收到 S

FATAL: could not connect to the primary server: expected authentication request from server, but received S

我正在尝试在 Postgress 服务器中创建主从复制方案。 我用 5300 端口创建了一个主站,从站有 5500 这是我的 postgresql.conf.

listen_addresses = '*'
port              = 5300
wal_level         = hot_standby
max_wal_senders   = 3
wal_keep_segments = 8
synchronous_standby_names = 'slave1'

我使用以下配置创建了 pg_hba.conf。

# "local" is for Unix domain socket connections only
local   all             all                                        trust
# IPv4 local connections:
host    all             all                127.0.0.1/32            trust
# IPv6 local connections:
host    all             all                ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                        trust
host    replication     all                127.0.0.1/32            trust
host    replication     all                ::1/128                 trust
host    replication     <database-user>    127.0.0.1/32            md5
host    replication     <database-user>    172.16.217.185/32       md5
host    replication     <database-user>    172.16.217.187/32       md5

然后我使用以下命令创建集群。

initdb

然后我使用以下命令启动我的主集群。

bin/pg_ctl -w -l master/logs -o "-p 5300" start

那个命令 运行 没问题。 然后我创建从属文件夹并将所有主数据复制到其中。 并将此文件夹传递到从属端。 然后在配置之后我确实创建了 recovary.conf.

并将以下内容放入其中。

standby_mode = 'on'
primary_conninfo ='host=172.16.217.185 port=5300 user=<db_user> password=<Password> application_name=slave1'

那我开始做奴隶了

pg_ctl -w -l slave/logs -o "-p 5500" start

当我看到 slave/logs 时给我错误提示。 我看到我在上面分享的错误。

FATAL: could not connect to the primary server: expected authentication request from server, but received S and remember I am running all the scenario in the VMFusion.

还有一件事我用防火墙试过了 enable/disable/allow 他们都给我相同的结果,所以不是防火墙导致了这个错误。

提前致谢。

请确保您的 /data 从属目录中有一个名为 recovery.conf 的存档,该文件需要包含以下内容:

standby_mode = 'on'

primary_conninfo = 'host=192.168.x.x port=5432 user=rep password=xxxxxx'

trigger_file = '/tmp/postgresql.trigger.5432'

where 192.168.x.x你需要用你的Master Ip来改变 当然密码是关于用户 rep

我找到了解决方案。 实际上,当多个集群在同一台机器上工作并且当您 运行 以下命令时,就会发生此错误。

pg_ctl -w -l slave/logs -o "-p 5500" start

服务器对哪个集群应该响应感到困惑。 我在停止所有集群并启动关注集群的同时解决了这个问题。