New feature: Simplify Watchdog related configuration parameters.
authorBo Peng <pengbo@sraoss.co.jp>
Mon, 10 Aug 2020 15:57:46 +0000 (00:57 +0900)
committerBo Peng <pengbo@sraoss.co.jp>
Mon, 10 Aug 2020 15:57:46 +0000 (00:57 +0900)
This commit simplifies watchdog related configuration parameters
by using a common config file for each pgpool node and a pgpool_node_id file.

Previously we need to configure the following parameters on each pgpool node,
because of the difference between local and remote pgpool nodes settings.
- wd_hostname
- wd_port
- wd_heartbeat_port
- heartbeat_device
- heartbeat_destination0
- heartbeat_destination_port0
- heartbeat_destination1
- heartbeat_destination_port1
- other_pgpool_hostname0
- other_pgpool_port0
- other_wd_port0
- other_pgpool_hostname1
- other_pgpool_port1
- other_wd_port1

This commit simplifies watchdog related configuration by using a common config file
for each pgpool node and a pgpool_node_id file, and users just copy the configuration file
to each pgpool node without editing.

The parameters above are changed to (for 3 pgpool nodes):
(For example)
==============================
 hostname0 = 'server1'
 wd_port0 = 9000
 pgpool_port0 = 9999

 hostname1 = 'server2'
 wd_port1 = 9000
 pgpool_port1 = 9999

 hostname2 = 'server3'
 wd_port2 = 9000
 pgpool_port2 = 9999

 heartbeat_hostname0 = 'server1'
 heartbeat_port0 = 9694
 heartbeat_device0 = ''

 heartbeat_hostname1 = 'server2'
 heartbeat_port1 = 9694
 heartbeat_device1 = ''

 heartbeat_hostname2 = 'server3'
 heartbeat_port2 = 9694
 heartbeat_device2 = ''
==============================

You can specify multiple configurations in "heartbeat_hostname" and "heartbeat_device" by separating
them using semicolon (;).

And user needs to specify local pgpool node id in a pgpool_node_id file on each pgpool node.
pgpool_node_id file should be created in the direcroty of pgpool.conf.

In addition, this commit increases "WD_MESSAGE_DATA_VERSION_MINOR" to "2".

48 files changed:
doc.ja/src/sgml/example-watchdog.sgml
doc.ja/src/sgml/watchdog.sgml
doc/src/sgml/example-watchdog.sgml
doc/src/sgml/watchdog.sgml
src/config/pool_config.c
src/config/pool_config_variables.c
src/include/pool.h
src/include/pool_config.h
src/include/watchdog/watchdog.h
src/sample/pgpool.conf.sample-logical
src/sample/pgpool.conf.sample-raw
src/sample/pgpool.conf.sample-replication
src/sample/pgpool.conf.sample-slony
src/sample/pgpool.conf.sample-snapshot
src/sample/pgpool.conf.sample-stream
src/test/regression/tests/004.watchdog/master.conf
src/test/regression/tests/004.watchdog/standby.conf
src/test/regression/tests/004.watchdog/test.sh
src/test/regression/tests/011.watchdog_quorum_failover/master.conf
src/test/regression/tests/011.watchdog_quorum_failover/standby.conf
src/test/regression/tests/011.watchdog_quorum_failover/standby2.conf
src/test/regression/tests/011.watchdog_quorum_failover/test.sh
src/test/regression/tests/012.watchdog_failover_when_quorum_exists/master.conf
src/test/regression/tests/012.watchdog_failover_when_quorum_exists/standby.conf
src/test/regression/tests/012.watchdog_failover_when_quorum_exists/standby2.conf
src/test/regression/tests/012.watchdog_failover_when_quorum_exists/test.sh
src/test/regression/tests/013.watchdog_failover_require_consensus/master.conf
src/test/regression/tests/013.watchdog_failover_require_consensus/standby.conf
src/test/regression/tests/013.watchdog_failover_require_consensus/standby2.conf
src/test/regression/tests/013.watchdog_failover_require_consensus/test.sh
src/test/regression/tests/014.watchdog_test_quorum_bypass/master.conf
src/test/regression/tests/014.watchdog_test_quorum_bypass/test.sh
src/test/regression/tests/015.watchdog_master_and_backend_fail/master.conf
src/test/regression/tests/015.watchdog_master_and_backend_fail/standby.conf
src/test/regression/tests/015.watchdog_master_and_backend_fail/standby2.conf
src/test/regression/tests/015.watchdog_master_and_backend_fail/test.sh
src/test/watchdog_setup
src/tools/pgmd5/Makefile.am
src/tools/pgmd5/Makefile.in
src/tools/watchdog/Makefile.am
src/tools/watchdog/Makefile.in
src/tools/watchdog/wd_cli.c
src/utils/pool_process_reporting.c
src/watchdog/watchdog.c
src/watchdog/wd_heartbeat.c
src/watchdog/wd_ipc_conn.c
src/watchdog/wd_json_data.c
src/watchdog/wd_lifecheck.c

index 055aa2ecf9249eeaa38c7b83ed1e3f8cb51fb7c3..2fd3ed1d1a2c932be80c55879404a851831489c9 100644 (file)
    <!--
    Next, set the following parameters for each <productname>
    Pgpool-II</productname>.
-   Specify <xref linkend="guc-other-pgpool-hostname">,
-   <xref linkend="guc-other-pgpool-port"> and
-   <xref linkend="guc-other-wd-port"> with the values of
-   other <productname>Pgpool-II</productname> server values.
    -->
    次に、それぞれの<productname>Pgpool-II</>で以下のパラメータを設定します。
-   <xref linkend="guc-other-pgpool-hostname">、<xref linkend="guc-other-pgpool-port">、<xref linkend="guc-other-wd-port">を他の<productname>Pgpool-II</>の値で設定します。
   </para>
 
   <sect3 id="example-watchdog-configuration-active-server">
     -->
     watchdog の監視方法について設定するパラメータがあります。
     監視間隔秒を指定する<xref linkend="guc-wd-interval">、死活監視のタイプを指定する<xref linkend="guc-wd-lifecheck-method">を記述します。
-      <literal>heartbeat</literal>方式では、障害と判断する秒数を指定する<xref linkend="guc-wd-heartbeat-deadtime">、受信ポート番号を指定する<xref linkend="guc-wd-heartbeat-port">、ハートビート信号の送信間隔秒を指定する<xref linkend="guc-wd-heartbeat-keepalive">、送信先<xref linkend="guc-heartbeat-destination">、<xref linkend="guc-heartbeat-destination-port">を記述します。
+      <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')
index 91b6e57f60a8032456a62b991a933d30c24c3516..abb63968cbe08b8cacb9c80de08e9d7d8488eddc 100644 (file)
 
   <variablelist>
 
-   <varlistentry id="guc-wd-hostname" xreflabel="wd_hostname">
-    <term><varname>wd_hostname</varname> (<type>string</type>)
+   <varlistentry id="guc-hostname" xreflabel="hostname">
+    <term><varname>hostnameX</varname> (<type>string</type>)
      <indexterm>
       <!--
-      <primary><varname>wd_hostname</varname> configuration parameter</primary>
+      <primary><varname>hostnameX</varname> configuration parameter</primary>
       -->
-      <primary><varname>wd_hostname</varname>設定パラメータ</primary>
+      <primary><varname>hostnameX</varname>設定パラメータ</primary>
      </indexterm>
     </term>
     <listitem>
       <productname>Pgpool-II</productname> server.
       This is used for sending/receiving queries and packets,
       and also as an identifier of the watchdog node.
+      The number at the end of the parameter name is referred
+      as "pgpool node id", and it starts from 0 (e.g. hostname0).
       -->
       <productname>Pgpool-II</productname>サーバのホスト名またはIPアドレスを指定します。
       クエリやパケットの送受信の他、watchdogの識別子としても用います。
+      パラメータ名の最後にある数字は「pgpool ノードID」で、0から始まります(たとえばhostname0)。
      </para>
      <para>
       <!--
    </varlistentry>
 
    <varlistentry id="guc-wd-port" xreflabel="wd_port">
-    <term><varname>wd_port</varname> (<type>integer</type>)
+    <term><varname>wd_portX</varname> (<type>integer</type>)
      <indexterm>
       <!--
-      <primary><varname>wd_port</varname> configuration parameter</primary>
+      <primary><varname>wd_portX</varname> configuration parameter</primary>
       -->
-      <primary><varname>wd_port</varname> 設定パラメータ</primary>
+      <primary><varname>wd_port</varname>設定パラメータ</primary>
      </indexterm>
     </term>
     <listitem>
       <!--
       Specifies the port number to be used by watchdog
       process to listen for connections. Default is 9000.
+      The number at the end of the parameter name is referred
+      as "pgpool node id", and it starts from 0 (e.g. wd_port0).
       -->
       watchdogが接続を受け付けるために監視するポート番号です。
       デフォルト値は9000です。
+      パラメータ名の最後にある数字は「pgpool ノードID」で、0から始まります(たとえばwd_port0)。
      </para>
      <para>
       <!--
     </listitem>
    </varlistentry>
 
+   <varlistentry id="guc-pgpool-port" xreflabel="pgpool_port">
+    <term><varname>pgpool_portX</varname> (<type>integer</type>)
+     <indexterm>
+      <!--
+      <primary><varname>pgpool_portX</varname> configuration parameter</primary>
+      -->
+      <primary><varname>pgpool_portX</varname>設定パラメータ</primary>
+     </indexterm>
+    </term>
+    <listitem>
+     <para>
+      <!--
+      Specifies the <productname>Pgpool-II</productname> port number.
+      Default is 9999.
+      The number at the end of the parameter name is referred
+      as "pgpool node id", and it starts from 0 (e.g. pgpool_port0).
+      -->
+      <productname>Pgpool-II</productname>サーバのポート番号を指定します。
+      デフォルト値は9999です。
+      パラメータ名の最後にある数字は「pgpool ノードID」で、0から始まります(たとえばpgpool_port0)。
+     </para>
+     <para>
+      <!--
+      This parameter can only be set at server start.
+      -->
+      このパラメータは、サーバ起動時にのみ設定できます。
+     </para>
+     <example id="example-watchdog-1">
+      <!--
+      <title>Watchdog configuration</title>
+      -->
+      <title>Watchdogの設定例</title>
+      <para>
+       <!--
+       If you have 3 pgpool nodes with hostname server1, server2 and server3,
+       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 の場合、
+       <xref linkend="guc-hostname">、<xref linkend="guc-wd-port">
+       及び<xref linkend="guc-pgpool-port">を以下のように設定します。
+    <programlisting>
+     hostname0 = 'server1'
+     wd_port0 = 9000
+     pgpool_port0 = 9999
+
+     hostname1 = 'server2'
+     wd_port1 = 9000
+     pgpool_port1 = 9999
+
+     hostname2 = 'server3'
+     wd_port2 = 9000
+     pgpool_port2 = 9999
+    </programlisting>
+      </para>
+     </example>
+    </listitem>
+   </varlistentry>
+
    <varlistentry id="guc-wd-authkey" xreflabel="wd_authkey">
     <term><varname>wd_authkey</varname> (<type>string</type>)
      <indexterm>
   <title>死活監視:ハートビートモードの設定</title>
 
   <variablelist>
-   <varlistentry id="guc-wd-heartbeat-port" xreflabel="wd_heartbeat_port">
-    <term><varname>wd_heartbeat_port</varname> (<type>integer</type>)
+   <varlistentry id="guc-heartbeat-hostname" xreflabel="heartbeat_hostname">
+    <term><varname>heartbeat_hostnameX</varname> (<type>string</type>)
      <indexterm>
       <!--
-      <primary><varname>wd_heartbeat_port</varname> configuration parameter</primary>
+      <primary><varname>heartbeat_hostnameX</varname> configuration parameter</primary>
       -->
-      <primary><varname>wd_heartbeat_port</varname>設定パラメータ</primary>
+      <primary><varname>heartbeat_hostnameX</varname>設定パラメータ</primary>
      </indexterm>
     </term>
     <listitem>
      <para>
       <!--
-      Specifies the <acronym>UDP</acronym> port number to receive heartbeat signals.
-      Default is 9694.
-      <varname>wd_heartbeat_port</varname> is only applicable if the
-      <xref linkend="guc-wd-lifecheck-method"> is set to <literal>'heartbeat'</literal>
-      -->
-      ハートビート信号を受信する<acronym>UDP</acronym>ポート番号を指定します。
-      デフォルトは 9694 です。
-      <xref linkend="guc-wd-lifecheck-method">が<literal>'heartbeat'</literal>に設定されている場合のみ有効です。
-     </para>
-     <para>
-      <!--
-      This parameter can only be set at server start.
+      Specifies the <acronym>IP</acronym> address or <acronym>hostname</acronym> of
+      for sending and receiving the heartbeat signals.
+      Multiple destinations can be configured for the heartbeat singnals,
+      the number at the end of the parameter name is
+      referred as the "pgpool node id", that starts from 0.
       -->
-      このパラメータは、サーバ起動時にのみ設定できます。
+      ハートビート信号を送受信するための<acronym>IP</acronym>アドレスまたは <acronym>ホスト名</acronym>を指定します。
+      パラメータ名の最後にある数字は「pgpool ノードID」で、0から始まります(たとえばheartbeat_hostname0)。
+      複数のハートビート信号の送り先をセミコロン(;)で区切って指定することができます。
      </para>
-    </listitem>
-   </varlistentry>
-
-   <varlistentry id="guc-wd-heartbeat-keepalive" xreflabel="wd_heartbeat_keepalive">
-    <term><varname>wd_heartbeat_keepalive</varname> (<type>integer</type>)
-     <indexterm>
-      <!--
-      <primary><varname>wd_heartbeat_keepalive</varname> configuration parameter</primary>
-      -->
-      <primary><varname>wd_heartbeat_keepalive</varname>設定パラメータ</primary>
-     </indexterm>
-    </term>
-    <listitem>
      <para>
       <!--
-      Specifies the interval time in seconds between sending the heartbeat signals.
-      Default is 2.
-      <varname>wd_heartbeat_keepalive</varname> is only applicable if the
+      <varname>heartbeat_hostnameX</varname> is only applicable if the
       <xref linkend="guc-wd-lifecheck-method"> is set to <literal>'heartbeat'</literal>
       -->
-      ハートビート信号を送信する間隔(秒)を指定します。
-      デフォルトは2です。
-      <varname>wd_heartbeat_keepalive</varname>は、<xref linkend="guc-wd-lifecheck-method">が<literal>'heartbeat'</literal>に設定されている場合のみ有効です。
+      <varname>heartbeat_hostnameX</varname>は、<xref linkend="guc-wd-lifecheck-method">が<literal>'heartbeat'</literal>に設定されている場合のみ有効です。
      </para>
-
      <para>
       <!--
       This parameter can only be set at server start.
     </listitem>
    </varlistentry>
 
-   <varlistentry id="guc-wd-heartbeat-deadtime" xreflabel="wd_heartbeat_deadtime">
-    <term><varname>wd_heartbeat_deadtime</varname> (<type>integer</type>)
+   <varlistentry id="guc-heartbeat-port" xreflabel="heartbeat_port">
+    <term><varname>heartbeat_portX</varname> (<type>integer</type>)
      <indexterm>
       <!--
-      <primary><varname>wd_heartbeat_deadtime</varname> configuration parameter</primary>
+      <primary><varname>heartbeat_portX</varname> configuration parameter</primary>
       -->
-      <primary><varname>wd_heartbeat_deadtime</varname>設定パラメータ</primary>
+      <primary><varname>heartbeat_portX</varname>設定パラメータ</primary>
      </indexterm>
     </term>
     <listitem>
      <para>
       <!--
-      Specifies the time in seconds before marking the remote watchdog node as failed/dead node,
-      if no heartbeat signal is received within that time.
-      DDefault is <literal>30</literal>
-      <varname>wd_heartbeat_deadtime</varname> is only applicable if the
+      Specifies the port number for sending the heartbeat signals.
+      Multiple destinations can be configured for the heartbeat singnals,
+      the number at the end of the parameter name is
+      referred as the "pgpool node id", that starts from 0.
+      -->
+      ハートビート信号を受信するためのポート番号を指定します。
+      1つのみを指定してください。
+      パラメータ名の最後にある数字は「pgpool ノードID」で、0から始まります(たとえばheartbeat_port0)。
+     </para>
+     <para>
+      <!--
+      <varname>heartbeat_portX</varname> is only applicable if the
       <xref linkend="guc-wd-lifecheck-method"> is set to <literal>'heartbeat'</literal>
       -->
-      このオプションで指定された間隔(秒)の間ハートビート信号が途絶えた場合、リモートのwatchdogに障害が発生したとみなされます。
-      デフォルトは<literal>30</literal>です。
+      <varname>heartbeat_portX</varname>は、<xref linkend="guc-wd-lifecheck-method"> が <literal>'heartbeat'</literal>に設定されている場合のみ有効です。
      </para>
      <para>
       <!--
       -->
       このパラメータは、サーバ起動時にのみ設定できます。
      </para>
-
     </listitem>
    </varlistentry>
-   <varlistentry id="guc-heartbeat-destination" xreflabel="heartbeat_destination<emphasis>0</emphasis>">
-    <term><varname>heartbeat_destination0</varname> (<type>string</type>)
+
+   <varlistentry id="guc-heartbeat-device" xreflabel="heartbeat_device">
+    <term><varname>heartbeat_deviceX</varname> (<type>string</type>)
      <indexterm>
       <!--
-      <primary><varname>heartbeat_destination</varname> configuration parameter</primary>
+      <primary><varname>heartbeat_deviceX</varname> configuration parameter</primary>
       -->
-      <primary><varname>heartbeat_destination</varname>設定パラメータ</primary>
+      <primary><varname>heartbeat_deviceX</varname>設定パラメータ</primary>
      </indexterm>
     </term>
     <listitem>
      <para>
       <!--
-      Specifies the <acronym>IP</acronym> address or <acronym>hostname</acronym> of destination the remote
-      <productname>Pgpool-II</productname> for sending the heartbeat signals.
-      Multiple destinations can be configured for the heartbeat singnals,
-      the number at the end of the parameter name is
-      referred as the "destination number", that starts from 0.
+      Specifies the network device name for sending and receiving the heartbeat signals.
+      The number at the end of the parameter name is referred
+      as "pgpool node id", and it starts from 0 (e.g. heartbeat_device0).
+         You can specify multiple network devices by separating them using semicolon (;).
       -->
-      ハートビート信号の送る先の<acronym>IP</acronym>アドレスまたは <acronym>ホスト名</acronym>を指定します。
-      複数のハートビート信号の送り先が指定可能です
-      0から始まるパラメータの最後の部分は送り先の番号です。
+      ハートビートの送受信に用いるネットワークデバイス名を指定します。
+      パラメータ名の最後にある数字は「pgpool ノードID」で、0から始まります(たとえばheartbeat_device0)
+      複数のネットワークデバイス名をセミコロン(;)で区切って指定することができます。
      </para>
      <para>
       <!--
-      <varname>heartbeat_destination</varname> is only applicable if the
+      <varname>heartbeat_deviceX</varname> is only applicable if the
       <xref linkend="guc-wd-lifecheck-method"> is set to <literal>'heartbeat'</literal>
       -->
-      <varname>heartbeat_destination</varname>は、<xref linkend="guc-wd-lifecheck-method">が<literal>'heartbeat'</literal>に設定されている場合のみ有効です。
+      <varname>heartbeat_deviceX</varname>は、<xref linkend="guc-wd-lifecheck-method">が<literal>'heartbeat'</literal>に設定されている場合のみ有効です。
      </para>
      <para>
       <!--
       -->
       このパラメータは、サーバ起動時にのみ設定できます。
      </para>
+     <example id="example-heartbeat-1">
+      <!--
+      <title>Heartbeat configuration</title>
+      -->
+      <title>Heartbeat 信号を用いた死活監視の設定例</title>
+      <para>
+       <!--
+       If you have 3 pgpool nodes with hostname server1, server2 and server3,
+       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 の場合、
+       <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>
+      </para>
+     </example>
     </listitem>
    </varlistentry>
 
-   <varlistentry id="guc-heartbeat-destination-port" xreflabel="heartbeat_destination_port<emphasis>0</emphasis>">
-    <term><varname>heartbeat_destination_port0</varname> (<type>integer</type>)
+   <varlistentry id="guc-wd-heartbeat-keepalive" xreflabel="wd_heartbeat_keepalive">
+    <term><varname>wd_heartbeat_keepalive</varname> (<type>integer</type>)
      <indexterm>
       <!--
-      <primary><varname>heartbeat_destination_port</varname> configuration parameter</primary>
+      <primary><varname>wd_heartbeat_keepalive</varname> configuration parameter</primary>
       -->
-      <primary><varname>heartbeat_destination_port</varname>設定パラメータ</primary>
+      <primary><varname>wd_heartbeat_keepalive</varname>設定パラメータ</primary>
      </indexterm>
     </term>
     <listitem>
      <para>
       <!--
-      Specifies the destination port number for the heartbeat_destinationX of the remote
-      <productname>Pgpool-II</productname> for sending the heartbeat signals.
-      Multiple destinations can be configured for the heartbeat singnals,
-      the number at the end of the parameter name is
-      referred as the "destination number", that starts from 0.
-      -->
-      ハートビート信号の送る先のポート番号を指定します。
-      複数のハートビート信号の送り先が指定可能です。
-      0から始まるパラメータの最後の部分は送り先の番号です。
-     </para>
-     <para>
-      <!--
-      <varname>heartbeat_destination_port</varname> is only applicable if the
+      Specifies the interval time in seconds between sending the heartbeat signals.
+      Default is 2.
+      <varname>wd_heartbeat_keepalive</varname> is only applicable if the
       <xref linkend="guc-wd-lifecheck-method"> is set to <literal>'heartbeat'</literal>
       -->
-      <varname>heartbeat_destination_port</varname>は、<xref linkend="guc-wd-lifecheck-method"> が <literal>'heartbeat'</literal>に設定されている場合のみ有効です。 
+      ハートビート信号を送信する間隔(秒)を指定します。
+      デフォルトは2です。
+      <varname>wd_heartbeat_keepalive</varname>は、<xref linkend="guc-wd-lifecheck-method">が<literal>'heartbeat'</literal>に設定されている場合のみ有効です。
      </para>
+
      <para>
       <!--
       This parameter can only be set at server start.
     </listitem>
    </varlistentry>
 
-   <varlistentry id="guc-heartbeat-device" xreflabel="heartbeat_device">
-    <term><varname>heartbeat_device0</varname> (<type>string</type>)
+   <varlistentry id="guc-wd-heartbeat-deadtime" xreflabel="wd_heartbeat_deadtime">
+    <term><varname>wd_heartbeat_deadtime</varname> (<type>integer</type>)
      <indexterm>
       <!--
-      <primary><varname>heartbeat_device</varname> configuration parameter</primary>
+      <primary><varname>wd_heartbeat_deadtime</varname> configuration parameter</primary>
       -->
-      <primary><varname>heartbeat_device</varname>設定パラメータ</primary>
+      <primary><varname>wd_heartbeat_deadtime</varname>設定パラメータ</primary>
      </indexterm>
     </term>
     <listitem>
      <para>
       <!--
-      Specifies the network device name for sending the heartbeat signals to the destination specified by
-      heartbeat_destinationX:heartbeat_destination_portX.
-      Different heartbeat devices can be configured for each heartbeat destination
-      by changing the value of X(destination number)
-      at the end of parameter name. The destination index number starts from 0.
-      -->
-      heartbeat_destinationX:heartbeat_destination_portXで指定されるハートビートの送信先に用いるネットワークデバイス名を指定します。
-      パラメータ名の最後にあるXの値(送信先番号)を変えることにより、ハートビートの送信先ごとに異なるハートビートデバイス番号を設定することが可能です。
-      送信先番号は0から始まります。
-     </para>
-     <para>
-      <!--
-      <varname>heartbeat_device</varname> is only applicable if the
+      Specifies the time in seconds before marking the remote watchdog node as failed/dead node,
+      if no heartbeat signal is received within that time.
+      DDefault is <literal>30</literal>
+      <varname>wd_heartbeat_deadtime</varname> is only applicable if the
       <xref linkend="guc-wd-lifecheck-method"> is set to <literal>'heartbeat'</literal>
       -->
-      <varname>heartbeat_device</varname>は、<xref linkend="guc-wd-lifecheck-method">が<literal>'heartbeat'</literal>に設定されている場合のみ有効です。
+      このオプションで指定された間隔(秒)の間ハートビート信号が途絶えた場合、リモートのwatchdogに障害が発生したとみなされます。
+      デフォルトは<literal>30</literal>です。
      </para>
      <para>
       <!--
      </para>
     </listitem>
    </varlistentry>
-
   </variablelist>
  </sect2>
 
 
   </variablelist>
  </sect2>
-
- <sect2 id="config-watchdog-server-configuration">
-  <!--
-  <title>Watchdog servers configurations</title>
-  -->
-  <title>Watchdogサーバの設定</title>
-  <variablelist>
-
-   <varlistentry id="guc-other-pgpool-hostname" xreflabel="other_pgpool_hostname">
-    <term><varname>other_pgpool_hostname0</varname> (<type>string</type>)
-     <indexterm>
-      <!--
-      <primary><varname>other_pgpool_hostname</varname> configuration parameter</primary>
-      -->
-      <primary><varname>other_pgpool_hostname</varname>設定パラメータ</primary>
-     </indexterm>
-    </term>
-    <listitem>
-     <para>
-      <!--
-      Specifies the hostname of remote <productname>Pgpool-II</productname> server for watchdog node.
-      The number at the end of the parameter name is referred as "server id", and it starts from 0.
-      -->
-      リモートのwatchdogノードに対する<productname>Pgpool-II</productname>サーバのホスト名を指定します。
-      パラメータ名の最後にある数字は「サーバ番号」で、0から始まります。
-     </para>
-     <para>
-      <!--
-      This parameter can only be set at server start.
-      -->
-      このパラメータは、サーバ起動時にのみ設定できます。
-     </para>
-    </listitem>
-   </varlistentry>
-
-   <varlistentry id="guc-other-pgpool-port" xreflabel="other_pgpool_port">
-    <term><varname>other_pgpool_port0</varname> (<type>integer</type>)
-     <indexterm>
-      <!--
-      <primary><varname>other_pgpool_port</varname> configuration parameter</primary>
-      -->
-      <primary><varname>other_pgpool_port</varname>設定パラメータ</primary>
-     </indexterm>
-    </term>
-    <listitem>
-     <para>
-      <!--
-      Specifies the port number of the remote <productname>Pgpool-II</productname>
-      server for watchdog node.
-      The number at the end of the parameter name is referred
-      as "server id", and it starts from 0.
-      -->
-      リモートのwatchdogノードに対する<productname>Pgpool-II</productname>サーバのポート番号を指定します。
-      パラメータ名の最後にある数字は「サーバ番号」で、0から始まります。
-     </para>
-     <para>
-      <!--
-      This parameter can only be set at server start.
-      -->
-      このパラメータは、サーバ起動時にのみ設定できます。
-     </para>
-    </listitem>
-   </varlistentry>
-
-   <varlistentry id="guc-other-wd-port" xreflabel="other_wd_port">
-    <term><varname>other_wd_port0</varname> (<type>integer</type>)
-     <indexterm>
-      <!--
-      <primary><varname>other_wd_port0</varname> configuration parameter</primary>
-      -->
-      <primary><varname>other_wd_port0</varname>設定パラメータ</primary>
-     </indexterm>
-    </term>
-    <listitem>
-     <para>
-      <!--
-      Specifies the watchdog port number of the remote
-      <productname>Pgpool-II</productname> server for watchdog node.
-      The number at the end of the parameter name is referred
-      as "server id", and it starts from 0.
-      -->
-      リモートの<productname>Pgpool-II</productname>サーバにおけるwatchdogのポート番号を指定します。
-      パラメータ名の最後にある数字は「サーバ番号」で、0から始まります。
-     </para>
-     <para>
-      <!--
-      This parameter can only be set at server start.
-      -->
-      このパラメータは、サーバ起動時にのみ設定できます。
-     </para>
-    </listitem>
-   </varlistentry>
-
-  </variablelist>
- </sect2>
 </sect1>
index 102184330b0c42514c43ff1416cdf038031ae691..30193544ee9a5feca0331ceb860fd417c4455fc5 100644 (file)
   <para>
    Next, set the following parameters for each <productname>
     Pgpool-II</productname>.
-   Specify <xref linkend="guc-other-pgpool-hostname">,
-    <xref linkend="guc-other-pgpool-port"> and
-     <xref linkend="guc-other-wd-port"> with the values of
-      other <productname>Pgpool-II</productname> server values.
   </para>
 
   <sect3 id="example-watchdog-configuration-active-server">
      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
+       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-destination"> and finally
-         the destination port number <xref linkend="guc-heartbeat-destination-port">.
+        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')
index 8562b7060ddb7fd99dcfa1ad11be0f36fd41d6d0..b62020ffeb29422855058b3c758c917758e4a826 100644 (file)
 
   <variablelist>
 
-   <varlistentry id="guc-wd-hostname" xreflabel="wd_hostname">
-    <term><varname>wd_hostname</varname> (<type>string</type>)
+   <varlistentry id="guc-hostname" xreflabel="hostname">
+    <term><varname>hostnameX</varname> (<type>string</type>)
      <indexterm>
-      <primary><varname>wd_hostname</varname> configuration parameter</primary>
+      <primary><varname>hostnameX</varname> configuration parameter</primary>
      </indexterm>
     </term>
     <listitem>
@@ -52,6 +52,8 @@
       <productname>Pgpool-II</productname> server.
       This is used for sending/receiving queries and packets,
       and also as an identifier of the watchdog node.
+      The number at the end of the parameter name is referred
+      as "pgpool node id", and it starts from 0 (e.g. hostname0).
      </para>
      <para>
       This parameter can only be set at server start.
    </varlistentry>
 
    <varlistentry id="guc-wd-port" xreflabel="wd_port">
-    <term><varname>wd_port</varname> (<type>integer</type>)
+    <term><varname>wd_portX</varname> (<type>integer</type>)
      <indexterm>
-      <primary><varname>wd_port</varname> configuration parameter</primary>
+      <primary><varname>wd_portX</varname> configuration parameter</primary>
      </indexterm>
     </term>
     <listitem>
      <para>
       Specifies the port number to be used by watchdog
       process to listen for connections. Default is 9000.
+      The number at the end of the parameter name is referred
+      as "pgpool node id", and it starts from 0 (e.g. wd_port0).
+     </para>
+     <para>
+      This parameter can only be set at server start.
+     </para>
+    </listitem>
+   </varlistentry>
+
+   <varlistentry id="guc-pgpool-port" xreflabel="pgpool_port">
+    <term><varname>pgpool_portX</varname> (<type>integer</type>)
+     <indexterm>
+      <primary><varname>pgpool_portX</varname> configuration parameter</primary>
+     </indexterm>
+    </term>
+    <listitem>
+     <para>
+      Specifies the <productname>Pgpool-II</productname> port number.
+      Default is 9999.
+      The number at the end of the parameter name is referred
+      as "pgpool node id", and it starts from 0 (e.g. pgpool_port0).
      </para>
      <para>
       This parameter can only be set at server start.
      </para>
+
+     <example id="example-watchdog-1">
+      <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">,
+       <xref linkend="guc-wd-port"> and <xref linkend="guc-pgpool-port"> like below:
+    <programlisting>
+     hostname0 = 'server1'
+     wd_port0 = 9000
+     pgpool_port0 = 9999
+
+     hostname1 = 'server2'
+     wd_port1 = 9000
+     pgpool_port1 = 9999
+
+     hostname2 = 'server3'
+     wd_port2 = 9000
+     pgpool_port2 = 9999
+    </programlisting>
+      </para>
+     </example>
     </listitem>
    </varlistentry>
 
 
  <sect2 id="config-watchdog-lifecheck-heartbeat">
   <title>Lifecheck Heartbeat mode configuration</title>
-
   <variablelist>
-   <varlistentry id="guc-wd-heartbeat-port" xreflabel="wd_heartbeat_port">
-    <term><varname>wd_heartbeat_port</varname> (<type>integer</type>)
+   <varlistentry id="guc-heartbeat-hostname" xreflabel="heartbeat_hostname">
+    <term><varname>heartbeat_hostnameX</varname> (<type>string</type>)
      <indexterm>
-      <primary><varname>wd_heartbeat_port</varname> configuration parameter</primary>
+      <primary><varname>heartbeat_hostnameX</varname> configuration parameter</primary>
      </indexterm>
     </term>
     <listitem>
      <para>
-      Specifies the <acronym>UDP</acronym> port number to receive heartbeat signals.
-      Default is 9694.
-      <varname>wd_heartbeat_port</varname> is only applicable if the
-      <xref linkend="guc-wd-lifecheck-method"> is set to <literal>'heartbeat'</literal>
+      Specifies the <acronym>IP</acronym> address or <acronym>hostname</acronym>
+         for sending and receiving the heartbeat signals.
+      The number at the end of the parameter name is referred
+      as "pgpool node id", and it starts from 0 (e.g. heartbeat_hostname0).
+         You can specify multiple <acronym>IP</acronym> address or <acronym>hostname</acronym>
+      by separating them using semicolon (;).
      </para>
      <para>
-      This parameter can only be set at server start.
-     </para>
-    </listitem>
-   </varlistentry>
-
-   <varlistentry id="guc-wd-heartbeat-keepalive" xreflabel="wd_heartbeat_keepalive">
-    <term><varname>wd_heartbeat_keepalive</varname> (<type>integer</type>)
-     <indexterm>
-      <primary><varname>wd_heartbeat_keepalive</varname> configuration parameter</primary>
-     </indexterm>
-    </term>
-    <listitem>
-     <para>
-      Specifies the interval time in seconds between sending the heartbeat signals.
-      Default is 2.
-      <varname>wd_heartbeat_keepalive</varname> is only applicable if the
+      <varname>heartbeat_hostnameX</varname> is only applicable if the
       <xref linkend="guc-wd-lifecheck-method"> is set to <literal>'heartbeat'</literal>
      </para>
-
      <para>
       This parameter can only be set at server start.
      </para>
     </listitem>
    </varlistentry>
 
-   <varlistentry id="guc-wd-heartbeat-deadtime" xreflabel="wd_heartbeat_deadtime">
-    <term><varname>wd_heartbeat_deadtime</varname> (<type>integer</type>)
+   <varlistentry id="guc-heartbeat-port" xreflabel="heartbeat_port">
+    <term><varname>heartbeat_portX</varname> (<type>integer</type>)
      <indexterm>
-      <primary><varname>wd_heartbeat_deadtime</varname> configuration parameter</primary>
+      <primary><varname>heartbeat_portX</varname> configuration parameter</primary>
      </indexterm>
     </term>
     <listitem>
      <para>
-      Specifies the time in seconds before marking the remote watchdog node as failed/dead node,
-      if no heartbeat signal is received within that time.
-      Default is <literal>30</literal>
-      <varname>wd_heartbeat_deadtime</varname> is only applicable if the
+      Specifies the port number for sending and receiving the heartbeat signals.
+      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>
+     <para>
+      <varname>heartbeat_portX</varname> is only applicable if the
       <xref linkend="guc-wd-lifecheck-method"> is set to <literal>'heartbeat'</literal>
      </para>
      <para>
       This parameter can only be set at server start.
      </para>
-
     </listitem>
    </varlistentry>
-   <varlistentry id="guc-heartbeat-destination" xreflabel="heartbeat_destination<emphasis>0</emphasis>">
-    <term><varname>heartbeat_destination0</varname> (<type>string</type>)
+
+   <varlistentry id="guc-heartbeat-device" xreflabel="heartbeat_device">
+    <term><varname>heartbeat_deviceX</varname> (<type>string</type>)
      <indexterm>
-      <primary><varname>heartbeat_destination</varname> configuration parameter</primary>
+      <primary><varname>heartbeat_deviceX</varname> configuration parameter</primary>
      </indexterm>
     </term>
     <listitem>
      <para>
-      Specifies the <acronym>IP</acronym> address or <acronym>hostname</acronym> of destination the remote
-      <productname>Pgpool-II</productname> for sending the heartbeat signals.
-      Multiple destinations can be configured for the heartbeat signals,
-      the number at the end of the parameter name is
-      referred as the "destination number", that starts from 0.
+      Specifies the network device name for sending and receiving the heartbeat signals.
+      The number at the end of the parameter name is referred
+      as "pgpool node id", and it starts from 0 (e.g. heartbeat_device0).
+         You can specify multiple network devices by separating them using semicolon (;).
      </para>
      <para>
-      <varname>heartbeat_destination</varname> is only applicable if the
+      <varname>heartbeat_deviceX</varname> is only applicable if the
       <xref linkend="guc-wd-lifecheck-method"> is set to <literal>'heartbeat'</literal>
      </para>
      <para>
       This parameter can only be set at server start.
      </para>
+     <example id="example-heartbeat-1">
+      <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">,
+       <xref linkend="guc-heartbeat-port"> and <xref linkend="guc-heartbeat-device"> like below:
+       <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>
    </varlistentry>
 
-   <varlistentry id="guc-heartbeat-destination-port" xreflabel="heartbeat_destination_port<emphasis>0</emphasis>">
-    <term><varname>heartbeat_destination_port0</varname> (<type>integer</type>)
+   <varlistentry id="guc-wd-heartbeat-keepalive" xreflabel="wd_heartbeat_keepalive">
+    <term><varname>wd_heartbeat_keepalive</varname> (<type>integer</type>)
      <indexterm>
-      <primary><varname>heartbeat_destination_port</varname> configuration parameter</primary>
+      <primary><varname>wd_heartbeat_keepalive</varname> configuration parameter</primary>
      </indexterm>
     </term>
     <listitem>
      <para>
-      Specifies the destination port number of the remote
-      <productname>Pgpool-II</productname> for sending the heartbeat signals.
-      Multiple destinations can be configured for the heartbeat signals,
-      the number at the end of the parameter name is
-      referred as the "destination number", that starts from 0.
-     </para>
-     <para>
-      <varname>heartbeat_destination_port</varname> is only applicable if the
+      Specifies the interval time in seconds between sending the heartbeat signals.
+      Default is 2.
+      <varname>wd_heartbeat_keepalive</varname> is only applicable if the
       <xref linkend="guc-wd-lifecheck-method"> is set to <literal>'heartbeat'</literal>
      </para>
+
      <para>
       This parameter can only be set at server start.
      </para>
     </listitem>
    </varlistentry>
 
-   <varlistentry id="guc-heartbeat-device" xreflabel="heartbeat_device">
-    <term><varname>heartbeat_device0</varname> (<type>string</type>)
+   <varlistentry id="guc-wd-heartbeat-deadtime" xreflabel="wd_heartbeat_deadtime">
+    <term><varname>wd_heartbeat_deadtime</varname> (<type>integer</type>)
      <indexterm>
-      <primary><varname>heartbeat_device</varname> configuration parameter</primary>
+      <primary><varname>wd_heartbeat_deadtime</varname> configuration parameter</primary>
      </indexterm>
     </term>
     <listitem>
      <para>
-      Specifies the network device name for sending the heartbeat signals to the destination specified by
-      heartbeat_destinationX:heartbeat_destination_portX
-      Different heartbeat devices can be configured for each heartbeat destination
-      by changing the value of X(destination number).
-      at the end of parameter name. The destination index number starts from 0.
-     </para>
-     <para>
-      <varname>heartbeat_device</varname> is only applicable if the
+      Specifies the time in seconds before marking the remote watchdog node as failed/dead node,
+      if no heartbeat signal is received within that time.
+      Default is <literal>30</literal>
+      <varname>wd_heartbeat_deadtime</varname> is only applicable if the
       <xref linkend="guc-wd-lifecheck-method"> is set to <literal>'heartbeat'</literal>
      </para>
      <para>
      </para>
     </listitem>
    </varlistentry>
-
   </variablelist>
  </sect2>
 
 
   </variablelist>
  </sect2>
-
- <sect2 id="config-watchdog-server-configuration">
-  <title>Watchdog servers configurations</title>
-  <variablelist>
-
-   <varlistentry id="guc-other-pgpool-hostname" xreflabel="other_pgpool_hostname">
-    <term><varname>other_pgpool_hostname0</varname> (<type>string</type>)
-     <indexterm>
-      <primary><varname>other_pgpool_hostname</varname> configuration parameter</primary>
-     </indexterm>
-    </term>
-    <listitem>
-     <para>
-      Specifies the hostname of remote <productname>Pgpool-II</productname> server for watchdog node.
-      The number at the end of the parameter name is referred as "server id", and it starts from 0.
-     </para>
-     <para>
-      This parameter can only be set at server start.
-     </para>
-    </listitem>
-   </varlistentry>
-
-   <varlistentry id="guc-other-pgpool-port" xreflabel="other_pgpool_port">
-    <term><varname>other_pgpool_port0</varname> (<type>integer</type>)
-     <indexterm>
-      <primary><varname>other_pgpool_port</varname> configuration parameter</primary>
-     </indexterm>
-    </term>
-    <listitem>
-     <para>
-      Specifies the port number of the remote <productname>Pgpool-II</productname>
-      server for watchdog node.
-      The number at the end of the parameter name is referred
-      as "server id", and it starts from 0.
-     </para>
-     <para>
-      This parameter can only be set at server start.
-     </para>
-    </listitem>
-   </varlistentry>
-
-   <varlistentry id="guc-other-wd-port" xreflabel="other_wd_port">
-    <term><varname>other_wd_port0</varname> (<type>integer</type>)
-     <indexterm>
-      <primary><varname>other_wd_port0</varname> configuration parameter</primary>
-     </indexterm>
-    </term>
-    <listitem>
-     <para>
-      Specifies the watchdog port number of the remote
-      <productname>Pgpool-II</productname> server for watchdog node.
-      The number at the end of the parameter name is referred
-      as "server id", and it starts from 0.
-     </para>
-     <para>
-      This parameter can only be set at server start.
-     </para>
-    </listitem>
-   </varlistentry>
-
-  </variablelist>
- </sect2>
 </sect1>
index ac6aa74b869daa9161a99490fcce0e5d87821a62..c1165010cd3e930613adfa755f7705eeea00bb99 100644 (file)
@@ -480,6 +480,8 @@ static char *yy_last_accepting_cpos;
 extern int yy_flex_debug;
 int yy_flex_debug = 0;
 
+char    *config_file_dir = NULL; /* directory path of config file pgpool.conf */
+
 /* The intent behind this definition is that it'll catch
  * any uses of REJECT which flex missed.
  */
@@ -522,6 +524,7 @@ char *yytext;
 #include "pool_config.h"
 #include "pool_config_variables.h"
 #include "utils/regex_array.h"
+#include "utils/pool_path.h"
 #ifndef POOL_PRIVATE
 #include "utils/elog.h"
 #else
@@ -2062,9 +2065,15 @@ ParseConfigFile(const char *config_file, int elevel,
        char *key;
        char *val;
        ConfigVariable *item;
-       
+       char buf[POOLMAXPATHLEN + 1];
+
        *head_p = NULL;
 
+       /* get directory path of config file pgpool.conf */
+       strlcpy(buf, config_file, sizeof(buf));
+       get_parent_directory(buf);
+       config_file_dir = buf;
+
        /* open config file */
        fd = fopen(config_file, "r");
        if (!fd)
index 78a7dc119d51d0fe10467af035025847c0775283..8af4ea4487d2f7c1b52abc7bcee52fbcaeea84d1 100644 (file)
@@ -105,8 +105,8 @@ static char **get_list_from_string_regex_delim(const char *str, const char *deli
 /*show functions */
 static const char *IntValueShowFunc(int value);
 static const char *HBDestinationPortShowFunc(int index);
-static const char *HBDestinationShowFunc(int index);
 static const char *HBDeviceShowFunc(int index);
+static const char *HBHostnameShowFunc(int index);
 static const char *OtherWDPortShowFunc(int index);
 static const char *OtherPPPortShowFunc(int index);
 static const char *OtherPPHostShowFunc(int index);
@@ -140,9 +140,9 @@ static bool BackendDataDirAssignFunc(ConfigContext context, char *newval, int in
 static bool BackendFlagsAssignFunc(ConfigContext context, char *newval, int index, int elevel);
 static bool BackendWeightAssignFunc(ConfigContext context, double newval, int index, int elevel);
 static bool BackendAppNameAssignFunc(ConfigContext context, char *newval, int index, int elevel);
-static bool HBDestinationAssignFunc(ConfigContext context, char *newval, int index, int elevel);
 static bool HBDestinationPortAssignFunc(ConfigContext context, int newval, int index, int elevel);
 static bool HBDeviceAssignFunc(ConfigContext context, char *newval, int index, int elevel);
+static bool HBHostnameAssignFunc(ConfigContext context, char *newval, int index, int elevel);
 static bool OtherWDPortAssignFunc(ConfigContext context, int newval, int index, int elevel);
 static bool OtherPPPortAssignFunc(ConfigContext context, int newval, int index, int elevel);
 static bool OtherPPHostAssignFunc(ConfigContext context, char *newval, int index, int elevel);
@@ -160,6 +160,8 @@ static bool HealthCheckDatabaseAssignFunc(ConfigContext context, char *newval, i
 static bool LogDestinationProcessFunc(char *newval, int elevel);
 static bool SyslogIdentProcessFunc(char *newval, int elevel);
 static bool SyslogFacilityProcessFunc(int newval, int elevel);
+static bool SetHBDestIfFunc(int elevel);
+static bool SetPgpoolNodeId(int elevel);
 
 static struct config_generic *get_index_free_record_if_any(struct config_generic *record);
 
@@ -1031,16 +1033,6 @@ static struct config_string ConfigureNamesString[] =
                NULL, NULL, NULL, NULL
        },
 
-       {
-               {"wd_hostname", CFGCXT_INIT, WATCHDOG_CONFIG,
-                       "Host name or IP address of this watchdog.",
-                       CONFIG_VAR_TYPE_STRING, false, 0
-               },
-               &g_pool_config.wd_hostname,
-               "",
-               NULL, NULL, NULL, NULL
-       },
-
        {
                {"ping_path", CFGCXT_INIT, WATCHDOG_CONFIG,
                        "path to ping command.",
@@ -1448,8 +1440,8 @@ static struct config_int_array ConfigureNamesIntArray[] =
        },
 
        {
-               {"heartbeat_destination_port", CFGCXT_RELOAD, WATCHDOG_LIFECHECK,
-                       "Destination port for sending heartbeat.",
+               {"heartbeat_port", CFGCXT_RELOAD, WATCHDOG_LIFECHECK,
+                       "Port for sending heartbeat.",
                        CONFIG_VAR_TYPE_INT_ARRAY, true, 0, WD_MAX_IF_NUM
                },
                NULL,
@@ -1460,7 +1452,7 @@ static struct config_int_array ConfigureNamesIntArray[] =
        },
 
        {
-               {"other_wd_port", CFGCXT_RELOAD, WATCHDOG_CONFIG,
+               {"wd_port", CFGCXT_RELOAD, WATCHDOG_CONFIG,
                        "tcp/ip watchdog port number of other pgpool node for watchdog connection..",
                        CONFIG_VAR_TYPE_INT_ARRAY, true, 0, MAX_WATCHDOG_NUM
                },
@@ -1472,7 +1464,7 @@ static struct config_int_array ConfigureNamesIntArray[] =
        },
 
        {
-               {"other_pgpool_port", CFGCXT_RELOAD, WATCHDOG_CONFIG,
+               {"pgpool_port", CFGCXT_RELOAD, WATCHDOG_CONFIG,
                        "tcp/ip pgpool port number of other pgpool node for watchdog connection.",
                        CONFIG_VAR_TYPE_INT_ARRAY, true, 0, MAX_WATCHDOG_NUM
                },
@@ -1677,14 +1669,14 @@ static struct config_string_array ConfigureNamesStringArray[] =
        },
 
        {
-               {"heartbeat_destination", CFGCXT_RELOAD, WATCHDOG_LIFECHECK,
-                       "destination host for sending heartbeat signal.",
+               {"heartbeat_hostname", CFGCXT_RELOAD, WATCHDOG_LIFECHECK,
+                       "Hostname for sending heartbeat signal.",
                        CONFIG_VAR_TYPE_STRING_ARRAY, true, 0, WD_MAX_IF_NUM
                },
                NULL,
                "",
                EMPTY_CONFIG_STRING,
-               HBDestinationAssignFunc, NULL, HBDestinationShowFunc, WdIFSlotEmptyCheckFunc
+               HBHostnameAssignFunc, NULL, HBHostnameShowFunc, WdIFSlotEmptyCheckFunc
        },
 
        {
@@ -1699,8 +1691,8 @@ static struct config_string_array ConfigureNamesStringArray[] =
        },
 
        {
-               {"other_pgpool_hostname", CFGCXT_RELOAD, WATCHDOG_LIFECHECK,
-                       "Hostname of other pgpool node for watchdog connection.",
+               {"hostname", CFGCXT_RELOAD, WATCHDOG_LIFECHECK,
+                       "Hostname of pgpool node for watchdog connection.",
                        CONFIG_VAR_TYPE_STRING_ARRAY, true, 0, MAX_WATCHDOG_NUM
                },
                NULL,
@@ -1941,17 +1933,6 @@ static struct config_int ConfigureNamesInt[] =
                NULL, NULL, NULL
        },
 
-       {
-               {"wd_port", CFGCXT_INIT, WATCHDOG_CONFIG,
-                       "tcp/IP port number on which watchdog of process of pgpool will listen on.",
-                       CONFIG_VAR_TYPE_INT, false, 0
-               },
-               &g_pool_config.wd_port,
-               9000,
-               1024, INT_MAX,
-               NULL, NULL, NULL
-       },
-
        {
                {"wd_priority", CFGCXT_INIT, WATCHDOG_CONFIG,
                        "Watchdog node priority for leader election.",
@@ -1985,17 +1966,6 @@ static struct config_int ConfigureNamesInt[] =
                NULL, NULL, NULL
        },
 
-       {
-               {"wd_heartbeat_port", CFGCXT_INIT, WATCHDOG_CONFIG,
-                       "Port number for receiving heartbeat signal.",
-                       CONFIG_VAR_TYPE_INT, false, 0
-               },
-               &g_pool_config.wd_heartbeat_port,
-               9694,
-               1024, 65535,
-               NULL, NULL, NULL
-       },
-
        {
                {"wd_heartbeat_keepalive", CFGCXT_INIT, WATCHDOG_CONFIG,
                        "Time interval in seconds between sending the heartbeat siganl.",
@@ -2531,11 +2501,11 @@ build_variable_groups(void)
        ConfigureVarGroups[1].var_count = 3;
        ConfigureVarGroups[1].var_list = palloc0(sizeof(struct config_generic *) * ConfigureVarGroups[1].var_count);
        /* backend hostname */
-       ConfigureVarGroups[1].var_list[0] = find_option("other_pgpool_hostname", FATAL);
+       ConfigureVarGroups[1].var_list[0] = find_option("hostname", FATAL);
        ConfigureVarGroups[1].var_list[0]->flags |= VAR_PART_OF_GROUP;
-       ConfigureVarGroups[1].var_list[1] = find_option("other_pgpool_port", FATAL);
+       ConfigureVarGroups[1].var_list[1] = find_option("pgpool_port", FATAL);
        ConfigureVarGroups[1].var_list[1]->flags |= VAR_PART_OF_GROUP;
-       ConfigureVarGroups[1].var_list[2] = find_option("other_wd_port", FATAL);
+       ConfigureVarGroups[1].var_list[2] = find_option("wd_port", FATAL);
        ConfigureVarGroups[1].var_list[2]->flags |= VAR_PART_OF_GROUP;
        ConfigureVarGroups[1].gen.max_elements = ConfigureVarGroups[1].var_list[0]->max_elements;
 
@@ -2546,9 +2516,9 @@ build_variable_groups(void)
        /* backend hostname */
        ConfigureVarGroups[2].var_list[0] = find_option("heartbeat_device", FATAL);
        ConfigureVarGroups[2].var_list[0]->flags |= VAR_PART_OF_GROUP;
-       ConfigureVarGroups[2].var_list[1] = find_option("heartbeat_destination", FATAL);
+       ConfigureVarGroups[2].var_list[1] = find_option("heartbeat_hostname", FATAL);
        ConfigureVarGroups[2].var_list[1]->flags |= VAR_PART_OF_GROUP;
-       ConfigureVarGroups[2].var_list[2] = find_option("heartbeat_destination_port", FATAL);
+       ConfigureVarGroups[2].var_list[2] = find_option("heartbeat_port", FATAL);
        ConfigureVarGroups[2].var_list[2]->flags |= VAR_PART_OF_GROUP;
        ConfigureVarGroups[2].gen.max_elements = ConfigureVarGroups[2].var_list[0]->max_elements;
 
@@ -4338,50 +4308,50 @@ BackendSlotEmptyCheckFunc(int index)
 static bool
 WdSlotEmptyCheckFunc(int index)
 {
-       return (g_pool_config.wd_remote_nodes.wd_remote_node_info[index].pgpool_port == 0);
+       return (g_pool_config.wd_nodes.wd_node_info[index].pgpool_port == 0);
 }
 
 static bool
 WdIFSlotEmptyCheckFunc(int index)
 {
 
-       return (index >= g_pool_config.num_hb_if);
+       return (index >= g_pool_config.num_hb_dest_if);
 }
 
 static const char *
 OtherPPHostShowFunc(int index)
 {
-       return g_pool_config.wd_remote_nodes.wd_remote_node_info[index].hostname;
+       return g_pool_config.wd_nodes.wd_node_info[index].hostname;
 }
 
 static const char *
 OtherPPPortShowFunc(int index)
 {
-       return IntValueShowFunc(g_pool_config.wd_remote_nodes.wd_remote_node_info[index].pgpool_port);
+       return IntValueShowFunc(g_pool_config.wd_nodes.wd_node_info[index].pgpool_port);
 }
 
 static const char *
 OtherWDPortShowFunc(int index)
 {
-       return IntValueShowFunc(g_pool_config.wd_remote_nodes.wd_remote_node_info[index].wd_port);
+       return IntValueShowFunc(g_pool_config.wd_nodes.wd_node_info[index].wd_port);
 }
 
 static const char *
 HBDeviceShowFunc(int index)
 {
-       return g_pool_config.hb_if[index].if_name;
+       return g_pool_config.hb_ifs[index].if_name;
 }
 
 static const char *
-HBDestinationShowFunc(int index)
+HBHostnameShowFunc(int index)
 {
-       return g_pool_config.hb_if[index].addr;
+       return g_pool_config.hb_ifs[index].addr;
 }
 
 static const char *
 HBDestinationPortShowFunc(int index)
 {
-       return IntValueShowFunc(g_pool_config.hb_if[index].dest_port);
+       return IntValueShowFunc(g_pool_config.hb_ifs[index].dest_port);
 }
 
 static const char *
@@ -4505,31 +4475,31 @@ HealthCheckDatabaseAssignFunc(ConfigContext context, char *newval, int index, in
        return true;
 }
 
-/* Watchdog Assign functions */
-/*other_pgpool_hostname*/
+/* Watchdog hostname and heartbeat hostname assign functions */
+/* hostname */
 static bool
 OtherPPHostAssignFunc(ConfigContext context, char *newval, int index, int elevel)
 {
        if (newval == NULL || strlen(newval) == 0)
-               g_pool_config.wd_remote_nodes.wd_remote_node_info[index].hostname[0] = '\0';
+               g_pool_config.wd_nodes.wd_node_info[index].hostname[0] = '\0';
        else
-               strlcpy(g_pool_config.wd_remote_nodes.wd_remote_node_info[index].hostname, newval, MAX_DB_HOST_NAMELEN - 1);
+               strlcpy(g_pool_config.wd_nodes.wd_node_info[index].hostname, newval, MAX_DB_HOST_NAMELEN - 1);
        return true;
 }
 
-/*other_pgpool_port*/
+/* pgpool_port */
 static bool
 OtherPPPortAssignFunc(ConfigContext context, int newval, int index, int elevel)
 {
-       g_pool_config.wd_remote_nodes.wd_remote_node_info[index].pgpool_port = newval;
+       g_pool_config.wd_nodes.wd_node_info[index].pgpool_port = newval;
        return true;
 }
 
-/*other_wd_port*/
+/* wd_port */
 static bool
 OtherWDPortAssignFunc(ConfigContext context, int newval, int index, int elevel)
 {
-       g_pool_config.wd_remote_nodes.wd_remote_node_info[index].wd_port = newval;
+       g_pool_config.wd_nodes.wd_node_info[index].wd_port = newval;
        return true;
 }
 
@@ -4538,28 +4508,28 @@ static bool
 HBDeviceAssignFunc(ConfigContext context, char *newval, int index, int elevel)
 {
        if (newval == NULL || strlen(newval) == 0)
-               g_pool_config.hb_if[index].if_name[0] = '\0';
+               g_pool_config.hb_ifs[index].if_name[0] = '\0';
        else
-               strlcpy(g_pool_config.hb_if[index].if_name, newval, WD_MAX_IF_NAME_LEN);
+               strlcpy(g_pool_config.hb_ifs[index].if_name, newval, WD_MAX_IF_NAME_LEN - 1);
        return true;
 }
 
-/*heartbeat_destination*/
+/*heartbeat_hostname*/
 static bool
-HBDestinationAssignFunc(ConfigContext context, char *newval, int index, int elevel)
+HBHostnameAssignFunc(ConfigContext context, char *newval, int index, int elevel)
 {
        if (newval == NULL || strlen(newval) == 0)
-               g_pool_config.hb_if[index].addr[0] = '\0';
+               g_pool_config.hb_ifs[index].addr[0] = '\0';
        else
-               strlcpy(g_pool_config.hb_if[index].addr, newval, WD_MAX_HOST_NAMELEN - 1);
+               strlcpy(g_pool_config.hb_ifs[index].addr, newval, WD_MAX_HOST_NAMELEN - 1);
        return true;
 }
 
-/*heartbeat_destination_port*/
+/*heartbeat_port*/
 static bool
 HBDestinationPortAssignFunc(ConfigContext context, int newval, int index, int elevel)
 {
-       g_pool_config.hb_if[index].dest_port = newval;
+       g_pool_config.hb_ifs[index].dest_port = newval;
        return true;
 }
 
@@ -4618,9 +4588,12 @@ check_redirect_node_spec(char *node_spec)
 static bool
 config_post_processor(ConfigContext context, int elevel)
 {
-       double          total_weight = 0.0;
+       double           total_weight = 0.0;
        sig_atomic_t local_num_backends = 0;
-       int                     i;
+       int                      i;
+
+       /* read from pgpool_node_id */
+       SetPgpoolNodeId(elevel);
 
        if (context == CFGCXT_BOOT)
        {
@@ -4634,7 +4607,7 @@ config_post_processor(ConfigContext context, int elevel)
                                         errdetail("failed to get the local hostname")));
                        return false;
                }
-               g_pool_config.wd_hostname = pstrdup(localhostname);
+               strcpy(g_pool_config.wd_nodes.wd_node_info[g_pool_config.pgpool_node_id].hostname, localhostname);
                return true;
        }
        for (i = 0; i < MAX_CONNECTION_SLOTS; i++)
@@ -4695,23 +4668,25 @@ config_post_processor(ConfigContext context, int elevel)
        }
 
        /* Set the number of configured Watchdog nodes */
-       g_pool_config.wd_remote_nodes.num_wd = 0;
+       g_pool_config.wd_nodes.num_wd = 0;
        for (i = 0; i < MAX_WATCHDOG_NUM; i++)
        {
-               WdRemoteNodeInfo *wdNode = &g_pool_config.wd_remote_nodes.wd_remote_node_info[i];
+               WdNodeInfo *wdNode = &g_pool_config.wd_nodes.wd_node_info[i];
 
-               if (wdNode->wd_port > 0)
-                       g_pool_config.wd_remote_nodes.num_wd = i + 1;
-       }
+               if (i == g_pool_config.pgpool_node_id && wdNode->wd_port <= 0)
+        {
+            ereport(elevel,
+                    (errmsg("invalid watchdog configuration"),
+                     errdetail("no watchdog configuration for local pgpool node, pgpool node id: %d ", g_pool_config.pgpool_node_id)));
+            return false;
+        }
 
-       /* Set the number of configured heartbeat interfaces */
-       g_pool_config.num_hb_if = 0;
-       for (i = 0; i < WD_MAX_IF_NUM; i++)
-       {
-               if (g_pool_config.hb_if[i].dest_port > 0)
-                       g_pool_config.num_hb_if = i + 1;
+               if (wdNode->wd_port > 0)
+                       g_pool_config.wd_nodes.num_wd = i + 1;
        }
 
+       /* Set configured heartbeat destination interfaces */
+       SetHBDestIfFunc(elevel);
 
        if (strcmp(pool_config->recovery_1st_stage_command, "") ||
                strcmp(pool_config->recovery_2nd_stage_command, ""))
@@ -4914,6 +4889,135 @@ MakeDBRedirectListRegex(char *newval, int elevel)
        return true;
 }
 
+/* Read the pgpool_node_id file */
+static bool
+SetPgpoolNodeId(int elevel)
+{
+       char            pgpool_node_id_file[POOLMAXPATHLEN + 1];
+       FILE            *fd;
+       int         length;
+
+       if (g_pool_config.use_watchdog)
+       {
+               snprintf(pgpool_node_id_file, sizeof(pgpool_node_id_file), "%s/%s", config_file_dir, NODE_ID_FILE_NAME);
+
+#define MAXLINE 10
+               char        readbuf[MAXLINE];
+
+               fd = fopen(pgpool_node_id_file, "r");
+               if (!fd)
+                       ereport(elevel,
+                                       (errmsg("Pgpool node id file %s does not exist", pgpool_node_id_file),
+                                        errdetail("If watchdog is enable, pgpool_node_id file is required")));
+
+               readbuf[MAXLINE - 1] = '\0';
+               if (fgets(readbuf, MAXLINE - 1, fd) == 0)
+               {
+                       ereport(elevel,
+                                       (errmsg("pgpool_node_id file is empty"),
+                                        errdetail("If watchdog is enable, we need to specify pgpool node id in %s file", pgpool_node_id_file)));
+               }
+
+               length = strlen(readbuf);
+               if (length > 0 && readbuf[length - 1] == '\n')
+                       readbuf[length - 1] = '\0';
+
+               g_pool_config.pgpool_node_id = atoi(readbuf);
+
+               if (g_pool_config.pgpool_node_id < 0 || g_pool_config.pgpool_node_id > MAX_WATCHDOG_NUM)
+                       ereport(elevel,
+                                       (errmsg("Invalid pgpool node id \"%d\", must be between 0 and %d",
+                                                       g_pool_config.pgpool_node_id, MAX_WATCHDOG_NUM)));
+               else
+                       ereport(DEBUG1,
+                                       (errmsg("read pgpool node id file %s", pgpool_node_id_file),
+                                        errdetail("pgpool node id: %s", readbuf)));
+       }
+
+       return true;
+}
+
+/* Set configured heartbeat destination interfaces */
+static bool
+SetHBDestIfFunc(int elevel)
+{
+       int             idx = 0;
+       char    **addrs;
+       char    **if_names;
+       int             i, j,
+                       n_addr,
+                       n_if_name;
+
+       g_pool_config.num_hb_dest_if = 0;
+
+       if (g_pool_config.wd_lifecheck_method != LIFECHECK_BY_HB)
+       {
+               return true;
+       }
+
+       /*
+        * g_pool_config.hb_ifs is the information for sending/receiving heartbeat
+        * for all nodes specied in pgpool.conf.
+        * If it is local pgpool node information, set dest_port to g_pool_config.wd_heartbeat_port
+        * and ignore addr and if_name.
+        * g_pool_config.hb_dest_if is the heartbeat destination information.
+        */
+       for (i = 0; i < WD_MAX_IF_NUM; i++)
+       {
+               if (g_pool_config.hb_ifs[i].dest_port > 0)
+               {
+                       /* Ignore local pgpool node */
+                       if (i == g_pool_config.pgpool_node_id)
+                       {
+                               g_pool_config.wd_heartbeat_port = g_pool_config.hb_ifs[i].dest_port;
+                               continue;
+                       }
+
+                       WdHbIf *hbNodeInfo = &g_pool_config.hb_ifs[i];
+
+                       addrs = get_list_from_string(hbNodeInfo->addr, ";", &n_addr);
+                       if_names = get_list_from_string(hbNodeInfo->if_name, ";", &n_if_name);
+
+                       if (!addrs || n_addr < 0)
+                       {
+                               g_pool_config.hb_dest_if[idx].addr[0] = '\0';
+
+                               if (addrs)
+                                       pfree(addrs);
+
+                               ereport(elevel,
+                                               (errmsg("invalid watchdog configuration"),
+                                                errdetail("heartbeat_hostname%d is not defined", i)));
+
+                               return false;
+                       }
+
+                       for (j = 0; j < n_addr; j++)
+                       {
+                               strlcpy(g_pool_config.hb_dest_if[idx].addr, addrs[j], WD_MAX_HOST_NAMELEN - 1);
+                               g_pool_config.hb_dest_if[idx].dest_port = hbNodeInfo->dest_port;
+                               if (n_if_name > j + 1)
+                               {
+                                       strlcpy(g_pool_config.hb_dest_if[idx].if_name, if_names[j], WD_MAX_IF_NAME_LEN - 1);
+                                       pfree(if_names[j]);
+                               }
+                               else
+                                       g_pool_config.hb_dest_if[idx].if_name[0] = '\0';
+
+                               g_pool_config.num_hb_dest_if = idx + 1;
+                               idx++;
+                               pfree(addrs[j]);
+                       }
+
+                       if (addrs)
+                               pfree(addrs);
+                       if (if_names)
+                               pfree(if_names);
+               }
+       }
+       return true;
+}
+
 static struct config_generic *
 get_index_free_record_if_any(struct config_generic *record)
 {
index c3ff2ecc38e3fccc71804431fd00a01d6154710b..1aa44d37ff1480f1d87a3b42c0c458a6774b1531 100644 (file)
@@ -86,6 +86,9 @@
 /* default string used to identify pgpool on syslog output */
 #define DEFAULT_SYSLOG_IDENT "pgpool"
 
+/* Pgpool node id file name */
+#define NODE_ID_FILE_NAME "pgpool_node_id"
+
 /* function return codes */
 #define GENERAL_ERROR          (-1)
 #define RETRY                          (-2)
index abcd2b3061d3323ac0e69846e3e67d8e8f35e117..524971b9a5a66571d0464d36891ff06940e0ddba 100644 (file)
@@ -130,18 +130,18 @@ typedef enum CHECK_TEMP_TABLE_OPTION
 /*
  * watchdog list
  */
-typedef struct WdRemoteNodeInfo
+typedef struct WdNodeInfo
 {
        char            hostname[WD_MAX_HOST_NAMELEN];  /* host name */
        int                     pgpool_port;    /* pgpool port */
        int                     wd_port;                /* watchdog port */
-}                      WdRemoteNodeInfo;
+}                      WdNodeInfo;
 
-typedef struct WdRemoteNodesConfig
+typedef struct WdNodesConfig
 {
        int                     num_wd;                 /* number of watchdogs */
-       WdRemoteNodeInfo wd_remote_node_info[MAX_WATCHDOG_NUM];
-}                      WdRemoteNodesConfig;
+       WdNodeInfo wd_node_info[MAX_WATCHDOG_NUM];
+}                      WdNodesConfig;
 
 
 typedef struct
@@ -151,8 +151,8 @@ typedef struct
        int                     dest_port;
 }                      WdHbIf;
 
-#define WD_INFO(wd_id) (pool_config->wd_remote_nodes.wd_remote_node_info[(wd_id)])
-#define WD_HB_IF(if_id) (pool_config->hb_if[(if_id)])
+#define WD_INFO(wd_id) (pool_config->wd_nodes.wd_node_info[(wd_id)])
+#define WD_HB_IF(if_id) (pool_config->hb_dest_if[(if_id)])
 
 /*
  * Per node health check parameters
@@ -543,11 +543,10 @@ typedef struct
                                                                                 * on new active pgpool. */
        char       *wd_de_escalation_command;   /* Executes this command when
                                                                                         * master pgpool goes down. */
-       char       *wd_hostname;        /* watchdog hostname */
-       int                     wd_port;                /* watchdog port */
        int                     wd_priority;    /* watchdog node priority, during leader
                                                                 * election */
-       WdRemoteNodesConfig wd_remote_nodes;    /* watchdog lists */
+       int                     pgpool_node_id; /* pgpool (watchdog) node id */
+       WdNodesConfig wd_nodes;         /* watchdog lists */
        char       *trusted_servers;    /* icmp reachable server list (A,B,C) */
        char       *delegate_IP;        /* delegate IP address */
        int                     wd_interval;    /* lifecheck interval (sec) */
@@ -570,14 +569,16 @@ typedef struct
                                                                                 * signal (sec) */
        int                     wd_heartbeat_deadtime;  /* Deadtime interval for heartbeat
                                                                                 * signal (sec) */
-       WdHbIf          hb_if[WD_MAX_IF_NUM];   /* interface devices */
-       int                     num_hb_if;              /* number of interface devices */
+       WdHbIf          hb_ifs[WD_MAX_IF_NUM];          /* heartbeat interfaces of all watchdog nodes */
+       WdHbIf          hb_dest_if[WD_MAX_IF_NUM];      /* heartbeat destination interfaces */
+       int                     num_hb_dest_if;                         /* number of interface devices */
        char      **wd_monitoring_interfaces_list;      /* network interface name list
                                                                                                 * to be monitored by watchdog */
 
 }                      POOL_CONFIG;
 
 extern POOL_CONFIG * pool_config;
+extern char *config_file_dir; /* directory path of config file pgpool.conf */
 
 typedef enum
 {
index cee44e050a50908d5644b4cb958ba09c2d1baf99..073920ee57ff694752b9c0dc4bff2eaf9f665647 100644 (file)
@@ -57,7 +57,7 @@
  */
 
 #define WD_MESSAGE_DATA_VERSION_MAJOR  "1"
-#define WD_MESSAGE_DATA_VERSION_MINOR  "1"
+#define WD_MESSAGE_DATA_VERSION_MINOR  "2"
 #define WD_MESSAGE_DATA_VERSION        WD_MESSAGE_DATA_VERSION_MAJOR "." WD_MESSAGE_DATA_VERSION_MINOR
 #define MAX_VERSION_STR_LEN            10
 
@@ -172,8 +172,7 @@ typedef struct WatchdogNode
        int                     pgpool_port;    /* pgpool port */
        int                     wd_priority;    /* watchdog priority */
        char            delegate_ip[WD_MAX_HOST_NAMELEN];       /* delegate IP */
-       int                     private_id;             /* ID assigned to this node This id is
-                                                                * consumed locally */
+       int                     pgpool_node_id;         /* pgpool node id specified in pgpool_node_id file */
        int                     standby_nodes_count;    /* number of standby nodes joined the
                                                                                 * cluster only applicable when this
                                                                                 * WatchdogNode is the
index 0fb36c0a4f6329d225c3250981813b4348352bf0..a771366757766495f59f3e7f0c072773e3a61929 100644 (file)
@@ -594,12 +594,25 @@ ping_path = '/bin'
 
 # - Watchdog communication Settings -
 
-wd_hostname = ''
-                                    # Host name or IP address of this watchdog
+hostname0 = ''
+                                    # Host name or IP address of pgpool node
+                                    # for watchdog connection
                                     # (change requires restart)
-wd_port = 9000
-                                    # port number for watchdog service
+wd_port0 = 9000
+                                    # Port number for watchdog service
                                     # (change requires restart)
+pgpool_port0 = 9999
+                                    # Port number for pgpool
+                                    # (change requires restart)
+
+#hostname1 = ''
+#wd_port1 = 9000
+#pgpool_port1 = 9999
+
+#wd_hostname2 = ''
+#wd_port2 = 9000
+#pgpool_port2 = 9999
+
 wd_priority = 1
                                     # priority of this watchdog in leader election
                                     # (change requires restart)
@@ -697,23 +710,13 @@ wd_interval = 10
 
 # -- heartbeat mode --
 
-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
+heartbeat_hostname0 = ''
+                                    # Host name or IP address used
                                     # 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.
+heartbeat_port0 = 9694
+                                    # Port number used for receiving/sending heartbeat signal
+                                    # Usually this is the same as heartbeat_portX.
                                     # (change requires restart)
 heartbeat_device0 = ''
                                     # Name of NIC device (such like 'eth0')
@@ -723,9 +726,19 @@ heartbeat_device0 = ''
                                     # and pgpool has root privilege.
                                     # (change requires restart)
 
-#heartbeat_destination1 = 'host0_ip2'
-#heartbeat_destination_port1 = 9694
+#heartbeat_hostname1 = ''
+#heartbeat_port1 = 9694
 #heartbeat_device1 = ''
+#heartbeat_hostname2 = ''
+#heartbeat_port2 = 9694
+#heartbeat_device2 = ''
+
+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)
 
 # -- query mode --
 
index c2a9680470a0140370d822c208e7526eb3dc74b2..36d04509b31c8ca8bcfab5253d0794c140aa58b5 100644 (file)
@@ -626,12 +626,25 @@ ping_path = '/bin'
 
 # - Watchdog communication Settings -
 
-wd_hostname = ''
-                                    # Host name or IP address of this watchdog
+hostname0 = ''
+                                    # Host name or IP address of pgpool node
+                                    # for watchdog connection
                                     # (change requires restart)
-wd_port = 9000
-                                    # port number for watchdog service
+wd_port0 = 9000
+                                    # Port number for watchdog service
                                     # (change requires restart)
+pgpool_port0 = 9999
+                                    # Port number for pgpool
+                                    # (change requires restart)
+
+#hostname1 = ''
+#wd_port1 = 9000
+#pgpool_port1 = 9999
+
+#wd_hostname2 = ''
+#wd_port2 = 9000
+#pgpool_port2 = 9999
+
 wd_priority = 1
                                     # priority of this watchdog in leader election
                                     # (change requires restart)
@@ -646,7 +659,6 @@ wd_ipc_socket_dir = '/tmp'
                                     # /var/run/postgresql
                                     # (change requires restart)
 
-
 # - Virtual IP control Setting -
 
 delegate_IP = ''
@@ -735,23 +747,13 @@ wd_interval = 10
 
 # -- heartbeat mode --
 
-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
+heartbeat_hostname0 = ''
+                                    # Host name or IP address used
                                     # 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.
+heartbeat_port0 = 9694
+                                    # Port number used for receiving/sending heartbeat signal
+                                    # Usually this is the same as heartbeat_portX.
                                     # (change requires restart)
 heartbeat_device0 = ''
                                     # Name of NIC device (such like 'eth0')
@@ -761,9 +763,19 @@ heartbeat_device0 = ''
                                     # and pgpool has root privilege.
                                     # (change requires restart)
 
-#heartbeat_destination1 = 'host0_ip2'
-#heartbeat_destination_port1 = 9694
+#heartbeat_hostname1 = ''
+#heartbeat_port1 = 9694
 #heartbeat_device1 = ''
+#heartbeat_hostname2 = ''
+#heartbeat_port2 = 9694
+#heartbeat_device2 = ''
+
+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)
 
 # -- query mode --
 
index 48c88f7078c3dffd0a1c6a3c79c07c754da389f3..dcae99d949aadcab83ae157e59bf4fd7d14a9f35 100644 (file)
@@ -636,12 +636,24 @@ ping_path = '/bin'
 
 # - Watchdog communication Settings -
 
-wd_hostname = ''
-                                    # Host name or IP address of this watchdog
+hostname0 = ''
+                                    # Host name or IP address of pgpool node
+                                    # for watchdog connection
                                     # (change requires restart)
-wd_port = 9000
-                                    # port number for watchdog service
+wd_port0 = 9000
+                                    # Port number for watchdog service
                                     # (change requires restart)
+pgpool_port0 = 9999
+                                    # Port number for pgpool
+                                    # (change requires restart)
+
+#hostname1 = ''
+#wd_port1 = 9000
+#pgpool_port1 = 9999
+
+#wd_hostname2 = ''
+#wd_port2 = 9000
+#pgpool_port2 = 9999
 
 wd_priority = 1
                                     # priority of this watchdog in leader election
@@ -748,23 +760,13 @@ wd_interval = 10
 
 # -- heartbeat mode --
 
-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
+heartbeat_hostname0 = ''
+                                    # Host name or IP address used
                                     # 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.
+heartbeat_port0 = 9694
+                                    # Port number used for receiving/sending heartbeat signal
+                                    # Usually this is the same as heartbeat_portX.
                                     # (change requires restart)
 heartbeat_device0 = ''
                                     # Name of NIC device (such like 'eth0')
@@ -774,9 +776,19 @@ heartbeat_device0 = ''
                                     # and pgpool has root privilege.
                                     # (change requires restart)
 
-#heartbeat_destination1 = 'host0_ip2'
-#heartbeat_destination_port1 = 9694
+#heartbeat_hostname1 = ''
+#heartbeat_port1 = 9694
 #heartbeat_device1 = ''
+#heartbeat_hostname2 = ''
+#heartbeat_port2 = 9694
+#heartbeat_device2 = ''
+
+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)
 
 # -- query mode --
 
index 8911c4150cf9d92f6c315d67d6b7004c29614223..3a78e6504c5c28276f278e5e04141d156a45fd35 100644 (file)
@@ -627,12 +627,25 @@ ping_path = '/bin'
 
 # - Watchdog communication Settings -
 
-wd_hostname = ''
-                                    # Host name or IP address of this watchdog
+hostname0 = ''
+                                    # Host name or IP address of pgpool node
+                                    # for watchdog connection
                                     # (change requires restart)
-wd_port = 9000
-                                    # port number for watchdog service
+wd_port0 = 9000
+                                    # Port number for watchdog service
                                     # (change requires restart)
+pgpool_port0 = 9999
+                                    # Port number for pgpool
+                                    # (change requires restart)
+
+#hostname1 = ''
+#wd_port1 = 9000
+#pgpool_port1 = 9999
+
+#wd_hostname2 = ''
+#wd_port2 = 9000
+#pgpool_port2 = 9999
+
 wd_priority = 1
                                     # priority of this watchdog in leader election
                                     # (change requires restart)
@@ -736,23 +749,13 @@ wd_interval = 10
 
 # -- heartbeat mode --
 
-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
+heartbeat_hostname0 = ''
+                                    # Host name or IP address used
                                     # 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.
+heartbeat_port0 = 9694
+                                    # Port number used for receiving/sending heartbeat signal
+                                    # Usually this is the same as heartbeat_portX.
                                     # (change requires restart)
 heartbeat_device0 = ''
                                     # Name of NIC device (such like 'eth0')
@@ -762,9 +765,19 @@ heartbeat_device0 = ''
                                     # and pgpool has root privilege.
                                     # (change requires restart)
 
-#heartbeat_destination1 = 'host0_ip2'
-#heartbeat_destination_port1 = 9694
+#heartbeat_hostname1 = ''
+#heartbeat_port1 = 9694
 #heartbeat_device1 = ''
+#heartbeat_hostname2 = ''
+#heartbeat_port2 = 9694
+#heartbeat_device2 = ''
+
+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)
 
 # -- query mode --
 
index 8e39c27b00b81e4de98cd250544481a9d3369d11..d55cc32b463ff8286ba05493962af84bf68cf2cf 100644 (file)
@@ -636,12 +636,24 @@ ping_path = '/bin'
 
 # - Watchdog communication Settings -
 
-wd_hostname = ''
-                                    # Host name or IP address of this watchdog
+hostname0 = ''
+                                    # Host name or IP address of pgpool node
+                                    # for watchdog connection
                                     # (change requires restart)
-wd_port = 9000
-                                    # port number for watchdog service
+wd_port0 = 9000
+                                    # Port number for watchdog service
                                     # (change requires restart)
+pgpool_port0 = 9999
+                                    # Port number for pgpool
+                                    # (change requires restart)
+
+#hostname1 = ''
+#wd_port1 = 9000
+#pgpool_port1 = 9999
+
+#wd_hostname2 = ''
+#wd_port2 = 9000
+#pgpool_port2 = 9999
 
 wd_priority = 1
                                     # priority of this watchdog in leader election
@@ -748,23 +760,13 @@ wd_interval = 10
 
 # -- heartbeat mode --
 
-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
+heartbeat_hostname0 = ''
+                                    # Host name or IP address used
                                     # 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.
+heartbeat_port0 = 9694
+                                    # Port number used for receiving/sending heartbeat signal
+                                    # Usually this is the same as heartbeat_portX.
                                     # (change requires restart)
 heartbeat_device0 = ''
                                     # Name of NIC device (such like 'eth0')
@@ -774,9 +776,19 @@ heartbeat_device0 = ''
                                     # and pgpool has root privilege.
                                     # (change requires restart)
 
-#heartbeat_destination1 = 'host0_ip2'
-#heartbeat_destination_port1 = 9694
+#heartbeat_hostname1 = ''
+#heartbeat_port1 = 9694
 #heartbeat_device1 = ''
+#heartbeat_hostname2 = ''
+#heartbeat_port2 = 9694
+#heartbeat_device2 = ''
+
+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)
 
 # -- query mode --
 
@@ -798,22 +810,6 @@ wd_lifecheck_password = ''
                                     # Password in pool_passwd file before using the empty password
                                     # (change requires restart)
 
-# - Other pgpool Connection Settings -
-
-#other_pgpool_hostname0 = 'host0'
-                                    # Host name or IP address to connect to for other pgpool 0
-                                    # (change requires restart)
-#other_pgpool_port0 = 5432
-                                    # Port number for other pgpool 0
-                                    # (change requires restart)
-#other_wd_port0 = 9000
-                                    # Port number for other watchdog 0
-                                    # (change requires restart)
-#other_pgpool_hostname1 = 'host1'
-#other_pgpool_port1 = 5432
-#other_wd_port1 = 9000
-
-
 #------------------------------------------------------------------------------
 # OTHERS
 #------------------------------------------------------------------------------
index b963b282049bdb929922d998d3d722c00946b218..8f59d03b587c4da48eeb603bd574693b66e09802 100644 (file)
@@ -628,12 +628,25 @@ ping_path = '/bin'
 
 # - Watchdog communication Settings -
 
-wd_hostname = ''
-                                    # Host name or IP address of this watchdog
+hostname0 = ''
+                                    # Host name or IP address of pgpool node
+                                    # for watchdog connection
                                     # (change requires restart)
-wd_port = 9000
-                                    # port number for watchdog service
+wd_port0 = 9000
+                                    # Port number for watchdog service
                                     # (change requires restart)
+pgpool_port0 = 9999
+                                    # Port number for pgpool
+                                    # (change requires restart)
+
+#hostname1 = ''
+#wd_port1 = 9000
+#pgpool_port1 = 9999
+
+#wd_hostname2 = ''
+#wd_port2 = 9000
+#pgpool_port2 = 9999
+
 wd_priority = 1
                                     # priority of this watchdog in leader election
                                     # (change requires restart)
@@ -737,23 +750,13 @@ wd_interval = 10
 
 # -- heartbeat mode --
 
-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
+heartbeat_hostname0 = ''
+                                    # Host name or IP address used
                                     # 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.
+heartbeat_port0 = 9694
+                                    # Port number used for receiving/sending heartbeat signal
+                                    # Usually this is the same as heartbeat_portX.
                                     # (change requires restart)
 heartbeat_device0 = ''
                                     # Name of NIC device (such like 'eth0')
@@ -763,9 +766,19 @@ heartbeat_device0 = ''
                                     # and pgpool has root privilege.
                                     # (change requires restart)
 
-#heartbeat_destination1 = 'host0_ip2'
-#heartbeat_destination_port1 = 9694
+#heartbeat_hostname1 = ''
+#heartbeat_port1 = 9694
 #heartbeat_device1 = ''
+#heartbeat_hostname2 = ''
+#heartbeat_port2 = 9694
+#heartbeat_device2 = ''
+
+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)
 
 # -- query mode --
 
@@ -787,22 +800,6 @@ wd_lifecheck_password = ''
                                     # Password in pool_passwd file before using the empty password
                                     # (change requires restart)
 
-# - Other pgpool Connection Settings -
-
-#other_pgpool_hostname0 = 'host0'
-                                    # Host name or IP address to connect to for other pgpool 0
-                                    # (change requires restart)
-#other_pgpool_port0 = 5432
-                                    # Port number for other pgpool 0
-                                    # (change requires restart)
-#other_wd_port0 = 9000
-                                    # Port number for other watchdog 0
-                                    # (change requires restart)
-#other_pgpool_hostname1 = 'host1'
-#other_pgpool_port1 = 5432
-#other_wd_port1 = 9000
-
-
 #------------------------------------------------------------------------------
 # OTHERS
 #------------------------------------------------------------------------------
index f6bb6823ce0ad7b65251741bb74dff7e42a16e57..a1d1464a4c087ca9d7268ff984f40a9aafb92161 100644 (file)
@@ -2,15 +2,17 @@
 use_watchdog = on
 wd_interval = 1
 wd_priority = 2
-wd_hostname = 'localhost'
-wd_port = 21004
-wd_heartbeat_port = 21005
 
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21105
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port0 = 11100
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11100
-other_wd_port0 = 21104
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port01 = 21105
 
 enable_consensus_with_half_votes = on
index 5da16952b134d08a7a43b33a06777c8ec59ac7d0..65c18dac8200eb87e4632754c1634e70c566b591 100644 (file)
@@ -4,14 +4,17 @@ pcp_port = 11105
 use_watchdog = on
 wd_interval = 1
 wd_priority = 1
-wd_hostname = 'localhost'
-wd_port = 21104
-wd_heartbeat_port = 21105
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21005
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11000
-other_wd_port0 = 21004
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port0 = 11100
+
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port01 = 21105
 
 enable_consensus_with_half_votes = on
index b9489b546e94455405853773f978560de9ebb308..599775dd98826d7d8e749c955b91238f9300f147 100755 (executable)
@@ -27,6 +27,7 @@ cp -r etc ../$STANDBY_DIR/
 
 source ./bashrc.ports
 cat ../master.conf >> etc/pgpool.conf
+echo 0 > etc/pgpool_node_id
 
 ./startall
 wait_for_pgpool_startup
@@ -43,6 +44,7 @@ echo -n "creating standby pgpool..."
 cat standby.conf >> $STANDBY_DIR/etc/pgpool.conf
 # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf
 echo "pid_file_name = '$PWD/pgpool2.pid'" >> $STANDBY_DIR/etc/pgpool.conf
+echo 1 > $STANDBY_DIR/etc/pgpool_node_id
 # start the stnadby pgpool-II by hand
 $PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY_DIR/etc/pgpool.conf -F $STANDBY_DIR/etc/pcp.conf -a $STANDBY_DIR/etc/pool_hba.conf > $STANDBY_DIR/log/pgpool.log 2>&1 &
 
index 289ca5afad8a76b5deb7cd7ef6a296418cc07ee5..a7d78c4f658e7d30e4ef8bfb258c469bfeff0e02 100644 (file)
@@ -2,19 +2,20 @@
 use_watchdog = on
 wd_interval = 1
 wd_priority = 5
-wd_hostname = 'localhost'
-wd_port = 21004
-wd_heartbeat_port = 21005
 
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21105
-heartbeat_destination1 = 'localhost'
-heartbeat_destination_port1 = 21205
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port1 = 11100
+hostname2 = 'localhost'
+wd_port2 = 21204
+pgpool_port2 = 11200
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11100
-other_wd_port0 = 21104
-
-other_pgpool_hostname1 = 'localhost'
-other_pgpool_port1 = 11200
-other_wd_port1 = 21204
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port1 = 21105
+heartbeat_hostname2 = 'localhost'
+heartbeat_port2 = 21205
index 120bcb0f8684980a9a4dd724b81807254e78619d..012307ba66ebaf4e2ad37dedee5a58601f9b229f 100644 (file)
@@ -4,19 +4,20 @@ pcp_port = 11105
 use_watchdog = on
 wd_interval = 1
 wd_priority = 3
-wd_hostname = 'localhost'
-wd_port = 21104
-wd_heartbeat_port = 21105
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21005
-heartbeat_destination1 = 'localhost'
-heartbeat_destination_port1 = 21205
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11000
-other_wd_port0 = 21004
-
-other_pgpool_hostname1 = 'localhost'
-other_pgpool_port1 = 11200
-other_wd_port1 = 21204
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port1 = 11100
+hostname2 = 'localhost'
+wd_port2 = 21204
+pgpool_port2 = 11200
 
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port1 = 21105
+heartbeat_hostname2 = 'localhost'
+heartbeat_port2 = 21205
index d5da7ffda8fb16e3e1cafdca65e4770f5c25a1df..90254786c1c70aa974061510ebb44bc1c171a7b1 100644 (file)
@@ -4,19 +4,20 @@ pcp_port = 11205
 use_watchdog = on
 wd_interval = 1
 wd_priority = 1
-wd_hostname = 'localhost'
-wd_port = 21204
-wd_heartbeat_port = 21205
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21005
-heartbeat_destination1 = 'localhost'
-heartbeat_destination_port1 = 21105
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11000
-other_wd_port0 = 21004
-
-other_pgpool_hostname1 = 'localhost'
-other_pgpool_port1 = 11100
-other_wd_port1 = 21104
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port1 = 11100
+hostname2 = 'localhost'
+wd_port2 = 21204
+pgpool_port2 = 11200
 
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port1 = 21105
+heartbeat_hostname2 = 'localhost'
+heartbeat_port2 = 21205
index 431d8887bb23d87e12cfcdecfda32872770d9049..74843aa455da21b247fdc0a702d10b39f1445d45 100755 (executable)
@@ -40,6 +40,7 @@ cp -r etc ../$STANDBY2_DIR/
 
 source ./bashrc.ports
 cat ../master.conf >> etc/pgpool.conf
+echo 0 > etc/pgpool_node_id
 
 ./startall
 wait_for_pgpool_startup
@@ -57,6 +58,7 @@ cat standby.conf >> $STANDBY_DIR/etc/pgpool.conf
 # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf
 echo "pid_file_name = '$PWD/pgpool2.pid'" >> $STANDBY_DIR/etc/pgpool.conf
 echo "logdir = $STANDBY_DIR/log" >> $STANDBY_DIR/etc/pgpool.conf
+echo 1 > $STANDBY_DIR/etc/pgpool_node_id
 # start the stnadby pgpool-II by hand
 $PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY_DIR/etc/pgpool.conf -F $STANDBY_DIR/etc/pcp.conf -a $STANDBY_DIR/etc/pool_hba.conf > $STANDBY_DIR/log/pgpool.log 2>&1 &
 
@@ -68,6 +70,7 @@ cat standby2.conf >> $STANDBY2_DIR/etc/pgpool.conf
 # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf
 echo "pid_file_name = '$PWD/pgpool3.pid'" >> $STANDBY2_DIR/etc/pgpool.conf
 echo "logdir = $STANDBY2_DIR/log" >> $STANDBY2_DIR/etc/pgpool.conf
+echo 2 > $STANDBY2_DIR/etc/pgpool_node_id
 # start the stnadby pgpool-II by hand
 $PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY2_DIR/etc/pgpool.conf -F $STANDBY2_DIR/etc/pcp.conf -a $STANDBY2_DIR/etc/pool_hba.conf > $STANDBY2_DIR/log/pgpool.log 2>&1 &
 
index 0b83c719226808e70ef779d91e7b9bbe6b2fe3d7..37efa3d69d69a845d61a751478758360d43d3454 100644 (file)
@@ -6,19 +6,20 @@ failover_require_consensus = false
 allow_multiple_failover_requests_from_node = false
 wd_interval = 1
 wd_priority = 5
-wd_hostname = 'localhost'
-wd_port = 21004
-wd_heartbeat_port = 21005
 
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21105
-heartbeat_destination1 = 'localhost'
-heartbeat_destination_port1 = 21205
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port1 = 11100
+hostname2 = 'localhost'
+wd_port2 = 21204
+pgpool_port2 = 11200
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11100
-other_wd_port0 = 21104
-
-other_pgpool_hostname1 = 'localhost'
-other_pgpool_port1 = 11200
-other_wd_port1 = 21204
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port1 = 21105
+heartbeat_hostname2 = 'localhost'
+heartbeat_port2 = 21205
index e03412d852aed96c027ab8eacbee8a4623a59216..72b5ca0d6b4a1086b4f93eb93023626a4513f563 100644 (file)
@@ -8,19 +8,20 @@ failover_require_consensus = false
 allow_multiple_failover_requests_from_node = false
 wd_interval = 1
 wd_priority = 3
-wd_hostname = 'localhost'
-wd_port = 21104
-wd_heartbeat_port = 21105
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21005
-heartbeat_destination1 = 'localhost'
-heartbeat_destination_port1 = 21205
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11000
-other_wd_port0 = 21004
-
-other_pgpool_hostname1 = 'localhost'
-other_pgpool_port1 = 11200
-other_wd_port1 = 21204
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port1 = 11100
+hostname2 = 'localhost'
+wd_port2 = 21204
+pgpool_port2 = 11200
 
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port1 = 21105
+heartbeat_hostname2 = 'localhost'
+heartbeat_port2 = 21205
index f28bd9da330b05a5c765b4a360fa2c9e5b1ebc2a..ae9a05381672c823c7e45713b8a5c4bab5ee163d 100644 (file)
@@ -8,19 +8,20 @@ failover_require_consensus = false
 allow_multiple_failover_requests_from_node = false
 wd_interval = 1
 wd_priority = 1
-wd_hostname = 'localhost'
-wd_port = 21204
-wd_heartbeat_port = 21205
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21005
-heartbeat_destination1 = 'localhost'
-heartbeat_destination_port1 = 21105
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11000
-other_wd_port0 = 21004
-
-other_pgpool_hostname1 = 'localhost'
-other_pgpool_port1 = 11100
-other_wd_port1 = 21104
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port1 = 11100
+hostname2 = 'localhost'
+wd_port2 = 21204
+pgpool_port2 = 11200
 
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port1 = 21105
+heartbeat_hostname2 = 'localhost'
+heartbeat_port2 = 21205
index 6fa062093ef8c74c25afefd862bdca0774be7f67..819f5a28a9340b525235c3ebc0fc8a3f6d991775 100755 (executable)
@@ -42,6 +42,7 @@ cp -r etc ../$STANDBY2_DIR/
 
 source ./bashrc.ports
 cat ../master.conf >> etc/pgpool.conf
+echo 0 > etc/pgpool_node_id
 
 ./startall
 wait_for_pgpool_startup
@@ -59,6 +60,7 @@ cat standby.conf >> $STANDBY_DIR/etc/pgpool.conf
 # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf
 echo "pid_file_name = '$PWD/pgpool2.pid'" >> $STANDBY_DIR/etc/pgpool.conf
 echo "logdir = $STANDBY_DIR/log" >> $STANDBY_DIR/etc/pgpool.conf
+echo 1 > $STANDBY_DIR/etc/pgpool_node_id
 # start the stnadby pgpool-II by hand
 #$PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY_DIR/etc/pgpool.conf -F $STANDBY_DIR/etc/pcp.conf -a $STANDBY_DIR/etc/pool_hba.conf > $STANDBY_DIR/log/pgpool.log 2>&1 &
 
@@ -70,6 +72,7 @@ cat standby2.conf >> $STANDBY2_DIR/etc/pgpool.conf
 # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf
 echo "pid_file_name = '$PWD/pgpool3.pid'" >> $STANDBY2_DIR/etc/pgpool.conf
 echo "logdir = $STANDBY2_DIR/log" >> $STANDBY2_DIR/etc/pgpool.conf
+echo 2 > $STANDBY2_DIR/etc/pgpool_node_id
 # start the stnadby pgpool-II by hand
 #$PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY2_DIR/etc/pgpool.conf -F $STANDBY2_DIR/etc/pcp.conf -a $STANDBY2_DIR/etc/pool_hba.conf > $STANDBY2_DIR/log/pgpool.log 2>&1 &
 
index 58e6f4badf0bd28c8c16bfd12ec9ee4bce0bd5ef..d8af08b49ea592f492d601e673b4ba035449958b 100644 (file)
@@ -6,19 +6,20 @@ failover_require_consensus = true
 allow_multiple_failover_requests_from_node = false
 wd_interval = 1
 wd_priority = 5
-wd_hostname = 'localhost'
-wd_port = 21004
-wd_heartbeat_port = 21005
 
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21105
-heartbeat_destination1 = 'localhost'
-heartbeat_destination_port1 = 21205
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port1 = 11100
+hostname2 = 'localhost'
+wd_port2 = 21204
+pgpool_port2 = 11200
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11100
-other_wd_port0 = 21104
-
-other_pgpool_hostname1 = 'localhost'
-other_pgpool_port1 = 11200
-other_wd_port1 = 21204
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port1 = 21105
+heartbeat_hostname2 = 'localhost'
+heartbeat_port2 = 21205
index 710cbb7ae555e9dfd29cc9efcfea988ac9a26674..8c8a14d35bf6b7ccec51b7735630d659a3d5fe71 100644 (file)
@@ -8,19 +8,20 @@ failover_require_consensus = true
 allow_multiple_failover_requests_from_node = false
 wd_interval = 1
 wd_priority = 3
-wd_hostname = 'localhost'
-wd_port = 21104
-wd_heartbeat_port = 21105
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21005
-heartbeat_destination1 = 'localhost'
-heartbeat_destination_port1 = 21205
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11000
-other_wd_port0 = 21004
-
-other_pgpool_hostname1 = 'localhost'
-other_pgpool_port1 = 11200
-other_wd_port1 = 21204
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port1 = 11100
+hostname2 = 'localhost'
+wd_port2 = 21204
+pgpool_port2 = 11200
 
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port1 = 21105
+heartbeat_hostname2 = 'localhost'
+heartbeat_port2 = 21205
index f447141331eac50422cc36c18e2c37d42b52ec31..f094054b715df05fdb0e6bedd1955bb43cd892da 100644 (file)
@@ -8,19 +8,20 @@ failover_require_consensus = true
 allow_multiple_failover_requests_from_node = false
 wd_interval = 1
 wd_priority = 1
-wd_hostname = 'localhost'
-wd_port = 21204
-wd_heartbeat_port = 21205
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21005
-heartbeat_destination1 = 'localhost'
-heartbeat_destination_port1 = 21105
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11000
-other_wd_port0 = 21004
-
-other_pgpool_hostname1 = 'localhost'
-other_pgpool_port1 = 11100
-other_wd_port1 = 21104
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port1 = 11100
+hostname2 = 'localhost'
+wd_port2 = 21204
+pgpool_port2 = 11200
 
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port1 = 21105
+heartbeat_hostname2 = 'localhost'
+heartbeat_port2 = 21205
index f4249839fcb416d8c59e49f22c426f486fa701c2..f0c77b501a668eb4b7788fee5f7ebe78479619f4 100755 (executable)
@@ -42,6 +42,7 @@ cp -r etc ../$STANDBY2_DIR/
 
 source ./bashrc.ports
 cat ../master.conf >> etc/pgpool.conf
+echo 0 > etc/pgpool_node_id
 
 ./startall
 wait_for_pgpool_startup
@@ -59,6 +60,7 @@ cat standby.conf >> $STANDBY_DIR/etc/pgpool.conf
 # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf
 echo "pid_file_name = '$PWD/pgpool2.pid'" >> $STANDBY_DIR/etc/pgpool.conf
 echo "logdir = $STANDBY_DIR/log" >> $STANDBY_DIR/etc/pgpool.conf
+echo 1 > $STANDBY_DIR/etc/pgpool_node_id
 # start the stnadby pgpool-II by hand
 $PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY_DIR/etc/pgpool.conf -F $STANDBY_DIR/etc/pcp.conf -a $STANDBY_DIR/etc/pool_hba.conf > $STANDBY_DIR/log/pgpool.log 2>&1 &
 
@@ -69,6 +71,7 @@ cat standby2.conf >> $STANDBY2_DIR/etc/pgpool.conf
 # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf
 echo "pid_file_name = '$PWD/pgpool3.pid'" >> $STANDBY2_DIR/etc/pgpool.conf
 echo "logdir = $STANDBY2_DIR/log" >> $STANDBY2_DIR/etc/pgpool.conf
+echo 2 > $STANDBY2_DIR/etc/pgpool_node_id
 # start the stnadby pgpool-II by hand
 $PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY2_DIR/etc/pgpool.conf -F $STANDBY2_DIR/etc/pcp.conf -a $STANDBY2_DIR/etc/pool_hba.conf > $STANDBY2_DIR/log/pgpool.log 2>&1 &
 
index 58e6f4badf0bd28c8c16bfd12ec9ee4bce0bd5ef..d8af08b49ea592f492d601e673b4ba035449958b 100644 (file)
@@ -6,19 +6,20 @@ failover_require_consensus = true
 allow_multiple_failover_requests_from_node = false
 wd_interval = 1
 wd_priority = 5
-wd_hostname = 'localhost'
-wd_port = 21004
-wd_heartbeat_port = 21005
 
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21105
-heartbeat_destination1 = 'localhost'
-heartbeat_destination_port1 = 21205
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port1 = 11100
+hostname2 = 'localhost'
+wd_port2 = 21204
+pgpool_port2 = 11200
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11100
-other_wd_port0 = 21104
-
-other_pgpool_hostname1 = 'localhost'
-other_pgpool_port1 = 11200
-other_wd_port1 = 21204
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port1 = 21105
+heartbeat_hostname2 = 'localhost'
+heartbeat_port2 = 21205
index 7898f33b11aab5a44e20b433949ca87a1ff3f094..1ead1540bca9ab8eedf8e7cf8b9012b8fe6db54b 100755 (executable)
@@ -34,6 +34,7 @@ echo "master setup done."
 
 source ./bashrc.ports
 cat ../master.conf >> etc/pgpool.conf
+echo 0 > etc/pgpool_node_id
 
 ./startall
 wait_for_pgpool_startup
index 58e6f4badf0bd28c8c16bfd12ec9ee4bce0bd5ef..d8af08b49ea592f492d601e673b4ba035449958b 100644 (file)
@@ -6,19 +6,20 @@ failover_require_consensus = true
 allow_multiple_failover_requests_from_node = false
 wd_interval = 1
 wd_priority = 5
-wd_hostname = 'localhost'
-wd_port = 21004
-wd_heartbeat_port = 21005
 
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21105
-heartbeat_destination1 = 'localhost'
-heartbeat_destination_port1 = 21205
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port1 = 11100
+hostname2 = 'localhost'
+wd_port2 = 21204
+pgpool_port2 = 11200
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11100
-other_wd_port0 = 21104
-
-other_pgpool_hostname1 = 'localhost'
-other_pgpool_port1 = 11200
-other_wd_port1 = 21204
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port1 = 21105
+heartbeat_hostname2 = 'localhost'
+heartbeat_port2 = 21205
index 710cbb7ae555e9dfd29cc9efcfea988ac9a26674..8c8a14d35bf6b7ccec51b7735630d659a3d5fe71 100644 (file)
@@ -8,19 +8,20 @@ failover_require_consensus = true
 allow_multiple_failover_requests_from_node = false
 wd_interval = 1
 wd_priority = 3
-wd_hostname = 'localhost'
-wd_port = 21104
-wd_heartbeat_port = 21105
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21005
-heartbeat_destination1 = 'localhost'
-heartbeat_destination_port1 = 21205
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11000
-other_wd_port0 = 21004
-
-other_pgpool_hostname1 = 'localhost'
-other_pgpool_port1 = 11200
-other_wd_port1 = 21204
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port1 = 11100
+hostname2 = 'localhost'
+wd_port2 = 21204
+pgpool_port2 = 11200
 
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port1 = 21105
+heartbeat_hostname2 = 'localhost'
+heartbeat_port2 = 21205
index f447141331eac50422cc36c18e2c37d42b52ec31..f094054b715df05fdb0e6bedd1955bb43cd892da 100644 (file)
@@ -8,19 +8,20 @@ failover_require_consensus = true
 allow_multiple_failover_requests_from_node = false
 wd_interval = 1
 wd_priority = 1
-wd_hostname = 'localhost'
-wd_port = 21204
-wd_heartbeat_port = 21205
-heartbeat_destination0 = 'localhost'
-heartbeat_destination_port0 = 21005
-heartbeat_destination1 = 'localhost'
-heartbeat_destination_port1 = 21105
 
-other_pgpool_hostname0 = 'localhost'
-other_pgpool_port0 = 11000
-other_wd_port0 = 21004
-
-other_pgpool_hostname1 = 'localhost'
-other_pgpool_port1 = 11100
-other_wd_port1 = 21104
+hostname0 = 'localhost'
+wd_port0 = 21004
+pgpool_port0 = 11000
+hostname1 = 'localhost'
+wd_port1 = 21104
+pgpool_port1 = 11100
+hostname2 = 'localhost'
+wd_port2 = 21204
+pgpool_port2 = 11200
 
+heartbeat_hostname0 = 'localhost'
+heartbeat_port0 = 21005
+heartbeat_hostname1 = 'localhost'
+heartbeat_port1 = 21105
+heartbeat_hostname2 = 'localhost'
+heartbeat_port2 = 21205
index 4aa2f681f26634d08508ae69383a719241847354..f253d3380606e56e0d600072b2ba609f77c55287 100755 (executable)
@@ -42,6 +42,7 @@ cp -r etc ../$STANDBY2_DIR/
 
 source ./bashrc.ports
 cat ../master.conf >> etc/pgpool.conf
+echo 0 > etc/pgpool_node_id
 
 ./startall
 wait_for_pgpool_startup
@@ -59,6 +60,7 @@ cat standby.conf >> $STANDBY_DIR/etc/pgpool.conf
 # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf
 echo "pid_file_name = '$PWD/pgpool2.pid'" >> $STANDBY_DIR/etc/pgpool.conf
 echo "logdir = $STANDBY_DIR/log" >> $STANDBY_DIR/etc/pgpool.conf
+echo 1 > $STANDBY_DIR/etc/pgpool_node_id
 # start the stnadby pgpool-II by hand
 $PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY_DIR/etc/pgpool.conf -F $STANDBY_DIR/etc/pcp.conf -a $STANDBY_DIR/etc/pool_hba.conf > $STANDBY_DIR/log/pgpool.log 2>&1 &
 
@@ -69,6 +71,7 @@ cat standby2.conf >> $STANDBY2_DIR/etc/pgpool.conf
 # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf
 echo "pid_file_name = '$PWD/pgpool3.pid'" >> $STANDBY2_DIR/etc/pgpool.conf
 echo "logdir = $STANDBY2_DIR/log" >> $STANDBY2_DIR/etc/pgpool.conf
+echo 2 > $STANDBY2_DIR/etc/pgpool_node_id
 # start the stnadby pgpool-II by hand
 $PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY2_DIR/etc/pgpool.conf -F $STANDBY2_DIR/etc/pcp.conf -a $STANDBY2_DIR/etc/pool_hba.conf > $STANDBY2_DIR/log/pgpool.log 2>&1 &
 
index 1bbbbeb549b70adca0562bdc0bb99def04237266..6a14b8e82c40645fdd51a93fced752ddc24ffc26 100755 (executable)
@@ -171,35 +171,30 @@ function set_watchdog_params {
     priority=`expr $num_pgpool - $id`
     n=0
     conf=etc/pgpool.conf
-    wd_port=`expr $base_port + \( $id \* $num_ports_per_node \) + 2`
-    wd_heartbeat_port=`expr $wd_port + 1`
+       node_id_file=etc/pgpool_node_id
 
     cat >> $conf <<EOF
 use_watchdog = on
 wd_interval = 1
 wd_priority = $priority
-wd_hostname = 'localhost'
-wd_port = $wd_port
-wd_heartbeat_port = $wd_heartbeat_port
 EOF
 
-    suf=0
     while [ $n -lt $num_pgpool ]
     do
-       if [ $id != $n ];then
-           echo "heartbeat_destination$suf = 'localhost'" >> $conf
-           pgpool_port=`expr $base_port + \( $n \* $num_ports_per_node \)`
-           pcp_port=`expr $pgpool_port + 1`
-           wd_port=`expr $pcp_port + 1`
-           wd_heartbeat_port=`expr $wd_port + 1`
-           echo "heartbeat_destination_port$suf = $wd_heartbeat_port" >> $conf
-           echo "other_pgpool_hostname$suf = 'localhost'" >> $conf
-           echo "other_pgpool_port$suf = $pgpool_port" >> $conf
-           echo "other_wd_port$suf = $wd_port" >> $conf
-           suf=`expr $suf + 1`
-       fi
-       n=`expr $n + 1`
+               pgpool_port=`expr $base_port + \( $n \* $num_ports_per_node \)`
+               pcp_port=`expr $pgpool_port + 1`
+               wd_port=`expr $pcp_port + 1`
+
+               wd_heartbeat_port=`expr $wd_port + 1`
+               echo "hostname$n = 'localhost'" >> $conf
+               echo "pgpool_port$n = $pgpool_port" >> $conf
+               echo "wd_port$n = $wd_port" >> $conf
+               echo "heartbeat_hostname$n = 'localhost'" >> $conf
+               echo "heartbeat_port$n = $wd_heartbeat_port" >> $conf
+               n=`expr $n + 1`
     done
+
+       echo "$id" >> $node_id_file
 }
 
 #################################################################################
index ec0d9ba26e50bb9569243aee88adb9eed1da1c1d..1bf535a2ab29207c7433082042b22c62b9e29619 100644 (file)
@@ -9,7 +9,8 @@ nodist_pg_md5_SOURCES = md5.c \
                regex_array.c \
                pool_config_variables.c \
                pool_config.c \
-               fe_memutils.c
+               fe_memutils.c \
+               pool_path.c
 
 DEFS = @DEFS@ \
     -DDEFAULT_CONFIGDIR=\"$(sysconfdir)\" -DPOOL_TOOLS
@@ -20,6 +21,8 @@ md5.h: ../../../src/include/auth/md5.h
        rm -f $@ && ln -s $< .
 pool_passwd.c: ../../../src/auth/pool_passwd.c
        rm -f $@ && ln -s $< .
+pool_path.c: ../../../src/utils/pool_path.c
+       rm -f $@ && ln -s $< .
 strlcpy.c: ../../../src/utils/strlcpy.c
        rm -f $@ && ln -s $< .
 regex_array.c: ../../../src/utils/regex_array.c
index ebd150003dcc76482826597f86942cbd88141e7e..0fbb1b8023f0a9a1e796263c44637d1923bafbfd 100644 (file)
@@ -103,7 +103,7 @@ dist_pg_md5_OBJECTS = pg_md5.$(OBJEXT) ../fe_port.$(OBJEXT)
 nodist_pg_md5_OBJECTS = md5.$(OBJEXT) pool_passwd.$(OBJEXT) \
        strlcpy.$(OBJEXT) regex_array.$(OBJEXT) \
        pool_config_variables.$(OBJEXT) pool_config.$(OBJEXT) \
-       fe_memutils.$(OBJEXT)
+       fe_memutils.$(OBJEXT) pool_path.$(OBJEXT)
 pg_md5_OBJECTS = $(dist_pg_md5_OBJECTS) $(nodist_pg_md5_OBJECTS)
 pg_md5_LDADD = $(LDADD)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -319,7 +319,8 @@ nodist_pg_md5_SOURCES = md5.c \
                regex_array.c \
                pool_config_variables.c \
                pool_config.c \
-               fe_memutils.c
+               fe_memutils.c \
+               pool_path.c
 
 all: all-am
 
@@ -648,6 +649,8 @@ md5.h: ../../../src/include/auth/md5.h
        rm -f $@ && ln -s $< .
 pool_passwd.c: ../../../src/auth/pool_passwd.c
        rm -f $@ && ln -s $< .
+pool_path.c: ../../../src/utils/pool_path.c
+       rm -f $@ && ln -s $< .
 strlcpy.c: ../../../src/utils/strlcpy.c
        rm -f $@ && ln -s $< .
 regex_array.c: ../../../src/utils/regex_array.c
index e54df85845dea0b202abdfd52ac95725e0bdefbf..c405e8173593b090de5eea4f528ee536d1b20e5c 100644 (file)
@@ -14,6 +14,7 @@ nodist_wd_cli_SOURCES = ssl_utils.c \
                json.c \
                pool_config_variables.c \
                pool_config.c \
+               pool_path.c \
                fe_memutils.c \
                stringinfo.h \
                stringinfo.c \
@@ -64,6 +65,8 @@ pool_config_variables.c: ../../../src/config/pool_config_variables.c
        rm -f $@ && ln -s $< .
 pool_config.c: ../../../src/config/pool_config.c
        rm -f $@ && ln -s $< .
+pool_path.c: ../../../src/utils/pool_path.c
+       rm -f $@ && ln -s $< .
 fe_memutils.c: ../../../src/tools/fe_memutils.c
        rm -f $@ && ln -s $< .
 
index 9106352560ca811d21ba679eb5444d655e45f11d..9754d2c4b308462873877dfa8f5ebc9bf47c8746 100644 (file)
@@ -104,9 +104,9 @@ dist_wd_cli_OBJECTS = wd_cli.$(OBJEXT) ../fe_port.$(OBJEXT)
 nodist_wd_cli_OBJECTS = ssl_utils.$(OBJEXT) wd_ipc_conn.$(OBJEXT) \
        wd_commands.$(OBJEXT) json_writer.$(OBJEXT) json.$(OBJEXT) \
        pool_config_variables.$(OBJEXT) pool_config.$(OBJEXT) \
-       fe_memutils.$(OBJEXT) stringinfo.$(OBJEXT) strlcpy.$(OBJEXT) \
-       socket_stream.$(OBJEXT) regex_array.$(OBJEXT) \
-       psprintf.$(OBJEXT) md5.$(OBJEXT)
+       pool_path.$(OBJEXT) fe_memutils.$(OBJEXT) stringinfo.$(OBJEXT) \
+       strlcpy.$(OBJEXT) socket_stream.$(OBJEXT) \
+       regex_array.$(OBJEXT) psprintf.$(OBJEXT) md5.$(OBJEXT)
 wd_cli_OBJECTS = $(dist_wd_cli_OBJECTS) $(nodist_wd_cli_OBJECTS)
 wd_cli_LDADD = $(LDADD)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -353,6 +353,7 @@ nodist_wd_cli_SOURCES = ssl_utils.c \
                json.c \
                pool_config_variables.c \
                pool_config.c \
+               pool_path.c \
                fe_memutils.c \
                stringinfo.h \
                stringinfo.c \
@@ -757,6 +758,8 @@ pool_config_variables.c: ../../../src/config/pool_config_variables.c
        rm -f $@ && ln -s $< .
 pool_config.c: ../../../src/config/pool_config.c
        rm -f $@ && ln -s $< .
+pool_path.c: ../../../src/utils/pool_path.c
+       rm -f $@ && ln -s $< .
 fe_memutils.c: ../../../src/tools/fe_memutils.c
        rm -f $@ && ln -s $< .
 
index 0824e01bb6162137ad83dd8226900fc8e0198998..dfc47f58e4576b591ee7a440dc511f94d5cfc2ea 100644 (file)
@@ -334,14 +334,15 @@ main(int argc, char **argv)
                }
 
                if (debug)
-                       printf("DEBUG: From config %s:%d\n",pool_config->wd_ipc_socket_dir, pool_config->wd_port);
+                       printf("DEBUG: From config %s:%d\n",pool_config->wd_ipc_socket_dir,
+                                       pool_config->wd_nodes.wd_node_info[pool_config->pgpool_node_id].wd_port);
 
                pfree(conf_file_path);
                /* only use values from pg_config that are not provided explicitely*/
                if (wd_authkey == NULL)
                        wd_authkey = pstrdup(pool_config->wd_authkey);
                if (port < 0)
-                       port = pool_config->wd_port;
+                       port = pool_config->wd_nodes.wd_node_info[pool_config->pgpool_node_id].wd_port;
                if (socket_dir == NULL)
                        socket_dir = pstrdup(pool_config->wd_ipc_socket_dir);
        }
index 9ecd8e088d9f3f7cf172c923aceb0a12233cb3ca..f570d20c6f3a39c0fbaf5b7dfc7121a8f71a41e7 100644 (file)
@@ -774,16 +774,6 @@ get_config(int *nrows)
        StrNCpy(status[i].desc, "delegate IP address of master pgpool", POOLCONFIG_MAXDESCLEN);
        i++;
 
-       StrNCpy(status[i].name, "wd_hostname", POOLCONFIG_MAXNAMELEN);
-       snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->wd_hostname);
-       StrNCpy(status[i].desc, "Host name or IP address of this watchdog", POOLCONFIG_MAXDESCLEN);
-       i++;
-
-       StrNCpy(status[i].name, "wd_port", POOLCONFIG_MAXNAMELEN);
-       snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->wd_port);
-       StrNCpy(status[i].desc, "watchdog port number", POOLCONFIG_MAXDESCLEN);
-       i++;
-
        StrNCpy(status[i].name, "wd_priority", POOLCONFIG_MAXNAMELEN);
        snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->wd_priority);
        StrNCpy(status[i].desc, "watchdog priority", POOLCONFIG_MAXDESCLEN);
@@ -1030,35 +1020,57 @@ get_config(int *nrows)
                if (WD_INFO(j).pgpool_port == 0)
                        continue;
 
-               snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "other_pgpool_hostname%d", j);
-               snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_INFO(j).hostname);
-               snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d hostname", j);
-               i++;
-
-               snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "other_pgpool_port%d", j);
-               snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_INFO(j).pgpool_port);
-               snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d port number", j);
-               i++;
-
-               snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "other_pgpool_wd_port%d", j);
-               snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_INFO(j).wd_port);
-               snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d watchdog port number", j);
-               i++;
-
+               if (j == pool_config->pgpool_node_id)
+               {
+                       snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "hostname%d", j);
+                       snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_INFO(j).hostname);
+                       snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "Host name or IP address of this watchdog");
+                       i++;
+
+                       snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "pgpool_port%d", j);
+                       snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_INFO(j).pgpool_port);
+                       snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "local pgpool port number");
+                       i++;
+
+                       snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "wd_port%d", j);
+                       snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_INFO(j).wd_port);
+                       snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "local pgpool watchdog port number");
+                       i++;
+               }
+               else
+               {
+                       snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "hostname%d", j);
+                       snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_INFO(j).hostname);
+                       snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d hostname", j);
+                       i++;
+
+                       snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "pgpool_port%d", j);
+                       snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_INFO(j).pgpool_port);
+                       snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d port number", j);
+                       i++;
+
+                       snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "wd_port%d", j);
+                       snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_INFO(j).wd_port);
+                       snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d watchdog port number", j);
+                       i++;
+               }
        }
 
-       for (j = 0; j < pool_config->num_hb_if; j++)
+       for (j = 0; j < pool_config->num_hb_dest_if; j++)
        {
-               snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "heartbeat_device%d", j);
-               snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_HB_IF(j).if_name);
-               snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "name of NIC device #%d for sending hearbeat", j);
-               i++;
+               if (j == pool_config->pgpool_node_id)
+                       continue;
 
                snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "heartbeat_destination%d", j);
                snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_HB_IF(j).addr);
                snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "destination host for sending heartbeat using NIC device %d", j);
                i++;
 
+               snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "heartbeat_device%d", j);
+               snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_HB_IF(j).if_name);
+               snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "name of NIC device #%d for sending hearbeat", j);
+               i++;
+
                snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "heartbeat_destination_port%d", j);
                snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_HB_IF(j).dest_port);
                snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "destination port for sending heartbeat using NIC device %d", j);
index 841a349d55bd0b8144d6d1bef1c740d13bbebbf5..fb4a34177164c6b3f1453a90d605c3ac6432ab5c 100644 (file)
@@ -617,7 +617,7 @@ initialize_watchdog(void)
 static void
 wd_check_config(void)
 {
-       if (pool_config->wd_remote_nodes.num_wd == 0)
+       if (pool_config->wd_nodes.num_wd == 0)
                ereport(ERROR,
                                (errmsg("invalid watchdog configuration. other pgpools setting is not defined")));
 
@@ -627,7 +627,7 @@ wd_check_config(void)
                                                MAX_PASSWORD_SIZE)));
        if (pool_config->wd_lifecheck_method == LIFECHECK_BY_HB)
        {
-               if (pool_config->num_hb_if <= 0)
+               if (pool_config->num_hb_dest_if <= 0)
                        ereport(ERROR,
                                        (errmsg("invalid lifecheck configuration. no heartbeat interfaces defined")));
        }
@@ -714,22 +714,24 @@ static void
 wd_cluster_initialize(void)
 {
        int                     i = 0;
+       int                     pgpool_node_id = pool_config->pgpool_node_id;
 
-       if (pool_config->wd_remote_nodes.num_wd <= 0)
+       if (pool_config->wd_nodes.num_wd <= 0)
        {
                /* should also have upper limit??? */
                ereport(ERROR,
                                (errmsg("initializing watchdog failed. no watchdog nodes configured")));
        }
+
        /* initialize local node settings */
        g_cluster.localNode = palloc0(sizeof(WatchdogNode));
-       g_cluster.localNode->wd_port = pool_config->wd_port;
+       g_cluster.localNode->wd_port = pool_config->wd_nodes.wd_node_info[pgpool_node_id].wd_port;
+       g_cluster.localNode->pgpool_port = pool_config->wd_nodes.wd_node_info[pgpool_node_id].pgpool_port;
        g_cluster.localNode->wd_priority = pool_config->wd_priority;
-       g_cluster.localNode->pgpool_port = pool_config->port;
-       g_cluster.localNode->private_id = 0;
+       g_cluster.localNode->pgpool_node_id = pool_config->pgpool_node_id;
        gettimeofday(&g_cluster.localNode->startup_time, NULL);
 
-       strncpy(g_cluster.localNode->hostname, pool_config->wd_hostname, sizeof(g_cluster.localNode->hostname) - 1);
+       strncpy(g_cluster.localNode->hostname, pool_config->wd_nodes.wd_node_info[pgpool_node_id].hostname, sizeof(g_cluster.localNode->hostname) - 1);
        strncpy(g_cluster.localNode->delegate_ip, pool_config->delegate_IP, sizeof(g_cluster.localNode->delegate_ip) - 1);
        /* Assign the node name */
        {
@@ -737,8 +739,8 @@ wd_cluster_initialize(void)
 
                uname(&unameData);
                snprintf(g_cluster.localNode->nodeName, sizeof(g_cluster.localNode->nodeName), "%s:%d %s %s",
-                                pool_config->wd_hostname,
-                                pool_config->port,
+                                pool_config->wd_nodes.wd_node_info[pgpool_node_id].hostname,
+                                pool_config->wd_nodes.wd_node_info[pgpool_node_id].pgpool_port,
                                 unameData.sysname,
                                 unameData.nodename);
                /* should also have upper limit??? */
@@ -747,24 +749,32 @@ wd_cluster_initialize(void)
        }
 
        /* initialize remote nodes */
-       g_cluster.remoteNodeCount = pool_config->wd_remote_nodes.num_wd;
-       g_cluster.remoteNodes = palloc0((sizeof(WatchdogNode) * g_cluster.remoteNodeCount));
+       g_cluster.remoteNodeCount = pool_config->wd_nodes.num_wd - 1;
+       if (g_cluster.remoteNodeCount == 0)
+               ereport(ERROR,
+                (errmsg("invalid watchdog configuration. other pgpools setting is not defined")));
 
        ereport(LOG,
                        (errmsg("watchdog cluster is configured with %d remote nodes", g_cluster.remoteNodeCount)));
-
-       for (i = 0; i < pool_config->wd_remote_nodes.num_wd; i++)
+       g_cluster.remoteNodes = palloc0((sizeof(WatchdogNode) * g_cluster.remoteNodeCount));
+       int idx = 0;
+       for (i = 0; i < pool_config->wd_nodes.num_wd; i++)
        {
-               g_cluster.remoteNodes[i].wd_port = pool_config->wd_remote_nodes.wd_remote_node_info[i].wd_port;
-               g_cluster.remoteNodes[i].private_id = i + 1;
-               g_cluster.remoteNodes[i].pgpool_port = pool_config->wd_remote_nodes.wd_remote_node_info[i].pgpool_port;
-               strcpy(g_cluster.remoteNodes[i].hostname, pool_config->wd_remote_nodes.wd_remote_node_info[i].hostname);
-               g_cluster.remoteNodes[i].delegate_ip[0] = '\0'; /* this will be
+               if (i == pool_config->pgpool_node_id)
+                       continue;
+
+               g_cluster.remoteNodes[idx].wd_port = pool_config->wd_nodes.wd_node_info[i].wd_port;
+               g_cluster.remoteNodes[idx].pgpool_node_id = i;
+               g_cluster.remoteNodes[idx].pgpool_port = pool_config->wd_nodes.wd_node_info[i].pgpool_port;
+               strcpy(g_cluster.remoteNodes[idx].hostname, pool_config->wd_nodes.wd_node_info[i].hostname);
+               g_cluster.remoteNodes[idx].delegate_ip[0] = '\0'; /* this will be
                                                                                                                 * populated by remote
                                                                                                                 * node */
 
                ereport(LOG,
-                               (errmsg("watchdog remote node:%d on %s:%d", i, g_cluster.remoteNodes[i].hostname, g_cluster.remoteNodes[i].wd_port)));
+                               (errmsg("watchdog remote node:%d on %s:%d", idx, g_cluster.remoteNodes[idx].hostname, g_cluster.remoteNodes[idx].wd_port)));
+
+               idx++;
        }
 
        g_cluster.clusterMasterInfo.masterNode = NULL;
@@ -1545,6 +1555,15 @@ read_sockets(fd_set *rmask, int pending_fds_count)
                                        bool            found = false;
                                        bool            authenticated = false;
 
+                                       if (tempNode->pgpool_node_id == pool_config->pgpool_node_id)
+                                       {
+                                               ereport(ERROR,
+                                                               (errmsg("the pgpool node id configured on node \"%s\" cannot be same as local node", tempNode->nodeName),
+                                                                errdetail("this node id is \"%d\" while local node is \"%d\"",
+                                                                                  tempNode->pgpool_node_id,
+                                                                                  pool_config->pgpool_node_id)));
+                                       }
+
                                        print_watchdog_node_info(tempNode);
                                        authenticated = verify_authhash_for_node(tempNode, authkey);
                                        ereport(DEBUG1,
@@ -1557,7 +1576,8 @@ read_sockets(fd_set *rmask, int pending_fds_count)
                                                {
                                                        wdNode = &(g_cluster.remoteNodes[i]);
 
-                                                       if ((wdNode->wd_port == tempNode->wd_port && wdNode->pgpool_port == tempNode->pgpool_port) &&
+                                                       if ((wdNode->wd_port == tempNode->wd_port && wdNode->pgpool_port == tempNode->pgpool_port &&
+                                                               wdNode->pgpool_node_id == tempNode->pgpool_node_id) &&
                                                                ((strcmp(wdNode->hostname, conn->addr) == 0) || (strcmp(wdNode->hostname, tempNode->hostname) == 0)))
                                                        {
                                                                /* We have found the match */
@@ -2230,7 +2250,7 @@ fire_node_status_event(int nodeID, int nodeStatus)
 
                for (i = 0; i < g_cluster.remoteNodeCount; i++)
                {
-                       if (nodeID == g_cluster.remoteNodes[i].private_id)
+                       if (nodeID == g_cluster.remoteNodes[i].pgpool_node_id)
                        {
                                wdNode = &g_cluster.remoteNodes[i];
                                break;
@@ -3572,7 +3592,7 @@ add_nodeinfo_to_json(JsonNode * jNode, WatchdogNode * node)
 {
        jw_start_object(jNode, "WatchdogNode");
 
-       jw_put_int(jNode, "ID", nodeIfNull_int(private_id, -1));
+       jw_put_int(jNode, "ID", nodeIfNull_int(pgpool_node_id, -1));
        jw_put_int(jNode, "State", nodeIfNull_int(state, -1));
        jw_put_string(jNode, "NodeName", nodeIfNull_str(nodeName, NotSet));
        jw_put_string(jNode, "HostName", nodeIfNull_str(hostname, NotSet));
@@ -3634,7 +3654,7 @@ static JsonNode * get_node_list_json(int id)
                        {
                                WatchdogNode *wdNode = &(g_cluster.remoteNodes[i]);
 
-                               if (wdNode->private_id == id)
+                               if (wdNode->pgpool_node_id == id)
                                {
                                        wdNodeToAdd = wdNode;
                                        break;
@@ -7397,14 +7417,14 @@ verify_pool_configurations(WatchdogNode * wdNode, POOL_CONFIG * config)
                }
        }
 
-       if (config->wd_remote_nodes.num_wd != pool_config->wd_remote_nodes.num_wd)
+       if (config->wd_nodes.num_wd != pool_config->wd_nodes.num_wd)
        {
                ereport(WARNING,
                                (errmsg("the number of configured watchdog nodes on node \"%s\" are different", wdNode->nodeName),
                                 errdetail("this node has %d watchdog nodes while \"%s\" is configured with %d watchdog nodes",
-                                                  pool_config->wd_remote_nodes.num_wd,
+                                                  pool_config->wd_nodes.num_wd,
                                                   wdNode->nodeName,
-                                                  config->wd_remote_nodes.num_wd)));
+                                                  config->wd_nodes.num_wd)));
        }
 }
 
index 88a5914d6f0e999087eb721a7843c8ba546018cd..b2e8f4da026af29ead5fc2f597131dff500fb2ff 100644 (file)
@@ -551,7 +551,7 @@ wd_hb_sender(int fork_wait_time, WdHbIf * hb_if)
 
                /* contents of packet */
                gettimeofday(&pkt.send_time, NULL);
-               strlcpy(pkt.from, pool_config->wd_hostname, sizeof(pkt.from));
+               strlcpy(pkt.from, pool_config->wd_nodes.wd_node_info[pool_config->pgpool_node_id].hostname, sizeof(pkt.from));
                pkt.from_pgpool_port = pool_config->port;
 
                /* authentication key */
index 4515747718e63b5d8b2ccb34ca745062f2868cb2..207a5801fa5f805b237397e081513b978ca7e41f 100644 (file)
@@ -80,7 +80,7 @@ wd_ipc_conn_initialize(void)
 {
        if (watchdog_ipc_address == NULL)
        {
-               wd_set_ipc_address(pool_config->wd_ipc_socket_dir, pool_config->wd_port);
+               wd_set_ipc_address(pool_config->wd_ipc_socket_dir, pool_config->wd_nodes.wd_node_info[pool_config->pgpool_node_id].wd_port);
        }
 }
 
index a7576e108f06093ab0ad5c017dc00f3108ddffd2..9c8ff044fdf622fe31e1b74547700d5ddc3a08fc 100644 (file)
@@ -104,10 +104,10 @@ get_pool_config_from_json(char *json_data, int data_len)
                goto ERROR_EXIT;
        if (json_get_bool_value_for_key(root, "clear_memqcache_on_escalation", &config->clear_memqcache_on_escalation))
                goto ERROR_EXIT;
-       if (json_get_int_value_for_key(root, "wd_port", &config->wd_port))
-               goto ERROR_EXIT;
        if (json_get_int_value_for_key(root, "wd_priority", &config->wd_priority))
                goto ERROR_EXIT;
+       if (json_get_int_value_for_key(root, "pgpool_node_id", &config->pgpool_node_id))
+               goto ERROR_EXIT;
        if (json_get_int_value_for_key(root, "master_slave_sub_mode", (int *) &config->master_slave_sub_mode))
                goto ERROR_EXIT;
 
@@ -137,25 +137,25 @@ get_pool_config_from_json(char *json_data, int data_len)
                strncpy(config->backend_desc->backend_info[i].backend_hostname, ptr, sizeof(config->backend_desc->backend_info[i].backend_hostname) - 1);
        }
 
-       /* wd_remote_nodes array */
-       value = json_get_value_for_key(root, "wd_remote_nodes");
+       /* wd_nodes array */
+       value = json_get_value_for_key(root, "wd_nodes");
        if (value == NULL || value->type != json_array)
                goto ERROR_EXIT;
 
-       config->wd_remote_nodes.num_wd = value->u.array.length;
-       for (i = 0; i < config->wd_remote_nodes.num_wd; i++)
+       config->wd_nodes.num_wd = value->u.array.length;
+       for (i = 0; i < config->wd_nodes.num_wd; i++)
        {
                json_value *arr_value = value->u.array.values[i];
                char       *ptr;
 
-               if (json_get_int_value_for_key(arr_value, "wd_port", &config->wd_remote_nodes.wd_remote_node_info[i].wd_port))
+               if (json_get_int_value_for_key(arr_value, "wd_port", &config->wd_nodes.wd_node_info[i].wd_port))
                        goto ERROR_EXIT;
-               if (json_get_int_value_for_key(arr_value, "pgpool_port", &config->wd_remote_nodes.wd_remote_node_info[i].pgpool_port))
+               if (json_get_int_value_for_key(arr_value, "pgpool_port", &config->wd_nodes.wd_node_info[i].pgpool_port))
                        goto ERROR_EXIT;
                ptr = json_get_string_value_for_key(arr_value, "hostname");
                if (ptr == NULL)
                        goto ERROR_EXIT;
-               strncpy(config->wd_remote_nodes.wd_remote_node_info[i].hostname, ptr, sizeof(config->wd_remote_nodes.wd_remote_node_info[i].hostname) - 1);
+               strncpy(config->wd_nodes.wd_node_info[i].hostname, ptr, sizeof(config->wd_nodes.wd_node_info[i].hostname) - 1);
        }
 
        json_value_free(root);
@@ -206,8 +206,8 @@ get_pool_config_json(void)
        jw_put_bool(jNode, "memory_cache_enabled", pool_config->memory_cache_enabled);
        jw_put_bool(jNode, "use_watchdog", pool_config->use_watchdog);
        jw_put_bool(jNode, "clear_memqcache_on_escalation", pool_config->clear_memqcache_on_escalation);
-       jw_put_int(jNode, "wd_port", pool_config->wd_port);
        jw_put_int(jNode, "wd_priority", pool_config->wd_priority);
+       jw_put_int(jNode, "pgpool_node_id", pool_config->pgpool_node_id);
        jw_put_int(jNode, "master_slave_sub_mode", pool_config->master_slave_sub_mode);
 
        jw_put_bool(jNode, "failover_when_quorum_exists", pool_config->failover_when_quorum_exists);
@@ -225,17 +225,17 @@ get_pool_config_json(void)
        }
        jw_end_element(jNode);          /* backend_desc array End */
 
-       /* Array of wd_remote_nodes */
-       jw_start_array(jNode, "wd_remote_nodes");
-       for (i = 0; i < pool_config->wd_remote_nodes.num_wd; i++)
+       /* Array of wd_nodes */
+       jw_start_array(jNode, "wd_nodes");
+       for (i = 0; i < pool_config->wd_nodes.num_wd; i++)
        {
-               jw_start_object(jNode, "WdRemoteNodesConfig");
-               jw_put_string(jNode, "hostname", pool_config->wd_remote_nodes.wd_remote_node_info[i].hostname);
-               jw_put_int(jNode, "wd_port", pool_config->wd_remote_nodes.wd_remote_node_info[i].wd_port);
-               jw_put_int(jNode, "pgpool_port", pool_config->wd_remote_nodes.wd_remote_node_info[i].pgpool_port);
+               jw_start_object(jNode, "WdNodesConfig");
+               jw_put_string(jNode, "hostname", pool_config->wd_nodes.wd_node_info[i].hostname);
+               jw_put_int(jNode, "wd_port", pool_config->wd_nodes.wd_node_info[i].wd_port);
+               jw_put_int(jNode, "pgpool_port", pool_config->wd_nodes.wd_node_info[i].pgpool_port);
                jw_end_element(jNode);
        }
-       jw_end_element(jNode);          /* wd_remote_nodes array End */
+       jw_end_element(jNode);          /* wd_nodes array End */
 
        jw_finish_document(jNode);
        json_str = pstrdup(jw_get_json_string(jNode));
@@ -443,6 +443,7 @@ get_watchdog_node_info_json(WatchdogNode * wdNode, char *authkey)
        jw_put_int(jNode, "WdPort", wdNode->wd_port);
        jw_put_int(jNode, "PgpoolPort", wdNode->pgpool_port);
        jw_put_int(jNode, "WdPriority", wdNode->wd_priority);
+       jw_put_int(jNode, "PgpoolNodeId", wdNode->pgpool_node_id);
 
        jw_put_string(jNode, "NodeName", wdNode->nodeName);
        jw_put_string(jNode, "HostName", wdNode->hostname);
@@ -521,6 +522,8 @@ get_watchdog_node_from_json(char *json_data, int data_len, char **authkey)
                goto ERROR_EXIT;
        if (json_get_int_value_for_key(root, "WdPriority", &wdNode->wd_priority))
                goto ERROR_EXIT;
+       if (json_get_int_value_for_key(root, "PgpoolNodeId", &wdNode->pgpool_node_id))
+               goto ERROR_EXIT;
 
 
        ptr = json_get_string_value_for_key(root, "NodeName");
index ad6f9208095533d37a201e9a8f43d38529b79a45..7dfda75f374e2cd973ef4e9f3b09caa9f8167533 100644 (file)
@@ -134,7 +134,7 @@ lifecheck_child_name(pid_t pid)
 {
        int                     i;
 
-       for (i = 0; i < pool_config->num_hb_if; i++)
+       for (i = 0; i < pool_config->num_hb_dest_if; i++)
        {
                if (g_hb_receiver_pid && pid == g_hb_receiver_pid[i])
                        return "heartBeat receiver";
@@ -213,13 +213,13 @@ wd_reaper_lifecheck(pid_t pid, int status)
        if (g_hb_receiver_pid == NULL && g_hb_sender_pid == NULL)
                return -1;
 
-       for (i = 0; i < pool_config->num_hb_if; i++)
+       for (i = 0; i < pool_config->num_hb_dest_if; i++)
        {
                if (g_hb_receiver_pid && pid == g_hb_receiver_pid[i])
                {
                        if (restart_child)
                        {
-                               g_hb_receiver_pid[i] = wd_hb_receiver(1, &(pool_config->hb_if[i]));
+                               g_hb_receiver_pid[i] = wd_hb_receiver(1, &(pool_config->hb_dest_if[i]));
                                ereport(LOG,
                                                (errmsg("fork a new %s process with pid: %d", proc_name, g_hb_receiver_pid[i])));
                        }
@@ -233,7 +233,7 @@ wd_reaper_lifecheck(pid_t pid, int status)
                {
                        if (restart_child)
                        {
-                               g_hb_sender_pid[i] = wd_hb_sender(1, &(pool_config->hb_if[i]));
+                               g_hb_sender_pid[i] = wd_hb_sender(1, &(pool_config->hb_dest_if[i]));
                                ereport(LOG,
                                                (errmsg("fork a new %s process with pid: %d", proc_name, g_hb_sender_pid[i])));
                        }
@@ -256,7 +256,7 @@ lifecheck_kill_all_children(int sig)
        {
                int                     i;
 
-               for (i = 0; i < pool_config->num_hb_if; i++)
+               for (i = 0; i < pool_config->num_hb_dest_if; i++)
                {
                        pid_t           pid_child = g_hb_receiver_pid[i];
 
@@ -468,16 +468,16 @@ spawn_lifecheck_children(void)
        {
                int                     i;
 
-               g_hb_receiver_pid = palloc0(sizeof(pid_t) * pool_config->num_hb_if);
-               g_hb_sender_pid = palloc0(sizeof(pid_t) * pool_config->num_hb_if);
+               g_hb_receiver_pid = palloc0(sizeof(pid_t) * pool_config->num_hb_dest_if);
+               g_hb_sender_pid = palloc0(sizeof(pid_t) * pool_config->num_hb_dest_if);
 
-               for (i = 0; i < pool_config->num_hb_if; i++)
+               for (i = 0; i < pool_config->num_hb_dest_if; i++)
                {
                        /* heartbeat receiver process */
-                       g_hb_receiver_pid[i] = wd_hb_receiver(1, &(pool_config->hb_if[i]));
+                       g_hb_receiver_pid[i] = wd_hb_receiver(1, &(pool_config->hb_dest_if[i]));
 
                        /* heartbeat sender process */
-                       g_hb_sender_pid[i] = wd_hb_sender(1, &(pool_config->hb_if[i]));
+                       g_hb_sender_pid[i] = wd_hb_sender(1, &(pool_config->hb_dest_if[i]));
                }
        }
 }
@@ -667,7 +667,7 @@ is_wd_lifecheck_ready(void)
                /* heartbeat mode */
                else if (pool_config->wd_lifecheck_method == LIFECHECK_BY_HB)
                {
-                       if (node->ID == 0)      /* local node */
+                       if (node->ID == pool_config->pgpool_node_id)    /* local node */
                                continue;
 
                        if (!WD_TIME_ISSET(node->hb_last_recv_time) ||