双机热备只读修改postgres用户密码

Change postgres user password in hot standby read only mode

我想更改我的 PostgreSQL 从属服务器上 postgres 用户的密码,该服务器由于活动复制而处于只读模式。 SELECT pg_is_in_recovery(); returns 是的,因此我无法更改密码 - 到目前为止一切顺利。

如何暂时暂停复制(和只读模式)以便为 postgres 用户设置新密码? SELECT pg_xlog_replay_pause(); 没有用。

或者我应该在主服务器上重置 postgres 密码,然后在主服务器和从服务器上使用相同的密码吗?

https://www.postgresql.org/docs/current/static/hot-standby.html

When the hot_standby parameter is set to true on a standby server, it will begin accepting connections once the recovery has brought the system to a consistent state. All such connections are strictly read-only; not even temporary tables may be written.

等等您可以在从机上执行的操作的列表。你不能 ALTER USER 在 slave 上 - 在 master 上做它会被复制到 slave。不过,您可以尝试使用不同的密码:

  1. 更改主密码 - 它会复制到从属所以你有相同的密码
  2. pg_xlog_replay_pause 在从机上停止重播主机
  3. 更改主密码

这样您将在一段时间内使用不同的密码(直到您恢复重播)