1 つのプライマリ ノードと 1 つのセカンダリ ノードで pg_auto フェイルオーバーを使用して postgres を作成しました。このリンクをたどっています。https://www.citusdata.com/blog/2019/05/30/introducing-pg-auto-failover/ --auth タグなしで、モニターと postgres ノードでフェイルオーバーとレプリケーションをテストしました。認証なしで正常に動作します。ここにコマンドがあります
export PATH="$PATH:/usr/pgsql-11/bin"
pg_autoctl create monitor --nodename 10.247.74.66 --pgport 6000
export PGDATA=/var/lib/pgsql/node_a
pg_autoctl create postgres --nodename 10.247.74.66 --pgport 6001 --dbname test --monitor postgres://autoctl_node@10.247.74.66:6000/pg_auto_failover
pg_autoctl run
2 番目のノード
export PATH="$PATH:/usr/pgsql-11/bin"
export PGDATA=/var/lib/pgsql/node_b
pg_autoctl create postgres --nodename 10.247.74.67 --pgport 6002 --dbname test --monitor postgres://autoctl_node@10.247.74.66:6000/pg_auto_failover
pg_autoctl run
pg_autoctl show state
Name | Port | Group | Node | Current State | Assigned State
-------------+--------+-------+-------+-------------------+------------------
10.247.74.66 | 6001 | 0 | 1 | primary | primary
10.247.74.67 | 6002 | 0 | 2 | secondary | secondary
--auth md5 として監視ノードに認証を追加し、このリンクに従って pg_auto_failover データベースの autoctl_node のパスワードを変更しましたhttps://pg-auto-failover.readthedocs.io/en/latest/security.html監視ノードも正常に動作します. しかし、プライマリ node_a と node_b に --auth md5 を追加すると、ノードは待機と追いつきでスタックします。
export PGDATA=/var/lib/pgsql/monitor
pg_autoctl create monitor --auth md5 --nodename 10.247.74.66 --pgport 6000
export PGDATA=/var/lib/pgsql/node_a
pg_autoctl create postgres --auth md5 --nodename 10.247.74.66 --pgport 6001 --dbname test --monitor postgres://autoctl_node:BMGAAES123z3RZ5ZSwq@10.247.74.66:6000/pg_auto_failover
pg_autoctl config set replication.password ZUp3aEAy123BEmTb44A
pg_autoctl run
export PGPASSWORD=ZUp3aEAy123BEmTb44A
export PGDATA=/var/lib/pgsql/node_b
pg_autoctl create postgres --auth md5 --nodename 10.247.74.67 --pgport 6002 --dbname test --monitor postgres://autoctl_node:BMGAAES123z3RZ5ZSwq@10.247.74.66:6000/pg_auto_failover
pg_autoctl config set replication.password ZUp3aEAy123BEmTb44A
pg_autoctl run
Name | Port | Group | Node | Current State | Assigned State
-------------+--------+-------+-------+-------------------+------------------
10.247.74.66 | 6001 | 0 | 1 | wait_primary | wait_primary
10.247.74.67 | 6002 | 0 | 2 | catchingup | catchingup
プライマリ node_a のログ
2021-04-02 19:06:32.028 IST [19588] LOG: connection received: host=10.247.74.66 port=52598
2021-04-02 19:06:32.031 IST [19588] FATAL: password authentication failed for user "pgautofailover_monitor"
2021-04-02 19:06:32.031 IST [19588] DETAIL: User "pgautofailover_monitor" has no password assigned.
Connection matched pg_hba.conf line 95: "host all "pgautofailover_monitor" 10.247.74.66/32 md5 # Auto-generated by pg_auto_failover"
2021-04-02 19:06:34.034 IST [19609] LOG: connection received: host=10.247.74.66 port=52618
2021-04-02 19:06:34.036 IST [19609] FATAL: password authentication failed for user "pgautofailover_monitor"
2021-04-02 19:06:34.036 IST [19609] DETAIL: User "pgautofailover_monitor" has no password assigned.
Connection matched pg_hba.conf line 95: "host all "pgautofailover_monitor" 10.247.74.66/32 md5 # Auto-generated by pg_auto_failover"
2021-04-02 19:06:36.041 IST [19626] LOG: connection received: host=10.247.74.66 port=52628
2021-04-02 19:06:36.043 IST [19626] FATAL: password authentication failed for user "pgautofailover_monitor"
2021-04-02 19:06:36.043 IST [19626] DETAIL: User "pgautofailover_monitor" has no password assigned.
Connection matched pg_hba.conf line 95: "host all "pgautofailover_monitor" 10.247.74.66/32 md5 # Auto-generated by pg_auto_failover"
セカンダリ node_b のログ
2021-04-02 19:08:32.099 IST [8755] LOG: connection received: host=10.247.74.66 port=41682
2021-04-02 19:08:32.101 IST [8755] FATAL: password authentication failed for user "pgautofailover_monitor"
2021-04-02 19:08:32.101 IST [8755] DETAIL: User "pgautofailover_monitor" has no password assigned.
Connection matched pg_hba.conf line 95: "host all "pgautofailover_monitor" 10.247.74.66/32 md5 # Auto-generated by pg_auto_failover"
2021-04-02 19:08:34.105 IST [8758] LOG: connection received: host=10.247.74.66 port=41732
2021-04-02 19:08:34.107 IST [8758] FATAL: password authentication failed for user "pgautofailover_monitor"
2021-04-02 19:08:34.107 IST [8758] DETAIL: User "pgautofailover_monitor" has no password assigned.
Connection matched pg_hba.conf line 95: "host all "pgautofailover_monitor" 10.247.74.66/32 md5 # Auto-generated by pg_auto_failover"
2021-04-02 19:08:36.111 IST [8760] LOG: connection received: host=10.247.74.66 port=41762
2021-04-02 19:08:36.115 IST [8760] FATAL: password authentication failed for user "pgautofailover_monitor"
2021-04-02 19:08:36.115 IST [8760] DETAIL: User "pgautofailover_monitor" has no password assigned.
Connection matched pg_hba.conf line 95: "host all "pgautofailover_monitor" 10.247.74.66/32 md5 # Auto-generated by pg_auto_failover"