-->
<title><productname>Pgpool-II</productname>の設定</title>
<para>
- <!--
- Mostly the <productname>Pgpool-II</productname> configurations for this
- example will be same as in the <xref linkend="example-watchdog">, except the
- <xref linkend="guc-delegate-ip"> which we will not set in this example instead
- we will use <xref linkend="guc-wd-escalation-command"> and
- <xref linkend="guc-wd-de-escalation-command"> to switch the
- Elastic IP address to the leader/Active <productname>Pgpool-II</productname> node.
- -->
- この例の設定は<xref linkend="example-watchdog">とほとんど同じになりますが、<xref linkend="guc-delegate-ip">を設定せず、代わりに<xref linkend="guc-wd-escalation-command">と<xref linkend="guc-wd-de-escalation-command">を使ってleader/Active <productname>Pgpool-II</productname>ノードのElastic IPアドレスを切り替えるのが異なります。
+ この例の設定は<xref linkend="example-cluster">とほとんど同じになりますが、<xref linkend="guc-delegate-ip">を設定せず、代わりに<xref linkend="guc-wd-escalation-command">と<xref linkend="guc-wd-de-escalation-command">を使ってleader/Active <productname>Pgpool-II</productname>ノードのElastic IPアドレスを切り替えるのが異なります。
</para>
- <sect3 id="example-AWS-pgpool-config-instance-1">
- <!--
- <title><productname>Pgpool-II</productname> configurations on Instance-1</title>
- -->
- <title>Instance-1における<productname>Pgpool-II</productname>の設定</title>
- <para>
-
- <programlisting>
- use_watchdog = on
- delegate_IP = ''
- wd_hostname = 'instance-1-private-ip'
- other_pgpool_hostname0 = 'instance-2-private-ip'
- other_pgpool_port0 = 9999
- other_wd_port0 = 9000
- wd_escalation_command = '$path_to_script/aws-escalation.sh'
- wd_de_escalation_command = '$path_to_script/aws-de-escalation.sh'
- </programlisting>
-
- </para>
- </sect3>
-
- <sect3 id="example-AWS-pgpool-config-instance-2">
- <!--
- <title><productname>Pgpool-II</productname> configurations on Instance-2</title>
- -->
- <title>Instance-2における<productname>Pgpool-II</productname>の設定</title>
- <para>
-
- <programlisting>
- use_watchdog = on
- delegate_IP = ''
- wd_hostname = 'instance-2-private-ip'
- other_pgpool_hostname0 = 'instance-1-private-ip'
- other_pgpool_port0 = 9999
- other_wd_port0 = 9000
- wd_escalation_command = '$path_to_script/aws-escalation.sh'
- wd_de_escalation_command = '$path_to_script/aws-de-escalation.sh'
- </programlisting>
-
- </para>
- </sect3>
+ <programlisting>
+use_watchdog = on
+delegate_IP = ''
+...
+wd_escalation_command = '$path_to_script/aws-escalation.sh'
+wd_de_escalation_command = '$path_to_script/aws-de-escalation.sh'
+ </programlisting>
</sect2>
<sect2 id="example-AWS-pgpool-aws-escalation-instance">
</programlisting>
<para>
- ハートビート通信用の各<productname>Pgpool-II</productname>サーバ情報を設定しておきます。
+ <literal>Watchdog</literal>死活監視の設定では、死活監視の方法を指定する<xref linkend="guc-wd-lifecheck-method">、
+ 監視間隔(秒)を指定する<xref linkend="guc-wd-interval">を設定します。
+ この設定例では、死活監視の方法は<literal>hearbeat</literal>を用います。
+ </para>
+
+ <programlisting>
+wd_lifecheck_method = 'heartbeat'
+ # Method of watchdog lifecheck ('heartbeat' or 'query' or 'external')
+ # (change requires restart)
+wd_interval = 10
+ # lifecheck interval (sec) > 0
+ # (change requires restart)
+ </programlisting>
+ <para>
+ <xref linkend="guc-wd-lifecheck-method">が<literal>heartbeat</literal>に設定されている場合、
+ heartbeat通信用の各<productname>Pgpool-II</productname>サーバ情報を設定しておきます。
</para>
<programlisting>
heartbeat_hostname0 = 'server1'
heartbeat_port2 = 9694
heartbeat_device2 = ''
</programlisting>
+ <para>
+ <xref linkend="guc-wd-lifecheck-method">が<literal>heartbeat</literal>に設定されている場合、
+ 障害と判断する秒数を指定する<xref linkend="guc-wd-heartbeat-deadtime">、
+ ハートビート信号の送信間隔(秒)を指定する<xref linkend="guc-wd-heartbeat-keepalive">を設定します。
+ </para>
+ <programlisting>
+wd_heartbeat_keepalive = 2
+ # Interval time of sending heartbeat signal (sec)
+ # (change requires restart)
+wd_heartbeat_deadtime = 30
+ # Deadtime interval for heartbeat signal (sec)
+ # (change requires restart)
+ </programlisting>
+ <note>
+ <para>
+ Watchdogノードの数が偶数の場合は、<xref linkend="guc-enable-consensus-with-half-votes">パラメータをonにする必要があります。
+ </para>
+ </note>
<note>
<para>
use_watchdog = onの場合は、pgpoolノード番号を<filename>pgpool_node_id</filename>に設定する必要があります。
+++ /dev/null
-<!-- doc/src/sgml/example-watchdog.sgml -->
-
-<sect1 id="example-watchdog">
- <!--
- <title>Watchdog Configuration Example</title>
- -->
- <title>Watchdogの設定例</title>
-
- <para>
- <!--
- This tutorial explains the simple way to try "Watchdog".
- What you need is 2 Linux boxes on which <productname>
- Pgpool-II</productname> is installed and a <productname>PostgreSQL</>
- on the same machine or in the other one. It is enough
- that 1 node for backend exists.
- You can use watchdog with <productname>
- Pgpool-II</productname> in any mode: replication mode,
- native replication mode and raw mode.
- -->
- ここではwatchdogの機能を簡単に試す方法を説明します。
- Linux マシン2台にそれぞれ <productname>Pgpool-II</> がインストールされているものとします。
- また、いずれかのマシンか第 3 のマシンに、<productname>PostgreSQL</> がインストールされて稼働しているものとします。
- バックエンドノードは1台でかまいません。
- <productname>Pgpool-II</> がどのモードで稼働していても(レプリケーションモードでもマスタースレーブモードでも)、watchdogを利用することができます。
- </para>
- <para>
- <!--
- This example uses use "osspc16" as an Active node and
- "osspc20" as a Standby node. "Someserver" means one of them.
- -->
- この例では、「osspc16」をActiveノードとして、「osspc20」をStandbyノードとして使います。
- 「someserver」は、これらのどちらかということを意味しています。
- </para>
-
- <sect2 id="example-watchdog-configuration">
- <!--
- <title>Common configurations</title>
- -->
- <title>共通設定</title>
- <para>
- <!--
- Set the following parameters in both of active and standby nodes.
- -->
- アクティブとスタンバイの両サーバで以下を設定します。
- </para>
-
- <sect3 id="example-watchdog-config-enable">
- <!--
- <title>Enabling watchdog</title>
- -->
- <title>Watchdogの有効化</title>
- <para>
- <!--
- First of all, set <xref linkend="guc-use-watchdog"> to on.
- -->
- まず、<xref linkend="guc-use-watchdog">をonにします。
- <programlisting>
- use_watchdog = on
- # Activates watchdog
- </programlisting>
- </para>
- </sect3>
-
- <sect3 id="example-watchdog-config-upstream">
- <!--
- <title>Configure Up stream servers</title>
- -->
- <title>上位サーバの設定</title>
- <para>
- <!--
- Specify the up stream servers (e.g. application servers).
- Leaving it blank is also fine.
- -->
- 上流のサーバ(アプリケーションサーバなど)を指定します。
- 空欄にしておいても構いません。
- <programlisting>
- trusted_servers = ''
- # trusted server list which are used
- # to confirm network connection
- # (hostA,hostB,hostC,...)
- </programlisting>
- </para>
- </sect3>
-
- <sect3 id="example-watchdog-config-wd-comm">
- <!--
- <title>Watchdog Communication</title>
- -->
- <title>Watchdog通信</title>
- <para>
- <!--
- Specify the TCP port number for watchdog communication.
- -->
- watchdog通信を行うTCPポート番号を指定します。
- <programlisting>
- wd_port = 9000
- # port number for watchdog service
- </programlisting>
- </para>
- </sect3>
-
- <sect3 id="example-watchdog-config-wd-vip">
- <!--
- <title>Virtual IP</title>
- -->
- <title>仮想IP</title>
- <para>
- <!--
- Specify the IP address to be used as a virtual IP address
- in the <xref linkend="guc-delegate-IP">.
- -->
- 仮想IPを<xref linkend="guc-delegate-IP">に設定します。
- <programlisting>
- delegate_IP = '133.137.177.143'
- # delegate IP address
- </programlisting>
- </para>
- <note>
- <para>
- <!--
- Make sure the IP address configured as a Virtual IP should be
- free and is not used by any other machine.
- -->
- 仮想IPに設定されるIPアドレスは空いており他のマシンで使用されていないことを確認してください。
- </para>
- </note>
- </sect3>
- </sect2>
-
- <sect2 id="example-watchdog-configuration-each-server">
- <!--
- <title>Individual Server Configurations</title>
- -->
- <title>個々のサーバ設定</title>
- <para>
- <!--
- Next, set the following parameters for each <productname>
- Pgpool-II</productname>.
- -->
- 次に、それぞれの<productname>Pgpool-II</>で以下のパラメータを設定します。
- </para>
-
- <sect3 id="example-watchdog-configuration-active-server">
- <!--
- <title>Active (osspc16) Server configurations</title>
- -->
- <title>Activeサーバの設定(osspc16)</title>
- <para>
- <programlisting>
- other_pgpool_hostname0 = 'osspc20'
- # Host name or IP address to connect to for other pgpool 0
- other_pgpool_port0 = 9999
- # Port number for other pgpool 0
- other_wd_port0 = 9000
- # Port number for other watchdog 0
- </programlisting>
- </para>
- </sect3>
-
- <sect3 id="example-watchdog-configuration-standby-server">
- <!--
- <title>Standby (osspc20) Server configurations</title>
- -->
- <title>Standbyサーバの設定(osspc20)</title>
- <para>
- <programlisting>
- other_pgpool_hostname0 = 'osspc16'
- # Host name or IP address to connect to for other pgpool 0
- other_pgpool_port0 = 9999
- # Port number for other pgpool 0
- other_wd_port0 = 9000
- # Port number for other watchdog 0
- </programlisting>
- </para>
- </sect3>
- </sect2>
-
- <sect2 id="example-watchdog-start-server">
- <!--
- <title>Starting <productname>Pgpool-II</productname></title>
- -->
- <title><productname>Pgpool-II</productname>の起動</title>
- <para>
- <!--
- Start <productname>Pgpool-II</productname> on each servers from
- <literal>root</literal> user with <literal>"-n"</literal> switch
- and redirect log messages into pgpool.log file.
- -->
- 両方のサーバで<productname>Pgpool-II</>を<literal>root</literal>ユーザで、<literal>"-n"</literal>オプションを付けて起動し、ログメッセージはpgpool.logファイルにリダイレクトします。
- </para>
-
- <sect3 id="example-watchdog-start-active-server">
- <!--
- <title>Starting pgpool in Active server (osspc16)</title>
- -->
- <title>ActiveサーバでのPgpool-II起動(osspc16)</title>
- <para>
- <!--
- First start the <productname>Pgpool-II</productname> on Active server.
- -->
- 最初に、Active サーバで<productname>Pgpool-II</productname>を起動します。
- <programlisting>
- [user@osspc16]$ su -
- [root@osspc16]# {installed_dir}/bin/pgpool -n -f {installed_dir}/etc/pgpool.conf > pgpool.log 2>&1
- </programlisting>
- <!--
- Log messages will show that <productname>Pgpool-II</productname>
- has the virtual IP address and starts watchdog process.
- -->
- ログから、仮想IP アドレスを使用し、またwatchdogプロセス起動したことが確認できます。
- <programlisting>
- LOG: I am announcing my self as leader/coordinator watchdog node
- LOG: I am the cluster leader node
- DETAIL: our declare coordinator message is accepted by all nodes
- LOG: I am the cluster leader node. Starting escalation process
- LOG: escalation process started with PID:59449
- <emphasis>LOG: watchdog process is initialized
- LOG: watchdog: escalation started
- LOG: I am the leader watchdog node</emphasis>
- DETAIL: using the local backend node status
- </programlisting>
- </para>
- </sect3>
-
- <sect3 id="example-watchdog-start-standby-server">
- <!--
- <title>Starting pgpool in Standby server (osspc20)</title>
- -->
- <title>StandbyサーバでのPgpool-II起動(osspc20)</title>
- <para>
- <!--
- Now start the <productname>Pgpool-II</productname> on Standby server.
- -->
- 次に、Standbyサーバで<productname>Pgpool-II</>を起動します。
- <programlisting>
- [user@osspc20]$ su -
- [root@osspc20]# {installed_dir}/bin/pgpool -n -f {installed_dir}/etc/pgpool.conf > pgpool.log 2>&1
- </programlisting>
- <!--
- Log messages will show that <productname>Pgpool-II</productname>
- has joind the watchdog cluster as standby watchdog.
- -->
- ログメッセージから<productname>Pgpool-II</productname>がwatchdogクラスタにスタンバイとして参加したことがわかります。
- <programlisting>
- LOG: watchdog cluster configured with 1 remote nodes
- LOG: watchdog remote node:0 on Linux_osspc16_9000:9000
- LOG: interface monitoring is disabled in watchdog
- LOG: IPC socket path: "/tmp/.s.PGPOOLWD_CMD.9000"
- LOG: watchdog node state changed from [DEAD] to [LOADING]
- LOG: new outbound connection to Linux_osspc16_9000:9000
- LOG: watchdog node state changed from [LOADING] to [INITIALIZING]
- LOG: watchdog node state changed from [INITIALIZING] to [STANDBY]
- <emphasis>
- LOG: successfully joined the watchdog cluster as standby node
- DETAIL: our join coordinator request is accepted by cluster leader node "Linux_osspc16_9000"
- LOG: watchdog process is initialized
- </emphasis>
- </programlisting>
- </para>
- </sect3>
- </sect2>
-
- <sect2 id="example-watchdog-try">
- <!--
- <title>Try it out</title>
- -->
- <title>動作確認</title>
- <para>
- <!--
- Confirm to ping to the virtual IP address.
- -->
- 仮想 IP アドレスに、pingが通ることを確認します。
- <programlisting>
- [user@someserver]$ ping 133.137.177.143
- PING 133.137.177.143 (133.137.177.143) 56(84) bytes of data.
- 64 bytes from 133.137.177.143: icmp_seq=1 ttl=64 time=0.328 ms
- 64 bytes from 133.137.177.143: icmp_seq=2 ttl=64 time=0.264 ms
- 64 bytes from 133.137.177.143: icmp_seq=3 ttl=64 time=0.412 ms
- </programlisting>
- <!--
- Confirm if the Active server which started at first has the virtual IP address.
- -->
- 先に<productname>Pgpool-II</>を起動したActiveサーバが、仮想IPアドレスを使っていることを確認します。
- <programlisting>
- [root@osspc16]# ifconfig
- eth0 ...
-
- eth0:0 inet addr:133.137.177.143 ...
-
- lo ...
- </programlisting>
- <!--
- Confirm if the Standby server which started not at first doesn't have the virtual IP address.
- -->
- 後から<productname>Pgpool-II</>を立ち上げたStandbサーバは、仮想IPアドレスを使っていないことを確認します。
- <programlisting>
- [root@osspc20]# ifconfig
- eth0 ...
-
- lo ...
- </programlisting>
-
- <!--
- Try to connect <productname>PostgreSQL</> by "psql -h delegate_IP -p port".
- -->
- 仮想IPアドレスを使って、<productname>PostgreSQL</> に接続をできることを確認します。
- <programlisting>
- [user@someserver]$ psql -h 133.137.177.143 -p 9999 -l
- </programlisting>
- </para>
- </sect2>
-
- <sect2 id="example-watchdog-vip-switch">
- <!--
- <title>Switching virtual IP</title>
- -->
- <title>仮想IPの切り替え</title>
- <para>
- <!--
- Confirm how the Standby server works when the Active server can't provide its service.
- Stop <productname>Pgpool-II</productname> on the Active server.
- -->
- Activeサーバがサービス供給不可な状態になったときに、Standbyがそれを引き継ぐのを確認します。
- Activeサーバの<productname>Pgpool-II</>を停止します。
- <programlisting>
- [root@osspc16]# {installed_dir}/bin/pgpool stop
- </programlisting>
-
- <!--
- Then, the Standby server starts to use the virtual IP address. Log shows:
- -->
- するとStandbyサーバで、仮想IPアドレスを使用しはじめたというログメッセージが出力されます。
-
- <programlisting>
- <emphasis>
- LOG: remote node "Linux_osspc16_9000" is shutting down
- LOG: watchdog cluster has lost the coordinator node
- </emphasis>
- LOG: watchdog node state changed from [STANDBY] to [JOINING]
- LOG: watchdog node state changed from [JOINING] to [INITIALIZING]
- LOG: I am the only alive node in the watchdog cluster
- HINT: skipping stand for coordinator state
- LOG: watchdog node state changed from [INITIALIZING] to [LEADER]
- LOG: I am announcing my self as leader/coordinator watchdog node
- LOG: I am the cluster leader node
- DETAIL: our declare coordinator message is accepted by all nodes
- <emphasis>
- LOG: I am the cluster leader node. Starting escalation process
- LOG: watchdog: escalation started
- </emphasis>
- LOG: watchdog escalation process with pid: 59551 exit with SUCCESS.
- </programlisting>
-
- <!--
- Confirm to ping to the virtual IP address.
- -->
- 仮想 IP アドレスに、pingが通ることを確認します。
- <programlisting>
- [user@someserver]$ ping 133.137.177.143
- PING 133.137.177.143 (133.137.177.143) 56(84) bytes of data.
- 64 bytes from 133.137.177.143: icmp_seq=1 ttl=64 time=0.328 ms
- 64 bytes from 133.137.177.143: icmp_seq=2 ttl=64 time=0.264 ms
- 64 bytes from 133.137.177.143: icmp_seq=3 ttl=64 time=0.412 ms
- </programlisting>
-
- <!--
- Confirm that the Active server doesn't use the virtual IP address any more.
- -->
- Activeではもう仮想IPアドレスが使われなくなったのを確認します。
- <programlisting>
- [root@osspc16]# ifconfig
- eth0 ...
-
- lo ...
- </programlisting>
-
- <!--
- Confirm that the Standby server uses the virtual IP address.
- -->
- Standbyで仮想IP アドレスが使われていることを確認します。
- <programlisting>
- [root@osspc20]# ifconfig
- eth0 ...
-
- eth0:0 inet addr:133.137.177.143 ...
-
- lo ...
- </programlisting>
-
- <!--
- Try to connect <productname>PostgreSQL</> by "psql -h delegate_IP -p port".
- -->
- 仮想IPアドレスを使って、<productname>PostgreSQL</>に接続できることを確認します。
- <programlisting>
- [user@someserver]$ psql -h 133.137.177.143 -p 9999 -l
- </programlisting>
-
- </para>
- </sect2>
-
- <sect2 id="example-watchdog-more">
- <!--
- <title>More</title>
- -->
- <title>応用</title>
-
- <sect3 id="example-watchdog-more-lifecheck">
- <!--
- <title>Lifecheck</title>
- -->
- <title>死活監視</title>
- <para>
- <!--
- There are the parameters about watchdog's monitoring.
- Specify the interval to check <xref linkend="guc-wd-interval"> and
- the type of lifecheck <xref linkend="guc-wd-lifecheck-method">.
- The <literal>hearbeat</literal> method specify the time to detect
- a fault <xref linkend="guc-wd-heartbeat-deadtime">, the port number to
- receive <xref linkend="guc-wd-heartbeat-port">, the interval to send
- <xref linkend="guc-wd-heartbeat-keepalive">, the IP address or hostname
- of destination <xref linkend="guc-heartbeat-destination"> and finally
- the destination port number <xref linkend="guc-heartbeat-destination-port">.
- -->
- watchdog の監視方法について設定するパラメータがあります。
- 監視間隔秒を指定する<xref linkend="guc-wd-interval">、死活監視のタイプを指定する<xref linkend="guc-wd-lifecheck-method">を記述します。
- <literal>heartbeat</literal>方式では、障害と判断する秒数を指定する<xref linkend="guc-wd-heartbeat-deadtime">、受信ポート番号を指定する<xref linkend="guc-heartbeat-port">、ハートビート信号の送信間隔秒を指定する<xref linkend="guc-wd-heartbeat-keepalive">、送信先<xref linkend="guc-heartbeat-hostname">、<xref linkend="guc-heartbeat-port">を記述します。
- <programlisting>
- wd_lifecheck_method = 'heartbeat'
- # Method of watchdog lifecheck ('heartbeat' or 'query' or 'external')
- # (change requires restart)
- wd_interval = 10
- # lifecheck interval (sec) > 0
- wd_heartbeat_port = 9694
- # Port number for receiving heartbeat signal
- # (change requires restart)
- wd_heartbeat_keepalive = 2
- # Interval time of sending heartbeat signal (sec)
- # (change requires restart)
- wd_heartbeat_deadtime = 30
- # Deadtime interval for heartbeat signal (sec)
- # (change requires restart)
- heartbeat_destination0 = 'host0_ip1'
- # Host name or IP address of destination 0
- # for sending heartbeat signal.
- # (change requires restart)
- heartbeat_destination_port0 = 9694
- # Port number of destination 0 for sending
- # heartbeat signal. Usually this is the
- # same as wd_heartbeat_port.
- # (change requires restart)
- </programlisting>
-
- </para>
- </sect3>
-
- <sect3 id="example-watchdog-more-vip-switching">
- <!--
- <title>Switching virtual IP address</title>
- -->
- <title>仮想IPの切り替え</title>
- <para>
- <!--
- There are the parameters for switching the virtual IP address.
- Specify switching commands <xref linkend="guc-if-up-cmd">,
- <xref linkend="guc-if-down-cmd">, the path to them
- <xref linkend="guc-if-cmd-path">, the command executed after
- switching to send ARP request <xref linkend="guc-arping-cmd">
- and the path to it <xref linkend="guc-arping-path">.
- -->
- IP アドレスの切り替えコマンドについて設定するパラメータがあります。
- 仮想 IP を切り替える際に使うコマンドとして<xref linkend="guc-if-up-cmd">、<xref linkend="guc-if-down-cmd">、そのパスを指定する<xref linkend="guc-if-cmd-path">を記述します。
- また、仮想IP切り替え後のARPリクエスト送信コマンドを指定する<xref linkend="guc-arping-cmd">、そのパスを指定する<xref linkend="guc-arping-path">を記述します。
- <programlisting>
- if_cmd_path = '/sbin'
- # path to the directory where if_up/down_cmd exists
- if_up_cmd = 'ip addr add $_IP_$/24 dev eth0 label eth0:0'
- # startup delegate IP command
- if_down_cmd = 'ip addr del $_IP_$/24 dev eth0'
- # shutdown delegate IP command
-
- arping_path = '/usr/sbin' # arping command path
-
- arping_cmd = 'arping -U $_IP_$ -w 1'
- </programlisting>
- <!--
- You can also bring up and bring down the virtual IP using arbitrary scripts
- specified <xref linkend="guc-wd-escalation-command"> and
- <xref linkend="guc-wd-de-escalation-command"> parameters.
- -->
- <xref linkend="guc-wd-escalation-command">および<xref linkend="guc-wd-de-escalation-command">パラメータに指定した任意のスクリプトで仮想IPの起動・停止を行うこともできます。
-
- </para>
- </sect3>
-
- </sect2>
-</sect1>
-->
<title>設定の例</title>
&example-basic;
- &example-watchdog;
&example-cluster;
&example-AWS;
&example-Aurora;
-->
このパラメータは、サーバ起動時にのみ設定できます。
</para>
+ <para>
+ <productname>Pgpool-II</productname> 4.2より前では、watchdogは自ノードとそれを基準に他ノードの設定を記述するため、
+ ノードごとに異なる設定を記述する必要がありました。
+ <productname>Pgpool-II</productname> 4.2以降では、watchdogの設定はノード間で共通するようにしました。
+ そのため、<productname>Pgpool-II</productname> 4.2以降、<literal>Watchdog</literal>機能が有効になっている場合、
+ どの設定がどのホストであるかを区別するには、
+ 設定ファイル<filename>pgpool.conf</filename>を格納するディレクトリに<filename>pgpool_node_id</filename>ファイルの作成が必要になります。
+ そのファイルにpgpool(watchdog)ホストを識別するためのノード番号(0、1、2など)を指定します。
+ </para>
+ <example id="example-pgpool-node-id-1">
+ <title>pgpool_node_idの設定例</title>
+ <para>
+ Pgpool ノードが3つあり、それぞれのホスト名が server1、server2、server3 の場合、各ホスト上で<filename>pgpool_node_id</filename>ファイル以下のように作成します。
+ RPMからインストールした場合は、<filename>pgpool.conf</filename>が<filename>/etc/pgpool-II/</filename>配下にインストールされます。
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>server1</literal>
+ </para>
+ <programlisting>
+[server1]# cat /etc/pgpool-II/pgpool_node_id
+0
+ </programlisting>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>server2</literal>
+ </para>
+ <programlisting>
+[server2]# cat /etc/pgpool-II/pgpool_node_id
+1
+ </programlisting>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>server3</literal>
+ </para>
+ <programlisting>
+[server3]# cat /etc/pgpool-II/pgpool_node_id
+2
+ </programlisting>
+ </listitem>
+ </itemizedlist>
+ </example>
</listitem>
</varlistentry>
</variablelist>
you can set the <xref linkend="guc-hostname">,
<xref linkend="guc-wd-port"> and <xref linkend="guc-pgpool-port"> like below:
-->
- Pgpool ノードが3つあり、それぞれのホストが server1、server2、server3 の場合、
+ Pgpool ノードが3つあり、それぞれのホスト名が server1、server2、server3 の場合、
<xref linkend="guc-hostname">、<xref linkend="guc-wd-port">
及び<xref linkend="guc-pgpool-port">を以下のように設定します。
<programlisting>
the number at the end of the parameter name is
referred as the "pgpool node id", that starts from 0.
-->
- ハートビート信号を受信するためのポート番号を指定します。
- 1つのみを指定してください。
+ ハートビート信号を受信するためのUDPポート番号を指定します。
+ 1つのみを指定してください。デフォルトは9694です。
パラメータ名の最後にある数字は「pgpool ノードID」で、0から始まります(たとえばheartbeat_port0)。
</para>
<para>
you can set the <xref linkend="guc-heartbeat-hostname">,
<xref linkend="guc-heartbeat-port"> and <xref linkend="guc-heartbeat-device"> like below:
-->
- Pgpool ノードが3つあり、それぞれのホストが server1、server2、server3 の場合、
+ Pgpool ノードが3つあり、それぞれのホスト名が server1、server2、server3 の場合、
<xref linkend="guc-heartbeat-hostname">、<xref linkend="guc-heartbeat-port">
及び<xref linkend="guc-heartbeat-device">を以下のように設定します。
- <programlisting>
- heartbeat_hostname0 = 'server1'
- heartbeat_port0 = 9694
- heartbeat_device0 = ''
-
- heartbeat_hostname1 = 'server2'
- heartbeat_port1 = 9694
- heartbeat_device1 = ''
-
- heartbeat_hostname2 = 'server3'
- heartbeat_port2 = 9694
- heartbeat_device2 = ''
- </programlisting>
+ <programlisting>
+heartbeat_hostname0 = 'server1'
+heartbeat_port0 = 9694
+heartbeat_device0 = ''
+
+heartbeat_hostname1 = 'server2'
+heartbeat_port1 = 9694
+heartbeat_device1 = ''
+
+heartbeat_hostname2 = 'server3'
+heartbeat_port2 = 9694
+heartbeat_device2 = ''
+ </programlisting>
</para>
</example>
</listitem>
<title><productname>Pgpool-II</productname> configurations</title>
<para>
Mostly the <productname>Pgpool-II</productname> configurations for this
- example will be same as in the <xref linkend="example-watchdog">, except the
+ example will be same as in the <xref linkend="example-cluster">, except the
<xref linkend="guc-delegate-ip"> which we will not set in this example instead
we will use <xref linkend="guc-wd-escalation-command"> and
<xref linkend="guc-wd-de-escalation-command"> to switch the
Elastic IP address to the leader/Active <productname>Pgpool-II</productname> node.
</para>
-
- <sect3 id="example-AWS-pgpool-config-instance-1">
- <title><productname>Pgpool-II</productname> configurations on Instance-1</title>
- <para>
-
- <programlisting>
- use_watchdog = on
- delegate_IP = ''
- wd_hostname = 'instance-1-private-ip'
- other_pgpool_hostname0 = 'instance-2-private-ip'
- other_pgpool_port0 = 9999
- other_wd_port0 = 9000
- wd_escalation_command = '$path_to_script/aws-escalation.sh'
- wd_de_escalation_command = '$path_to_script/aws-de-escalation.sh'
+ <programlisting>
+use_watchdog = on
+delegate_IP = ''
+...
+wd_escalation_command = '$path_to_script/aws-escalation.sh'
+wd_de_escalation_command = '$path_to_script/aws-de-escalation.sh'
</programlisting>
-
- </para>
- </sect3>
-
- <sect3 id="example-AWS-pgpool-config-instance-2">
- <title><productname>Pgpool-II</productname> configurations on Instance-2</title>
- <para>
-
- <programlisting>
- use_watchdog = on
- delegate_IP = ''
- wd_hostname = 'instance-2-private-ip'
- other_pgpool_hostname0 = 'instance-1-private-ip'
- other_pgpool_port0 = 9999
- other_wd_port0 = 9000
- wd_escalation_command = '$path_to_script/aws-escalation.sh'
- wd_de_escalation_command = '$path_to_script/aws-de-escalation.sh'
- </programlisting>
-
- </para>
- </sect3>
</sect2>
<sect2 id="example-AWS-pgpool-aws-escalation-instance">
wd_port2 = 9000
pgpool_port2 = 9999
</programlisting>
-
+ <para>
+ Specify the method of lifecheck <xref linkend="guc-wd-lifecheck-method">
+ and the lifecheck interval <xref linkend="guc-wd-interval">.
+ Here, we use <literal>hearbeat</literal> method to perform watchdog lifecheck.
+ </para>
+ <programlisting>
+wd_lifecheck_method = 'heartbeat'
+ # Method of watchdog lifecheck ('heartbeat' or 'query' or 'external')
+ # (change requires restart)
+wd_interval = 10
+ # lifecheck interval (sec) > 0
+ # (change requires restart)
+ </programlisting>
<para>
Specify all <productname>Pgpool-II</productname> nodes information for sending and receiving heartbeat signal.
</para>
heartbeat_port2 = 9694
heartbeat_device2 = ''
</programlisting>
+ <para>
+ If the <xref linkend="guc-wd-lifecheck-method"> is set to <literal>heartbeat</literal>,
+ specify the time to detect a fault <xref linkend="guc-wd-heartbeat-deadtime"> and
+ the interval to send heartbeat signals <xref linkend="guc-wd-heartbeat-deadtime">.
+ </para>
+ <programlisting>
+wd_heartbeat_keepalive = 2
+ # Interval time of sending heartbeat signal (sec)
+ # (change requires restart)
+wd_heartbeat_deadtime = 30
+ # Deadtime interval for heartbeat signal (sec)
+ # (change requires restart)
+ </programlisting>
+ <note>
+ <para>
+ If you have even number of watchdog nodes, you need to turn on <xref linkend="guc-enable-consensus-with-half-votes"> parameter.
+ </para>
+ </note>
<note>
<para>
If use_watchdog = on, please make sure the pgpool node number is specified
+++ /dev/null
- <sect1 id="example-watchdog">
- <title>Watchdog Configuration Example</title>
-
- <para>
- This tutorial explains the simple way to try "Watchdog".
- What you need is 2 Linux boxes on which <productname>
- Pgpool-II</productname> is installed and a <productname>PostgreSQL</productname>
- on the same machine or in the other one. It is enough
- that 1 node for backend exists.
- You can use watchdog with <productname>
- Pgpool-II</productname> in any mode: replication mode,
- native replication mode and raw mode.
- </para>
- <para>
- This example uses use "osspc16" as an Active node and
- "osspc20" as a Standby node. "Someserver" means one of them.
- </para>
-
- <sect2 id="example-watchdog-configuration">
- <title>Common configurations</title>
- <para>
- Set the following parameters in both of active and standby nodes.
- </para>
-
- <sect3 id="example-watchdog-config-enable">
- <title>Enabling watchdog</title>
- <para>
- First of all, set <xref linkend="guc-use-watchdog"> to on.
- <programlisting>
- use_watchdog = on
- # Activates watchdog
- </programlisting>
- </para>
- </sect3>
-
- <sect3 id="example-watchdog-config-upstream">
- <title>Configure Up stream servers</title>
- <para>
- Specify the up stream servers (e.g. application servers).
- Leaving it blank is also fine.
- <programlisting>
- trusted_servers = ''
- # trusted server list which are used
- # to confirm network connection
- # (hostA,hostB,hostC,...)
- </programlisting>
- </para>
- </sect3>
-
- <sect3 id="example-watchdog-config-wd-comm">
- <title>Watchdog Communication</title>
- <para>
- Specify the TCP port number for watchdog communication.
- <programlisting>
- wd_port = 9000
- # port number for watchdog service
- </programlisting>
- </para>
- </sect3>
-
- <sect3 id="example-watchdog-config-wd-vip">
- <title>Virtual IP</title>
- <para>
- Specify the IP address to be used as a virtual IP address
- in the <xref linkend="guc-delegate-IP">.
- <programlisting>
- delegate_IP = '133.137.177.143'
- # delegate IP address
- </programlisting>
- </para>
- <note>
- <para>
- Make sure the IP address configured as a Virtual IP should be
- free and is not used by any other machine.
- </para>
- </note>
- </sect3>
- </sect2>
-
- <sect2 id="example-watchdog-configuration-each-server">
- <title>Individual Server Configurations</title>
- <para>
- Next, set the following parameters for each <productname>
- Pgpool-II</productname>.
- </para>
-
- <sect3 id="example-watchdog-configuration-active-server">
- <title>Active (osspc16) Server configurations</title>
- <para>
- <programlisting>
- other_pgpool_hostname0 = 'osspc20'
- # Host name or IP address to connect to for other pgpool 0
- other_pgpool_port0 = 9999
- # Port number for other pgpool 0
- other_wd_port0 = 9000
- # Port number for other watchdog 0
- </programlisting>
- </para>
- </sect3>
-
- <sect3 id="example-watchdog-configuration-standby-server">
- <title>Standby (osspc20) Server configurations</title>
- <para>
- <programlisting>
- other_pgpool_hostname0 = 'osspc16'
- # Host name or IP address to connect to for other pgpool 0
- other_pgpool_port0 = 9999
- # Port number for other pgpool 0
- other_wd_port0 = 9000
- # Port number for other watchdog 0
- </programlisting>
- </para>
- </sect3>
- </sect2>
-
- <sect2 id="example-watchdog-start-server">
- <title>Starting <productname>Pgpool-II</productname></title>
- <para>
- Start <productname>Pgpool-II</productname> on each servers from
- <literal>root</literal> user with <literal>"-n"</literal> switch
- and redirect log messages into pgpool.log file.
- </para>
-
- <sect3 id="example-watchdog-start-active-server">
- <title>Starting pgpool in Active server (osspc16)</title>
- <para>
- First start the <productname>Pgpool-II</productname> on Active server.
- <programlisting>
- [user@osspc16]$ su -
- [root@osspc16]# {installed_dir}/bin/pgpool -n -f {installed_dir}/etc/pgpool.conf > pgpool.log 2>&1
- </programlisting>
- Log messages will show that <productname>Pgpool-II</productname>
- has the virtual IP address and starts watchdog process.
- <programlisting>
- LOG: I am announcing my self as leader/coordinator watchdog node
- LOG: I am the cluster leader node
- DETAIL: our declare coordinator message is accepted by all nodes
- LOG: I am the cluster leader node. Starting escalation process
- LOG: escalation process started with PID:59449
- <emphasis>LOG: watchdog process is initialized
- LOG: watchdog: escalation started
- LOG: I am the leader watchdog node</emphasis>
- DETAIL: using the local backend node status
- </programlisting>
- </para>
- </sect3>
-
- <sect3 id="example-watchdog-start-standby-server">
- <title>Starting pgpool in Standby server (osspc20)</title>
- <para>
- Now start the <productname>Pgpool-II</productname> on Standby server.
- <programlisting>
- [user@osspc20]$ su -
- [root@osspc20]# {installed_dir}/bin/pgpool -n -f {installed_dir}/etc/pgpool.conf > pgpool.log 2>&1
- </programlisting>
- Log messages will show that <productname>Pgpool-II</productname>
- has joined the watchdog cluster as standby watchdog.
- <programlisting>
- LOG: watchdog cluster configured with 1 remote nodes
- LOG: watchdog remote node:0 on Linux_osspc16_9000:9000
- LOG: interface monitoring is disabled in watchdog
- LOG: IPC socket path: "/tmp/.s.PGPOOLWD_CMD.9000"
- LOG: watchdog node state changed from [DEAD] to [LOADING]
- LOG: new outbound connection to Linux_osspc16_9000:9000
- LOG: watchdog node state changed from [LOADING] to [INITIALIZING]
- LOG: watchdog node state changed from [INITIALIZING] to [STANDBY]
- <emphasis>
- LOG: successfully joined the watchdog cluster as standby node
- DETAIL: our join coordinator request is accepted by cluster leader node "Linux_osspc16_9000"
- LOG: watchdog process is initialized
- </emphasis>
- </programlisting>
- </para>
- </sect3>
- </sect2>
-
- <sect2 id="example-watchdog-try">
- <title>Try it out</title>
- <para>
- Confirm to ping to the virtual IP address.
- <programlisting>
- [user@someserver]$ ping 133.137.177.142
- PING 133.137.177.143 (133.137.177.143) 56(84) bytes of data.
- 64 bytes from 133.137.177.143: icmp_seq=1 ttl=64 time=0.328 ms
- 64 bytes from 133.137.177.143: icmp_seq=2 ttl=64 time=0.264 ms
- 64 bytes from 133.137.177.143: icmp_seq=3 ttl=64 time=0.412 ms
- </programlisting>
- Confirm if the Active server which started at first has the virtual IP address.
- <programlisting>
- [root@osspc16]# ifconfig
- eth0 ...
-
- eth0:0 inet addr:133.137.177.143 ...
-
- lo ...
- </programlisting>
- Confirm if the Standby server which started not at first doesn't have the virtual IP address.
- <programlisting>
- [root@osspc20]# ifconfig
- eth0 ...
-
- lo ...
- </programlisting>
-
- Try to connect <productname>PostgreSQL</productname> by "psql -h delegate_IP -p port".
- <programlisting>
- [user@someserver]$ psql -h 133.137.177.142 -p 9999 -l
- </programlisting>
- </para>
- </sect2>
-
- <sect2 id="example-watchdog-vip-switch">
- <title>Switching virtual IP</title>
- <para>
- Confirm how the Standby server works when the Active server can't provide its service.
- Stop <productname>Pgpool-II</productname> on the Active server.
- <programlisting>
- [root@osspc16]# {installed_dir}/bin/pgpool stop
- </programlisting>
-
- Then, the Standby server starts to use the virtual IP address. Log shows:
-
- <programlisting>
- <emphasis>
- LOG: remote node "Linux_osspc16_9000" is shutting down
- LOG: watchdog cluster has lost the coordinator node
- </emphasis>
- LOG: watchdog node state changed from [STANDBY] to [JOINING]
- LOG: watchdog node state changed from [JOINING] to [INITIALIZING]
- LOG: I am the only alive node in the watchdog cluster
- HINT: skipping stand for coordinator state
- LOG: watchdog node state changed from [INITIALIZING] to [LEADER]
- LOG: I am announcing my self as leader/coordinator watchdog node
- LOG: I am the cluster leader node
- DETAIL: our declare coordinator message is accepted by all nodes
- <emphasis>
- LOG: I am the cluster leader node. Starting escalation process
- LOG: watchdog: escalation started
- </emphasis>
- LOG: watchdog escalation process with pid: 59551 exit with SUCCESS.
- </programlisting>
-
- Confirm to ping to the virtual IP address.
- <programlisting>
- [user@someserver]$ ping 133.137.177.142
- PING 133.137.177.143 (133.137.177.143) 56(84) bytes of data.
- 64 bytes from 133.137.177.143: icmp_seq=1 ttl=64 time=0.328 ms
- 64 bytes from 133.137.177.143: icmp_seq=2 ttl=64 time=0.264 ms
- 64 bytes from 133.137.177.143: icmp_seq=3 ttl=64 time=0.412 ms
- </programlisting>
-
- Confirm that the Active server doesn't use the virtual IP address any more.
- <programlisting>
- [root@osspc16]# ifconfig
- eth0 ...
-
- lo ...
- </programlisting>
-
- Confirm that the Standby server uses the virtual IP address.
- <programlisting>
- [root@osspc20]# ifconfig
- eth0 ...
-
- eth0:0 inet addr:133.137.177.143 ...
-
- lo ...
- </programlisting>
-
- Try to connect <productname>PostgreSQL</productname> by "psql -h delegate_IP -p port".
- <programlisting>
- [user@someserver]$ psql -h 133.137.177.142 -p 9999 -l
- </programlisting>
-
- </para>
- </sect2>
-
- <sect2 id="example-watchdog-more">
- <title>More</title>
-
- <sect3 id="example-watchdog-more-lifecheck">
- <title>Lifecheck</title>
- <para>
- There are the parameters about watchdog's monitoring.
- Specify the interval to check <xref linkend="guc-wd-interval"> and
- the type of lifecheck <xref linkend="guc-wd-lifecheck-method">.
- The <literal>hearbeat</literal> method specify the time to detect
- a fault <xref linkend="guc-wd-heartbeat-deadtime">, the port number to
- receive <xref linkend="guc-heartbeat-port">, the interval to send
- <xref linkend="guc-wd-heartbeat-keepalive">, the IP address or hostname
- of destination <xref linkend="guc-heartbeat-hostname"> and finally
- the destination port number <xref linkend="guc-heartbeat-port">.
- <programlisting>
- wd_lifecheck_method = 'heartbeat'
- # Method of watchdog lifecheck ('heartbeat' or 'query' or 'external')
- # (change requires restart)
- wd_interval = 10
- # lifecheck interval (sec) > 0
- wd_heartbeat_port = 9694
- # Port number for receiving heartbeat signal
- # (change requires restart)
- wd_heartbeat_keepalive = 2
- # Interval time of sending heartbeat signal (sec)
- # (change requires restart)
- wd_heartbeat_deadtime = 30
- # Deadtime interval for heartbeat signal (sec)
- # (change requires restart)
- heartbeat_destination0 = 'host0_ip1'
- # Host name or IP address of destination 0
- # for sending heartbeat signal.
- # (change requires restart)
- heartbeat_destination_port0 = 9694
- # Port number of destination 0 for sending
- # heartbeat signal. Usually this is the
- # same as wd_heartbeat_port.
- # (change requires restart)
- </programlisting>
-
- </para>
- </sect3>
-
- <sect3 id="example-watchdog-more-vip-switching">
- <title>Switching virtual IP address</title>
- <para>
- There are the parameters for switching the virtual IP address.
- Specify switching commands <xref linkend="guc-if-up-cmd">,
- <xref linkend="guc-if-down-cmd">, the path to them
- <xref linkend="guc-if-cmd-path">, the command executed after
- switching to send ARP request <xref linkend="guc-arping-cmd">
- and the path to it <xref linkend="guc-arping-path">.
- <programlisting>
- if_cmd_path = '/sbin'
- # path to the directory where if_up/down_cmd exists
- if_up_cmd = 'ip addr add $_IP_$/24 dev eth0 label eth0:0'
- # startup delegate IP command
- if_down_cmd = 'ip addr del $_IP_$/24 dev eth0'
- # shutdown delegate IP command
-
- arping_path = '/usr/sbin' # arping command path
-
- arping_cmd = 'arping -U $_IP_$ -w 1'
- </programlisting>
- You can also bring up and bring down the virtual IP using arbitrary scripts
- specified <xref linkend="guc-wd-escalation-command"> and
- <xref linkend="guc-wd-de-escalation-command"> parameters.
- </para>
- </sect3>
-
- </sect2>
- </sect1>
<chapter id="example-configs">
<title>Configuration Examples</title>
&example-basic;
- &example-watchdog;
&example-cluster;
&example-AWS;
&example-Aurora;
<para>
This parameter can only be set at server start.
</para>
+ <para>
+ <productname>Pgpool-II</productname> 4.1 or earlier, because it is required to specify
+ its own pgpool node information and the destination pgpool nodes information, the
+ settings are different per pgpool node.
+ Since <productname>Pgpool-II</productname> 4.2, all configuration parameters are
+ identical on all hosts. If watchdog feature is enabled, to distingusish which host
+ is which, a <filename>pgpool_node_id</filename> file is required.
+ You need to create a <filename>pgpool_node_id</filename> file and specify the
+ pgpool (watchdog) node number (e.g. 0, 1, 2 ...) to identify pgpool (watchdog) host.
+ </para>
+ <example id="example-pgpool-node-id-1">
+ <title>pgpool_node_id configuration</title>
+ <para>
+ If you have 3 pgpool nodes with hostname server1, server2 and server3, create the
+ <filename>pgpool_node_id</filename> file on each host as follows.
+ When installing <productname>Pgpool-II</productname> using RPM,
+ <filename>pgpool.conf</filename> is installed under <filename>/etc/pgpool-II/</filename>.
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>server1</literal>
+ </para>
+ <programlisting>
+[server1]# cat /etc/pgpool-II/pgpool_node_id
+0
+ </programlisting>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>server2</literal>
+ </para>
+ <programlisting>
+[server2]# cat /etc/pgpool-II/pgpool_node_id
+1
+ </programlisting>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>server3</literal>
+ </para>
+ <programlisting>
+[server3]# cat /etc/pgpool-II/pgpool_node_id
+2
+ </programlisting>
+ </listitem>
+ </itemizedlist>
+ </example>
</listitem>
</varlistentry>
</variablelist>
<title>Watchdog configuration</title>
<para>
If you have 3 pgpool nodes with hostname server1, server2 and server3,
- you can set the <xref linkend="guc-hostname">,
+ you can configure <xref linkend="guc-hostname">,
<xref linkend="guc-wd-port"> and <xref linkend="guc-pgpool-port"> like below:
<programlisting>
- hostname0 = 'server1'
- wd_port0 = 9000
- pgpool_port0 = 9999
+hostname0 = 'server1'
+wd_port0 = 9000
+pgpool_port0 = 9999
- hostname1 = 'server2'
- wd_port1 = 9000
- pgpool_port1 = 9999
+hostname1 = 'server2'
+wd_port1 = 9000
+pgpool_port1 = 9999
- hostname2 = 'server3'
- wd_port2 = 9000
- pgpool_port2 = 9999
+hostname2 = 'server3'
+wd_port2 = 9000
+pgpool_port2 = 9999
</programlisting>
</para>
</example>
<listitem>
<para>
Specifies the port number for sending and receiving the heartbeat signals.
+ Specify only one port number here. Default is 9694.
The number at the end of the parameter name is referred
as "pgpool node id", and it starts from 0 (e.g. heartbeat_port0).
</para>
<title>Heartbeat configuration</title>
<para>
If you have 3 pgpool nodes with hostname server1, server2 and server3,
- you can set the <xref linkend="guc-heartbeat-hostname">,
+ you can configure <xref linkend="guc-heartbeat-hostname">,
<xref linkend="guc-heartbeat-port"> and <xref linkend="guc-heartbeat-device"> like below:
<programlisting>
heartbeat_hostname0 = 'server1'