<!--
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')
<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>
<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')
<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>
<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>
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.
*/
#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
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)
/*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);
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);
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);
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.",
},
{
- {"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,
},
{
- {"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
},
},
{
- {"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
},
},
{
- {"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
},
{
},
{
- {"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,
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.",
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.",
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;
/* 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;
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 *
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;
}
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;
}
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)
{
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++)
}
/* 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, ""))
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)
{
/* 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)
/*
* 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
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
* 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) */
* 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
{
*/
#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
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
# - 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)
# -- 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')
# 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 --
# - 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)
# /var/run/postgresql
# (change requires restart)
-
# - Virtual IP control Setting -
delegate_IP = ''
# -- 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')
# 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 --
# - 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
# -- 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')
# 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 --
# - 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)
# -- 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')
# 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 --
# - 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
# -- 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')
# 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 --
# 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
#------------------------------------------------------------------------------
# - 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)
# -- 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')
# 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 --
# 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
#------------------------------------------------------------------------------
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
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
source ./bashrc.ports
cat ../master.conf >> etc/pgpool.conf
+echo 0 > etc/pgpool_node_id
./startall
wait_for_pgpool_startup
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 &
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
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
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
source ./bashrc.ports
cat ../master.conf >> etc/pgpool.conf
+echo 0 > etc/pgpool_node_id
./startall
wait_for_pgpool_startup
# 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 &
# 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 &
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
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
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
source ./bashrc.ports
cat ../master.conf >> etc/pgpool.conf
+echo 0 > etc/pgpool_node_id
./startall
wait_for_pgpool_startup
# 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 &
# 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 &
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
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
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
source ./bashrc.ports
cat ../master.conf >> etc/pgpool.conf
+echo 0 > etc/pgpool_node_id
./startall
wait_for_pgpool_startup
# 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 &
# 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 &
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
source ./bashrc.ports
cat ../master.conf >> etc/pgpool.conf
+echo 0 > etc/pgpool_node_id
./startall
wait_for_pgpool_startup
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
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
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
source ./bashrc.ports
cat ../master.conf >> etc/pgpool.conf
+echo 0 > etc/pgpool_node_id
./startall
wait_for_pgpool_startup
# 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 &
# 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 &
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
}
#################################################################################
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
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
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@)
regex_array.c \
pool_config_variables.c \
pool_config.c \
- fe_memutils.c
+ fe_memutils.c \
+ pool_path.c
all: all-am
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
json.c \
pool_config_variables.c \
pool_config.c \
+ pool_path.c \
fe_memutils.c \
stringinfo.h \
stringinfo.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 $< .
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@)
json.c \
pool_config_variables.c \
pool_config.c \
+ pool_path.c \
fe_memutils.c \
stringinfo.h \
stringinfo.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 $< .
}
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);
}
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);
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);
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")));
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")));
}
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 */
{
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??? */
}
/* 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;
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,
{
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 */
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;
{
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));
{
WatchdogNode *wdNode = &(g_cluster.remoteNodes[i]);
- if (wdNode->private_id == id)
+ if (wdNode->pgpool_node_id == id)
{
wdNodeToAdd = wdNode;
break;
}
}
- 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)));
}
}
/* 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 */
{
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);
}
}
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;
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);
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);
}
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));
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);
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");
{
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";
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])));
}
{
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])));
}
{
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];
{
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]));
}
}
}
/* 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) ||