<productname>PostgreSQL</productname>のインストールは<productname>PostgreSQL</productname>コミュニティのリポジトリを使います。
</para>
<programlisting>
- # yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
- # yum install -y postgresql13-server
+# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
+# yum install -y postgresql13-server
</programlisting>
<para>
<productname>Pgpool-II</productname>のインストールは<productname>Pgpool-II</productname>開発コミュニティが提供するYumリポジトリを用いてインストールします。
</para>
<programlisting>
- # yum install http://www.pgpool.net/yum/rpms/4.2/redhat/rhel-7-x86_64/pgpool-II-release-4.2-1.noarch.rpm
- # yum install pgpool-II-pg13-*
+# yum install http://www.pgpool.net/yum/rpms/4.2/redhat/rhel-7-x86_64/pgpool-II-release-4.2-1.noarch.rpm
+# yum install pgpool-II-pg13-*
</programlisting>
</sect2>
まず、すべてのサーバにて<acronym>WAL</acronym>を格納するディレクトリ<filename>/var/lib/pgsql/archivedir</filename>を事前に作成します。この設定例では、プライマリサーバのみで<acronym>WAL</acronym>アーカイブをローカルで実施します。
</para>
<programlisting>
- [全サーバ]# su - postgres
- [全サーバ]$ mkdir /var/lib/pgsql/archivedir
+[全サーバ]# su - postgres
+[全サーバ]$ mkdir /var/lib/pgsql/archivedir
</programlisting>
<para>
</para>
<programlisting>
- listen_addresses = '*'
- archive_mode = on
- archive_command = 'cp "%p" "/var/lib/pgsql/archivedir/%f"'
- max_wal_senders = 10
- max_replication_slots = 10
- wal_level = replica
- hot_standby = on
- wal_log_hints = on
+listen_addresses = '*'
+archive_mode = on
+archive_command = 'cp "%p" "/var/lib/pgsql/archivedir/%f"'
+max_wal_senders = 10
+max_replication_slots = 10
+wal_level = replica
+hot_standby = on
+wal_log_hints = on
</programlisting>
</listitem>
</table>
<programlisting>
- [server1]# psql -U postgres -p 5432
- postgres=# SET password_encryption = 'scram-sha-256';
- postgres=# CREATE ROLE pgpool WITH LOGIN;
- postgres=# CREATE ROLE repl WITH REPLICATION LOGIN;
- postgres=# \password pgpool
- postgres=# \password repl
- postgres=# \password postgres
+[server1]# psql -U postgres -p 5432
+postgres=# SET password_encryption = 'scram-sha-256';
+postgres=# CREATE ROLE pgpool WITH LOGIN;
+postgres=# CREATE ROLE repl WITH REPLICATION LOGIN;
+postgres=# \password pgpool
+postgres=# \password repl
+postgres=# \password postgres
</programlisting>
<para>
以下のコマンドで<literal>pgpool</literal>ユーザをそのグループに所属させます。
</para>
<programlisting>
- GRANT pg_monitor TO pgpool;
+GRANT pg_monitor TO pgpool;
</programlisting>
<note>
<productname>Pgpool-II</productname>サーバと<productname>PostgreSQL</productname>バックエンドサーバが同じサブネットワークにあることを想定し、各ユーザが<literal>scram-sha-256</literal>認証方式で接続できるように、<filename>pg_hba.conf</filename>を編集しておきます。
</para>
<programlisting>
- host all all samenet scram-sha-256
- host replication all samenet scram-sha-256
+host all all samenet scram-sha-256
+host replication all samenet scram-sha-256
</programlisting>
</listitem>
自動フェイルオーバ、オンラインリカバリ機能を利用するには、<productname>Pgpool-II</productname>起動ユーザ(デフォルトでは<literal>root</literal>)と<literal>postgres</literal>ユーザ間、<literal>postgres</literal>ユーザと<literal>postgres</literal>ユーザ間が双方向に<emphasis>パスワードなし</emphasis>で<literal>SSH</literal>接続できる状態になっている必要があります。全サーバで以下のコマンドを実行し、<literal>SSH</literal>の設定を行います。生成される鍵ファイル名は<literal>id_rsa_pgpool</literal>とします。
</para>
<programlisting>
- [全サーバ]# cd ~/.ssh
- [全サーバ]# ssh-keygen -t rsa -f id_rsa_pgpool
- [全サーバ]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server1
- [全サーバ]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server2
- [全サーバ]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server3
-
- [全サーバ]# su - postgres
- [全サーバ]$ cd ~/.ssh
- [全サーバ]$ ssh-keygen -t rsa -f id_rsa_pgpool
- [全サーバ]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server1
- [全サーバ]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server2
- [全サーバ]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server3
+[全サーバ]# cd ~/.ssh
+[全サーバ]# ssh-keygen -t rsa -f id_rsa_pgpool
+[全サーバ]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server1
+[全サーバ]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server2
+[全サーバ]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server3
+
+[全サーバ]# su - postgres
+[全サーバ]$ cd ~/.ssh
+[全サーバ]$ ssh-keygen -t rsa -f id_rsa_pgpool
+[全サーバ]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server1
+[全サーバ]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server2
+[全サーバ]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server3
</programlisting>
<para>
設定後、<literal>root</literal>ユーザ及び<literal>postgres</literal>ユーザから<command>ssh postgres@serverX -i ~/.ssh/id_rsa_pgpool</command>コマンドを実行し、パスワード入力せずログインできることを確認してください。
<literal>repl</literal>ユーザのパスワード入力なしで、ストリーミングレプリケーションとオンラインリカバリを行うために、または<literal>postgres</literal>ユーザで<application>pg_rewind</application>を実行するために、すべてのサーバにて<literal>postgres</literal>ユーザのホームディレクト<filename>/var/lib/pgsql</filename> に<filename>.pgpass</filename>を作成・配置し、パーミッションを 600 に設定しておきます。
</para>
<programlisting>
- [全サーバ]# su - postgres
- [全サーバ]$ vi /var/lib/pgsql/.pgpass
- (以下を追加)
- server1:5432:replication:repl:<replユーザのパスワード>
- server2:5432:replication:repl:<replユーザのパスワード>
- server3:5432:replication:repl:<replユーザのパスワード>
- server1:5432:postgres:postgres:<postgresユーザのパスワード>
- server2:5432:postgres:postgres:<postgresユーザのパスワード>
- server3:5432:postgres:postgres:<postgresユーザのパスワード>
- [全サーバ]$ chmod 600 /var/lib/pgsql/.pgpass
+[全サーバ]# su - postgres
+[全サーバ]$ vi /var/lib/pgsql/.pgpass
+(以下を追加)
+server1:5432:replication:repl:<replユーザのパスワード>
+server2:5432:replication:repl:<replユーザのパスワード>
+server3:5432:replication:repl:<replユーザのパスワード>
+server1:5432:postgres:postgres:<postgresユーザのパスワード>
+server2:5432:postgres:postgres:<postgresユーザのパスワード>
+server3:5432:postgres:postgres:<postgresユーザのパスワード>
+[全サーバ]$ chmod 600 /var/lib/pgsql/.pgpass
</programlisting>
</listitem>
<productname>Pgpool-II</productname>や<productname>PostgreSQL</productname>に接続する際には、ファイアーウォールによって目的のポートが開けられていなければなりません。<systemitem>CentOS/RHEL7</systemitem>の場合、以下のように設定します。
</para>
<programlisting>
- [全サーバ]# firewall-cmd --permanent --zone=public --add-service=postgresql
- [全サーバ]# firewall-cmd --permanent --zone=public --add-port=9999/tcp --add-port=9898/tcp --add-port=9000/tcp --add-port=9694/udp
- [全サーバ]# firewall-cmd --reload
+[全サーバ]# firewall-cmd --permanent --zone=public --add-service=postgresql
+[全サーバ]# firewall-cmd --permanent --zone=public --add-port=9999/tcp --add-port=9898/tcp --add-port=9000/tcp --add-port=9694/udp
+[全サーバ]# firewall-cmd --reload
</programlisting>
</listitem>
<productname>Pgpool-II</productname>の自動起動設定を全てのサーバで行います。
</para>
<programlisting>
- [全サーバ]# systemctl enable pgpool.service
+[全サーバ]# systemctl enable pgpool.service
</programlisting>
<note>
RPMからインストールした場合、すべての<productname>Pgpool-II</productname>のサンプル設定ファイルは<filename>/etc/pgpool-II</filename>にあります。今回はストリーミングレプリケーションモードのテンプレートとして<filename>pgpool.conf.sample-stream</filename>サンプルファイルを使用します。
</para>
<programlisting>
- [全サーバ]# cp -p /etc/pgpool-II/pgpool.conf.sample-stream /etc/pgpool-II/pgpool.conf
+[全サーバ]# cp -p /etc/pgpool-II/pgpool.conf.sample-stream /etc/pgpool-II/pgpool.conf
</programlisting>
</sect3>
<productname>Pgpool-II</productname>が全てのIPアドレスから接続を受け付けるように、<xref linkend="GUC-LISTEN-ADDRESSES">パラメータに<literal>'*'</literal>を設定します。
</para>
<programlisting>
- listen_addresses = '*'
+listen_addresses = '*'
</programlisting>
</sect3>
<productname>Pgpool-II</productname> 4.0から、<xref linkend="GUC-SR-CHECK-PASSWORD">が空白の場合、<productname>Pgpool-II</productname>は空のパスワードを使用する前にまず<xref linkend="GUC-POOL-PASSWD">ファイルから<xref linkend="GUC-SR-CHECK-USER">に指定したユーザのパスワードを取得できるか試みます。
</para>
<programlisting>
- sr_check_user = 'pgpool'
- sr_check_password = ''
+sr_check_user = 'pgpool'
+sr_check_password = ''
</programlisting>
</sect3>
<xref linkend="GUC-HEALTH-CHECK-USER">、<xref linkend="GUC-HEALTH-CHECK-PASSWORD">は前述の<xref linkend="GUC-SR-CHECK-USER">、<xref linkend="GUC-SR-CHECK-PASSWORD">と同様に設定します。
</para>
<programlisting>
- health_check_period = 5
+health_check_period = 5
# Health check period
# Disabled (0) by default
- health_check_timeout = 30
+health_check_timeout = 30
# Health check timeout
# 0 means no timeout
- health_check_user = 'pgpool'
- health_check_password = ''
+health_check_user = 'pgpool'
+health_check_password = ''
- health_check_max_retries = 3
+health_check_max_retries = 3
</programlisting>
</sect3>
また、バックエンド情報を前述の<literal>server1</literal>、<literal>server2</literal>及び<literal>server3</literal>の設定に従って設定しておきます。複数バックエンドノードを定義する場合、以下のbackend_*などのパラメータ名の末尾にノードIDを表す数字を付加することで複数のバックエンドを指定することができます。
</para>
<programlisting>
- # - Backend Connection Settings -
+# - Backend Connection Settings -
- backend_hostname0 = 'server1'
+backend_hostname0 = 'server1'
# Host name or IP address to connect to for backend 0
- backend_port0 = 5432
+backend_port0 = 5432
# Port number for backend 0
- backend_weight0 = 1
+backend_weight0 = 1
# Weight for backend 0 (only in load balancing mode)
- backend_data_directory0 = '/var/lib/pgsql/13/data'
+backend_data_directory0 = '/var/lib/pgsql/13/data'
# Data directory for backend 0
- backend_flag0 = 'ALLOW_TO_FAILOVER'
+backend_flag0 = 'ALLOW_TO_FAILOVER'
# Controls various backend behavior
# ALLOW_TO_FAILOVER or DISALLOW_TO_FAILOVER
- backend_hostname1 = 'server2'
- backend_port1 = 5432
- backend_weight1 = 1
- backend_data_directory1 = '/var/lib/pgsql/13/data'
- backend_flag1 = 'ALLOW_TO_FAILOVER'
-
- backend_hostname2 = 'server3'
- backend_port2 = 5432
- backend_weight2 = 1
- backend_data_directory2 = '/var/lib/pgsql/13/data'
- backend_flag2 = 'ALLOW_TO_FAILOVER'
+backend_hostname1 = 'server2'
+backend_port1 = 5432
+backend_weight1 = 1
+backend_data_directory1 = '/var/lib/pgsql/13/data'
+backend_flag1 = 'ALLOW_TO_FAILOVER'
+
+backend_hostname2 = 'server3'
+backend_port2 = 5432
+backend_weight2 = 1
+backend_data_directory2 = '/var/lib/pgsql/13/data'
+backend_flag2 = 'ALLOW_TO_FAILOVER'
</programlisting>
<para>
<xref linkend="SQL-SHOW-POOL-NODES">コマンドでレプリケーション状態と同期レプリケーション状態を表示するには、<xref linkend="GUC-BACKEND-APPLICATION-NAME">パラメータを設定する必要があります。ここではそれぞれのホスト名を設定します。(<productname>Pgpool-II</productname> 4.1以降)
<programlisting>
- ...
- backend_application_name0 = 'server1'
- ...
- backend_application_name1 = 'server2'
- ...
- backend_application_name2 = 'server3'
+...
+backend_application_name0 = 'server1'
+...
+backend_application_name1 = 'server2'
+...
+backend_application_name2 = 'server3'
</programlisting>
</para>
</sect3>
前述の<link linkend="EXAMPLE-CLUSTER-PRE-SETUP">事前設定</link>の章で<productname>Pgpool-II</productname>の自動起動が設定済なので、ここでシステム全体を再起動するか、以下のコマンドを実行してください。
</para>
<programlisting>
- # systemctl start pgpool.service
+# systemctl start pgpool.service
</programlisting>
</listitem>
<listitem>
まず、<productname>Pgpool-II</productname>のオンラインリカバリ機能を利用し、スタンバイサーバを構築します。<command>pcp_recovery_node</command>コマンドで実行される<varname>recovery_1st_stage_command</varname>パラメータに指定した<filename>recovery_1st_stage</filename>と<filename>pgpool_remote_start</filename>スプリクトが実行されるので、この 2つのスクリプトが現在稼働中のプライマリサーバ<literal>server1</literal>のデータベースクラスタの下に存在することを確認します。
</para>
<programlisting>
- # pcp_recovery_node -h 192.168.137.150 -p 9898 -U pgpool -n 1
- Password:
- pcp_recovery_node -- Command Successful
+# pcp_recovery_node -h 192.168.137.150 -p 9898 -U pgpool -n 1
+Password:
+pcp_recovery_node -- Command Successful
- # pcp_recovery_node -h 192.168.137.150 -p 9898 -U pgpool -n 2
- Password:
- pcp_recovery_node -- Command Successful
+# pcp_recovery_node -h 192.168.137.150 -p 9898 -U pgpool -n 2
+Password:
+pcp_recovery_node -- Command Successful
</programlisting>
<para>
<literal>server2</literal>と<literal>server3</literal>の<productname>PostgreSQL</productname>がスタンバイとして起動されていることを確認します。
</para>
<programlisting>
- # psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
- Password for user pgpool:
- node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
- ---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
- 0 | server1 | 5432 | up | 0.333333 | primary | 0 | false | 0 | | | 2019-08-06 11:13:17
- 1 | server2 | 5432 | up | 0.333333 | standby | 0 | true | 0 | streaming | async | 2019-08-06 11:13:25
- 2 | server3 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:14:20
- (3 rows)
+# psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
+Password for user pgpool:
+node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
+---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
+0 | server1 | 5432 | up | 0.333333 | primary | 0 | false | 0 | | | 2019-08-06 11:13:17
+1 | server2 | 5432 | up | 0.333333 | standby | 0 | true | 0 | streaming | async | 2019-08-06 11:13:25
+2 | server3 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:14:20
+(3 rows)
</programlisting>
</sect3>
<command>pcp_watchdog_info</command>で<productname>Pgpool-II</productname>の<application>watchdog</application>の情報を確認します。最初に起動した<productname>Pgpool-II</productname>が「LEADER」になります。
</para>
<programlisting>
- # pcp_watchdog_info -h 192.168.137.150 -p 9898 -U pgpool
- Password:
- 3 YES server1:9999 Linux server1 server1
+# pcp_watchdog_info -h 192.168.137.150 -p 9898 -U pgpool
+Password:
+3 YES server1:9999 Linux server1 server1
- server1:9999 Linux server1 server1 9999 9000 4 LEADER #最初に起動されたサーバがLEADERになる
- server2:9999 Linux server2 server2 9999 9000 7 STANDBY #スタンバイとして稼働
- server3:9999 Linux server3 server3 9999 9000 7 STANDBY #スタンバイとして稼働
+server1:9999 Linux server1 server1 9999 9000 4 LEADER #最初に起動されたサーバがLEADERになる
+server2:9999 Linux server2 server2 9999 9000 7 STANDBY #スタンバイとして稼働
+server3:9999 Linux server3 server3 9999 9000 7 STANDBY #スタンバイとして稼働
</programlisting>
<para>
アクティブである<literal>server1</literal>の<productname>Pgpool-II</productname>を停止し、<literal>server2</literal>または<literal>server3</literal>がスタンバイからアクティブに昇格することを確認します。<literal>server1</literal>を停止する方法は<productname>Pgpool-II</productname>を停止する、またはマシンをシャットダウンします。ここでは、<productname>Pgpool-II</productname>を停止します。
</para>
<programlisting>
- [server1]# systemctl stop pgpool.service
+[server1]# systemctl stop pgpool.service
- # pcp_watchdog_info -p 9898 -h 192.168.137.150 -U pgpool
- Password:
- 3 YES server2:9999 Linux server2 server2
+# pcp_watchdog_info -p 9898 -h 192.168.137.150 -U pgpool
+Password:
+3 YES server2:9999 Linux server2 server2
- server2:9999 Linux server2 server2 9999 9000 4 LEADER #server2がアクティブに昇格
- server1:9999 Linux server1 server1 9999 9000 10 SHUTDOWN #server1が停止された
- server3:9999 Linux server3 server3 9999 9000 7 STANDBY #スタンバイとして稼働
+server2:9999 Linux server2 server2 9999 9000 4 LEADER #server2がアクティブに昇格
+server1:9999 Linux server1 server1 9999 9000 10 SHUTDOWN #server1が停止された
+server3:9999 Linux server3 server3 9999 9000 7 STANDBY #スタンバイとして稼働
</programlisting>
<para>
先ほど停止した<productname>Pgpool-II</productname>を再起動し、スタンバイとして起動したことを確認します。
</para>
<programlisting>
- [server1]# systemctl start pgpool.service
+[server1]# systemctl start pgpool.service
- [server1]# pcp_watchdog_info -p 9898 -h 192.168.137.150 -U pgpool
- Password:
- 3 YES server2:9999 Linux server2 server2
+[server1]# pcp_watchdog_info -p 9898 -h 192.168.137.150 -U pgpool
+Password:
+3 YES server2:9999 Linux server2 server2
- server2:9999 Linux server2 server2 9999 9000 4 LEADER
- server1:9999 Linux server1 server1 9999 9000 7 STANDBY
- server3:9999 Linux server3 server3 9999 9000 7 STANDBY
+server2:9999 Linux server2 server2 9999 9000 4 LEADER
+server1:9999 Linux server1 server1 9999 9000 7 STANDBY
+server3:9999 Linux server3 server3 9999 9000 7 STANDBY
</programlisting>
</sect3>
<command>psql</command>で仮想IPに接続し、バックエンドの情報を確認します。
</para>
<programlisting>
- # psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
- Password for user pgpool:
- node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
- ---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
- 0 | server1 | 5432 | up | 0.333333 | primary | 0 | false | 0 | | | 2019-08-06 11:13:17
- 1 | server2 | 5432 | up | 0.333333 | standby | 0 | true | 0 | streaming | async | 2019-08-06 11:13:25
- 2 | server3 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:14:20
- (3 rows)
+# psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
+Password for user pgpool:
+node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
+---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
+0 | server1 | 5432 | up | 0.333333 | primary | 0 | false | 0 | | | 2019-08-06 11:13:17
+1 | server2 | 5432 | up | 0.333333 | standby | 0 | true | 0 | streaming | async | 2019-08-06 11:13:25
+2 | server3 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:14:20
+(3 rows)
</programlisting>
<para>
次にプライマリである<literal>server1</literal>の<productname>PostgreSQL</productname>を停止し、フェイルオーバするかどうか確認してみます。
</para>
<programlisting>
- [server1]$ pg_ctl -D /var/lib/pgsql/13/data -m immediate stop
+[server1]$ pg_ctl -D /var/lib/pgsql/13/data -m immediate stop
</programlisting>
<para>
<literal>ノード1</literal>を停止後、フェイルオーバが発生し、<literal>server2</literal>がプライマリに昇格したことを確認します。
</para>
<programlisting>
- # psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
- Password for user pgpool:
- node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
- ---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
- 0 | server1 | 5432 | down | 0.333333 | standby | 0 | false | 0 | | | 2019-08-06 11:36:03
- 1 | server2 | 5432 | up | 0.333333 | primary | 0 | true | 0 | | | 2019-08-06 11:36:03
- 2 | server3 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:36:15
- (3 rows)
+# psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
+Password for user pgpool:
+node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
+---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
+0 | server1 | 5432 | down | 0.333333 | standby | 0 | false | 0 | | | 2019-08-06 11:36:03
+1 | server2 | 5432 | up | 0.333333 | primary | 0 | true | 0 | | | 2019-08-06 11:36:03
+2 | server3 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:36:15
+(3 rows)
</programlisting>
<para>
</para>
<programlisting>
- [server3]# psql -h server3 -p 5432 -U pgpool postgres -c "select pg_is_in_recovery()"
- pg_is_in_recovery
- -------------------
- t
-
- [server2]# psql -h server2 -p 5432 -U pgpool postgres -c "select pg_is_in_recovery()"
- pg_is_in_recovery
- -------------------
- f
-
- [server2]# psql -h server2 -p 5432 -U pgpool postgres -c "select * from pg_stat_replication" -x
- -[ RECORD 1 ]----+------------------------------
- pid | 11059
- usesysid | 16392
- usename | repl
- application_name | server3
- client_addr | 192.168.137.103
- client_hostname |
- client_port | 48694
- backend_start | 2019-08-06 11:36:07.479161+09
- backend_xmin |
- state | streaming
- sent_lsn | 0/75000148
- write_lsn | 0/75000148
- flush_lsn | 0/75000148
- replay_lsn | 0/75000148
- write_lag |
- flush_lag |
- replay_lag |
- sync_priority | 0
- sync_state | async
- reply_time | 2019-08-06 11:42:59.823961+09
+[server3]# psql -h server3 -p 5432 -U pgpool postgres -c "select pg_is_in_recovery()"
+pg_is_in_recovery
+-------------------
+t
+
+[server2]# psql -h server2 -p 5432 -U pgpool postgres -c "select pg_is_in_recovery()"
+pg_is_in_recovery
+-------------------
+f
+
+[server2]# psql -h server2 -p 5432 -U pgpool postgres -c "select * from pg_stat_replication" -x
+-[ RECORD 1 ]----+------------------------------
+pid | 11059
+usesysid | 16392
+usename | repl
+application_name | server3
+client_addr | 192.168.137.103
+client_hostname |
+client_port | 48694
+backend_start | 2019-08-06 11:36:07.479161+09
+backend_xmin |
+state | streaming
+sent_lsn | 0/75000148
+write_lsn | 0/75000148
+flush_lsn | 0/75000148
+replay_lsn | 0/75000148
+write_lag |
+flush_lag |
+replay_lag |
+sync_priority | 0
+sync_state | async
+reply_time | 2019-08-06 11:42:59.823961+09
</programlisting>
</sect3>
次に、<productname>Pgpool-II</productname>のオンラインリカバリ機能を利用し、先ほど停止した旧プライマリサーバをスタンバイとして復旧させます。<command>pcp_recovery_node</command>コマンドで実行される<varname>recovery_1st_stage_command</varname>パラメータに指定した<filename>recovery_1st_stage</filename>と<filename>pgpool_remote_start</filename>スプリクトが現在稼働中のプライマリサーバ<literal>server2</literal>のデータベースクラスタの下に存在することを確認します。
</para>
<programlisting>
- # pcp_recovery_node -h 192.168.137.150 -p 9898 -U pgpool -n 0
- Password:
- pcp_recovery_node -- Command Successful
+# pcp_recovery_node -h 192.168.137.150 -p 9898 -U pgpool -n 0
+Password:
+pcp_recovery_node -- Command Successful
</programlisting>
<para>
<literal>ノード1</literal>がスタンバイとして起動されたことを確認します。
</para>
<programlisting>
- # psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
- Password for user pgpool:
- node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
- ---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
- 0 | server1 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:48:05
- 1 | server2 | 5432 | up | 0.333333 | primary | 0 | false | 0 | | | 2019-08-06 11:36:03
- 2 | server3 | 5432 | up | 0.333333 | standby | 0 | true | 0 | streaming | async | 2019-08-06 11:36:15
- (3 rows)
+# psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
+Password for user pgpool:
+node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
+---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
+0 | server1 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:48:05
+1 | server2 | 5432 | up | 0.333333 | primary | 0 | false | 0 | | | 2019-08-06 11:36:03
+2 | server3 | 5432 | up | 0.333333 | standby | 0 | true | 0 | streaming | async | 2019-08-06 11:36:15
+(3 rows)
</programlisting>
<para>
以上で、動作確認が完了です。
Install <productname>PostgreSQL</productname> using <productname>PostgreSQL</productname> YUM repository.
</para>
<programlisting>
- # yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
- # yum install -y postgresql13-server
+# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
+# yum install -y postgresql13-server
</programlisting>
<para>
Install <productname>Pgpool-II</productname> by using Pgpool-II YUM repository.
</para>
<programlisting>
- # yum install -y http://www.pgpool.net/yum/rpms/4.1/redhat/rhel-7-x86_64/pgpool-II-release-4.1-2.noarch.rpm
- # yum install -y pgpool-II-pg13-*
+# yum install -y http://www.pgpool.net/yum/rpms/4.1/redhat/rhel-7-x86_64/pgpool-II-release-4.1-2.noarch.rpm
+# yum install -y pgpool-II-pg13-*
</programlisting>
</sect2>
<acronym>WAL</acronym> locally.
</para>
<programlisting>
- [all servers]# su - postgres
- [all servers]$ mkdir /var/lib/pgsql/archivedir
+[all servers]# su - postgres
+[all servers]$ mkdir /var/lib/pgsql/archivedir
</programlisting>
<para>
Since the Primary may become a Standby later, we set <varname>hot_standby = on</varname>.
</para>
<programlisting>
- listen_addresses = '*'
- archive_mode = on
- archive_command = 'cp "%p" "/var/lib/pgsql/archivedir/%f"'
- max_wal_senders = 10
- max_replication_slots = 10
- wal_level = replica
- hot_standby = on
- wal_log_hints = on
+listen_addresses = '*'
+archive_mode = on
+archive_command = 'cp "%p" "/var/lib/pgsql/archivedir/%f"'
+max_wal_senders = 10
+max_replication_slots = 10
+wal_level = replica
+hot_standby = on
+wal_log_hints = on
</programlisting>
<para>
We use the online recovery functionality of <productname>Pgpool-II</productname> to setup standby server after the primary server is started.
</table>
<programlisting>
- [server1]# psql -U postgres -p 5432
- postgres=# SET password_encryption = 'scram-sha-256';
- postgres=# CREATE ROLE pgpool WITH LOGIN;
- postgres=# CREATE ROLE repl WITH REPLICATION LOGIN;
- postgres=# \password pgpool
- postgres=# \password repl
- postgres=# \password postgres
+[server1]# psql -U postgres -p 5432
+postgres=# SET password_encryption = 'scram-sha-256';
+postgres=# CREATE ROLE pgpool WITH LOGIN;
+postgres=# CREATE ROLE repl WITH REPLICATION LOGIN;
+postgres=# \password pgpool
+postgres=# \password repl
+postgres=# \password postgres
</programlisting>
<para>
to <literal>pgpool</literal>:
</para>
<programlisting>
- GRANT pg_monitor TO pgpool;
+GRANT pg_monitor TO pgpool;
</programlisting>
<note>
<para>
enable <literal>scram-sha-256</literal> authentication method.
</para>
<programlisting>
- host all all samenet scram-sha-256
- host replication all samenet scram-sha-256
+host all all samenet scram-sha-256
+host replication all samenet scram-sha-256
</programlisting>
</listitem>
to set up passwordless <literal>SSH</literal>. The generated key file name is <literal>id_rsa_pgpool</literal>.
</para>
<programlisting>
- [all servers]# cd ~/.ssh
- [all servers]# ssh-keygen -t rsa -f id_rsa_pgpool
- [all servers]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server1
- [all servers]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server2
- [all servers]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server3
-
- [all servers]# su - postgres
- [all servers]$ cd ~/.ssh
- [all servers]$ ssh-keygen -t rsa -f id_rsa_pgpool
- [all servers]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server1
- [all servers]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server2
- [all servers]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server3
+[all servers]# cd ~/.ssh
+[all servers]# ssh-keygen -t rsa -f id_rsa_pgpool
+[all servers]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server1
+[all servers]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server2
+[all servers]# ssh-copy-id -i id_rsa_pgpool.pub postgres@server3
+
+[all servers]# su - postgres
+[all servers]$ cd ~/.ssh
+[all servers]$ ssh-keygen -t rsa -f id_rsa_pgpool
+[all servers]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server1
+[all servers]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server2
+[all servers]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server3
</programlisting>
<para>
After setting, use <command>ssh postgres@serverX -i ~/.ssh/id_rsa_pgpool</command> command to
<literal>600</literal> on each <productname>PostgreSQL</productname> server.
</para>
<programlisting>
- [all servers]# su - postgres
- [all servers]$ vi /var/lib/pgsql/.pgpass
- server1:5432:replication:repl:<repl user password>
- server2:5432:replication:repl:<repl user passowrd>
- server3:5432:replication:repl:<repl user passowrd>
- server1:5432:postgres:postgres:<postgres user passowrd>
- server2:5432:postgres:postgres:<postgres user passowrd>
- server3:5432:postgres:postgres:<postgres user passowrd>
- [all servers]$ chmod 600 /var/lib/pgsql/.pgpass
+[all servers]# su - postgres
+[all servers]$ vi /var/lib/pgsql/.pgpass
+server1:5432:replication:repl:<repl user password>
+server2:5432:replication:repl:<repl user passowrd>
+server3:5432:replication:repl:<repl user passowrd>
+server1:5432:postgres:postgres:<postgres user passowrd>
+server2:5432:postgres:postgres:<postgres user passowrd>
+server3:5432:postgres:postgres:<postgres user passowrd>
+[all servers]$ chmod 600 /var/lib/pgsql/.pgpass
</programlisting>
</listitem>
When connect to <productname>Pgpool-II</productname> and <productname>PostgreSQL</productname> servers, the target port must be accessible by enabling firewall management softwares. Following is an example for <systemitem>CentOS/RHEL7</systemitem>.
</para>
<programlisting>
- [all servers]# firewall-cmd --permanent --zone=public --add-service=postgresql
- [all servers]# firewall-cmd --permanent --zone=public --add-port=9999/tcp --add-port=9898/tcp --add-port=9000/tcp --add-port=9694/udp
- [all servers]# firewall-cmd --reload
+[all servers]# firewall-cmd --permanent --zone=public --add-service=postgresql
+[all servers]# firewall-cmd --permanent --zone=public --add-port=9999/tcp --add-port=9898/tcp --add-port=9000/tcp --add-port=9694/udp
+[all servers]# firewall-cmd --reload
</programlisting>
</listitem>
We set <productname>Pgpool-II</productname> to start automatically on all servers.
</para>
<programlisting>
- [all servers]# systemctl enable pgpool.service
+[all servers]# systemctl enable pgpool.service
</programlisting>
<note>
In this example, we copy the sample configuration file for streaming replication mode.
</para>
<programlisting>
- # cp -p /etc/pgpool-II/pgpool.conf.sample-stream /etc/pgpool-II/pgpool.conf
+# cp -p /etc/pgpool-II/pgpool.conf.sample-stream /etc/pgpool-II/pgpool.conf
</programlisting>
</sect3>
To allow Pgpool-II to accept all incoming connections, we set <varname>listen_addresses = '*'</varname>.
</para>
<programlisting>
- listen_addresses = '*'
+listen_addresses = '*'
</programlisting>
</sect3>
specific user from <xref linkend="GUC-POOL-PASSWD"> file before using the empty password.
</para>
<programlisting>
- sr_check_user = 'pgpool'
- sr_check_password = ''
+sr_check_user = 'pgpool'
+sr_check_password = ''
</programlisting>
</sect3>
the same way like <xref linkend="GUC-SR-CHECK-USER"> and <xref linkend="GUC-SR-CHECK-PASSWORD">.
</para>
<programlisting>
- health_check_period = 5
+health_check_period = 5
# Health check period
# Disabled (0) by default
- health_check_timeout = 30
+health_check_timeout = 30
# Health check timeout
# 0 means no timeout
- health_check_user = 'pgpool'
- health_check_password = ''
+health_check_user = 'pgpool'
+health_check_password = ''
- health_check_max_retries = 3
+health_check_max_retries = 3
</programlisting>
</sect3>
Multiple backends can be specified by adding a number at the end of the parameter name.
</para>
<programlisting>
- # - Backend Connection Settings -
+# - Backend Connection Settings -
- backend_hostname0 = 'server1'
+backend_hostname0 = 'server1'
# Host name or IP address to connect to for backend 0
- backend_port0 = 5432
+backend_port0 = 5432
# Port number for backend 0
- backend_weight0 = 1
+backend_weight0 = 1
# Weight for backend 0 (only in load balancing mode)
- backend_data_directory0 = '/var/lib/pgsql/13/data'
+backend_data_directory0 = '/var/lib/pgsql/13/data'
# Data directory for backend 0
- backend_flag0 = 'ALLOW_TO_FAILOVER'
+backend_flag0 = 'ALLOW_TO_FAILOVER'
# Controls various backend behavior
# ALLOW_TO_FAILOVER or DISALLOW_TO_FAILOVER
- backend_hostname1 = 'server2'
- backend_port1 = 5432
- backend_weight1 = 1
- backend_data_directory1 = '/var/lib/pgsql/13/data'
- backend_flag1 = 'ALLOW_TO_FAILOVER'
-
- backend_hostname2 = 'server3'
- backend_port2 = 5432
- backend_weight2 = 1
- backend_data_directory2 = '/var/lib/pgsql/13/data'
- backend_flag2 = 'ALLOW_TO_FAILOVER'
+backend_hostname1 = 'server2'
+backend_port1 = 5432
+backend_weight1 = 1
+backend_data_directory1 = '/var/lib/pgsql/13/data'
+backend_flag1 = 'ALLOW_TO_FAILOVER'
+
+backend_hostname2 = 'server3'
+backend_port2 = 5432
+backend_weight2 = 1
+backend_data_directory2 = '/var/lib/pgsql/13/data'
+backend_flag2 = 'ALLOW_TO_FAILOVER'
</programlisting>
<para>
To show "replication_state" and "replication_sync_state" column in <xref linkend="SQL-SHOW-POOL-NODES">
Here we specify each backend's hostname in these parameters. (<productname>Pgpool-II</productname> 4.1 or later)
</para>
<programlisting>
- ...
- backend_application_name0 = 'server1'
- ...
- backend_application_name1 = 'server2'
- ...
- backend_application_name2 = 'server3'
+...
+backend_application_name0 = 'server1'
+...
+backend_application_name1 = 'server2'
+...
+backend_application_name2 = 'server3'
</programlisting>
</sect3>
See <xref linkend="GUC-FAILOVER-COMMAND"> for more details about each character.
</para>
<programlisting>
- failover_command = '/etc/pgpool-II/failover.sh %d %h %p %D %m %H %M %P %r %R %N %S'
- follow_primary_command = '/etc/pgpool-II/follow_primary.sh %d %h %p %D %m %H %M %P %r %R'
+failover_command = '/etc/pgpool-II/failover.sh %d %h %p %D %m %H %M %P %r %R %N %S'
+follow_primary_command = '/etc/pgpool-II/follow_primary.sh %d %h %p %D %m %H %M %P %r %R'
</programlisting>
<note>
<para>
<productname>Pgpool-II</productname>, restart the whole system or execute the following command.
</para>
<programlisting>
- # systemctl start pgpool.service
+# systemctl start pgpool.service
</programlisting>
</listitem>
<listitem>
Stopping <productname>Pgpool-II</productname>
</para>
<programlisting>
- # systemctl stop pgpool.service
+# systemctl stop pgpool.service
</programlisting>
</listitem>
</itemizedlist>
<literal>server2</literal>, <literal>server3</literal> by using the following command.
</para>
<programlisting>
- # systemctl start pgpool.service
+# systemctl start pgpool.service
</programlisting>
<sect3 id="example-cluster-try-standby">
<title>Set up PostgreSQL standby server</title>
<para>
- First, we should set up <productname>PostgreSQL</productname> standby server by
- using <productname>Pgpool-II</productname> online recovery functionality. Ensure
- that <filename>recovery_1st_stage</filename> and <filename>pgpool_remote_start</filename>
- scripts used by <command>pcp_recovery_node</command> command are in database
+ First, we should set up <productname>PostgreSQL</productname> standby server by
+ using <productname>Pgpool-II</productname> online recovery functionality. Ensure
+ that <filename>recovery_1st_stage</filename> and <filename>pgpool_remote_start</filename>
+ scripts used by <command>pcp_recovery_node</command> command are in database
cluster directory of <productname>PostgreSQL</productname> primary server (<literal>server1</literal>).
</para>
<programlisting>
are started as <productname>PostgreSQL</productname> standby server.
</para>
<programlisting>
- # psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
- Password for user pgpool
- node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
- ---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
- 0 | server1 | 5432 | up | 0.333333 | primary | 0 | false | 0 | | | 2019-08-06 11:13:17
- 1 | server2 | 5432 | up | 0.333333 | standby | 0 | true | 0 | streaming | async | 2019-08-06 11:13:25
- 2 | server3 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:14:20
- (3 rows)
+# psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
+Password for user pgpool
+node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
+---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
+0 | server1 | 5432 | up | 0.333333 | primary | 0 | false | 0 | | | 2019-08-06 11:13:17
+1 | server2 | 5432 | up | 0.333333 | standby | 0 | true | 0 | streaming | async | 2019-08-06 11:13:25
+2 | server3 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:14:20
+(3 rows)
</programlisting>
</sect3>
and verify the backend information.
</para>
<programlisting>
- # psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
- Password for user pgpool:
- node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
- ---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
- 0 | server1 | 5432 | up | 0.333333 | primary | 0 | false | 0 | | | 2019-08-06 11:13:17
- 1 | server2 | 5432 | up | 0.333333 | standby | 0 | true | 0 | streaming | async | 2019-08-06 11:13:25
- 2 | server3 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:14:20
- (3 rows)
+# psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
+Password for user pgpool:
+node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
+---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
+0 | server1 | 5432 | up | 0.333333 | primary | 0 | false | 0 | | | 2019-08-06 11:13:17
+1 | server2 | 5432 | up | 0.333333 | standby | 0 | true | 0 | streaming | async | 2019-08-06 11:13:25
+2 | server3 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:14:20
+(3 rows)
</programlisting>
<para>
Next, stop primary <productname>PostgreSQL</productname> server
<literal>server2</literal> becomes new primary DB.
</para>
<programlisting>
- # psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
- Password for user pgpool:
- node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
- ---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
- 0 | server1 | 5432 | down | 0.333333 | standby | 0 | false | 0 | | | 2019-08-06 11:36:03
- 1 | server2 | 5432 | up | 0.333333 | primary | 0 | true | 0 | | | 2019-08-06 11:36:03
- 2 | server3 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:36:15
- (3 rows)
+# psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
+Password for user pgpool:
+node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
+---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
+0 | server1 | 5432 | down | 0.333333 | standby | 0 | false | 0 | | | 2019-08-06 11:36:03
+1 | server2 | 5432 | up | 0.333333 | primary | 0 | true | 0 | | | 2019-08-06 11:36:03
+2 | server3 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:36:15
+(3 rows)
</programlisting>
<para>
<literal>server3</literal> is running as standby of new primary <literal>server2</literal>.
Then verify that <literal>server1</literal> is started as a standby.
</para>
<programlisting>
- # psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
- Password for user pgpool:
- node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
- ---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
- 0 | server1 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:48:05
- 1 | server2 | 5432 | up | 0.333333 | primary | 0 | false | 0 | | | 2019-08-06 11:36:03
- 2 | server3 | 5432 | up | 0.333333 | standby | 0 | true | 0 | streaming | async | 2019-08-06 11:36:15
- (3 rows)
+# psql -h 192.168.137.150 -p 9999 -U pgpool postgres -c "show pool_nodes"
+Password for user pgpool:
+node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | replication_state | replication_sync_state | last_status_change
+---------+----------+------+--------+-----------+---------+------------+-------------------+-------------------+-------------------+------------------------+---------------------
+0 | server1 | 5432 | up | 0.333333 | standby | 0 | false | 0 | streaming | async | 2019-08-06 11:48:05
+1 | server2 | 5432 | up | 0.333333 | primary | 0 | false | 0 | | | 2019-08-06 11:36:03
+2 | server3 | 5432 | up | 0.333333 | standby | 0 | true | 0 | streaming | async | 2019-08-06 11:36:15
+(3 rows)
</programlisting>
</sect3>
</sect2>