diff --git a/doc.ja/src/sgml/example-watchdog.sgml b/doc.ja/src/sgml/example-watchdog.sgml index 055aa2e..2fd3ed1 100644 --- a/doc.ja/src/sgml/example-watchdog.sgml +++ b/doc.ja/src/sgml/example-watchdog.sgml @@ -136,13 +136,8 @@ 次に、それぞれのPgpool-IIで以下のパラメータを設定します。 - を他のPgpool-IIの値で設定します。 @@ -428,7 +423,7 @@ --> watchdog の監視方法について設定するパラメータがあります。 監視間隔秒を指定する、死活監視のタイプを指定するを記述します。 - heartbeat方式では、障害と判断する秒数を指定する、受信ポート番号を指定する、ハートビート信号の送信間隔秒を指定する、送信先を記述します。 + heartbeat方式では、障害と判断する秒数を指定する、受信ポート番号を指定する、ハートビート信号の送信間隔秒を指定する、送信先を記述します。 wd_lifecheck_method = 'heartbeat' # Method of watchdog lifecheck ('heartbeat' or 'query' or 'external') diff --git a/doc.ja/src/sgml/watchdog.sgml b/doc.ja/src/sgml/watchdog.sgml index 91b6e57..abb6396 100644 --- a/doc.ja/src/sgml/watchdog.sgml +++ b/doc.ja/src/sgml/watchdog.sgml @@ -64,13 +64,13 @@ - - wd_hostname (string) + + hostnameX (string) - wd_hostname設定パラメータ + hostnameX設定パラメータ @@ -80,9 +80,12 @@ Pgpool-II 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). --> Pgpool-IIサーバのホスト名またはIPアドレスを指定します。 クエリやパケットの送受信の他、watchdogの識別子としても用います。 + パラメータ名の最後にある数字は「pgpool ノードID」で、0から始まります(たとえばhostname0)。 - wd_port 設定パラメータ + wd_port設定パラメータ @@ -106,9 +109,12 @@ watchdogが接続を受け付けるために監視するポート番号です。 デフォルト値は9000です。 + パラメータ名の最後にある数字は「pgpool ノードID」で、0から始まります(たとえばwd_port0)。 + pgpool_portX設定パラメータ + + + + + + Pgpool-IIサーバのポート番号を指定します。 + デフォルト値は9999です。 + パラメータ名の最後にある数字は「pgpool ノードID」で、0から始まります(たとえばpgpool_port0)。 + + + + このパラメータは、サーバ起動時にのみ設定できます。 + + + + Watchdogの設定例 + + + Pgpool ノードが3つあり、それぞれのホストが server1、server2、server3 の場合、 + + 及びを以下のように設定します。 + + hostname0 = 'server1' + wd_port0 = 9000 + pgpool_port0 = 9999 + + hostname1 = 'server2' + wd_port1 = 9000 + pgpool_port1 = 9999 + + hostname2 = 'server3' + wd_port2 = 9000 + pgpool_port2 = 9999 + + + + + + wd_authkey (string) @@ -1201,58 +1266,35 @@ 死活監視:ハートビートモードの設定 - - wd_heartbeat_port (integer) + + heartbeat_hostnameX (string) - wd_heartbeat_port設定パラメータ + heartbeat_hostnameX設定パラメータ - ハートビート信号を受信するUDPポート番号を指定します。 - デフォルトは 9694 です。 - 'heartbeat'に設定されている場合のみ有効です。 - - - - このパラメータは、サーバ起動時にのみ設定できます。 + ハートビート信号を送受信するためのIPアドレスまたは ホスト名を指定します。 + パラメータ名の最後にある数字は「pgpool ノードID」で、0から始まります(たとえばheartbeat_hostname0)。 + 複数のハートビート信号の送り先をセミコロン(;)で区切って指定することができます。 - - - - - wd_heartbeat_keepalive (integer) - - - wd_heartbeat_keepalive設定パラメータ - - - - ハートビート信号を送信する間隔(秒)を指定します。 - デフォルトは2です。 - wd_heartbeat_keepaliveは、'heartbeat'に設定されている場合のみ有効です。 + heartbeat_hostnameXは、'heartbeat'に設定されている場合のみ有効です。 - - wd_heartbeat_deadtime設定パラメータ + heartbeat_portX設定パラメータ + ハートビート信号を受信するためのポート番号を指定します。 + 1つのみを指定してください。 + パラメータ名の最後にある数字は「pgpool ノードID」で、0から始まります(たとえばheartbeat_port0)。 + + + - このオプションで指定された間隔(秒)の間ハートビート信号が途絶えた場合、リモートのwatchdogに障害が発生したとみなされます。 - デフォルトは30です。 + heartbeat_portXは、'heartbeat'に設定されている場合のみ有効です。 このパラメータは、サーバ起動時にのみ設定できます。 - - - heartbeat_destination0 (string) + + + heartbeat_deviceX (string) - heartbeat_destination設定パラメータ + heartbeat_deviceX設定パラメータ - ハートビート信号の送る先のIPアドレスまたは ホスト名を指定します。 - 複数のハートビート信号の送り先が指定可能です。 - 0から始まるパラメータの最後の部分は送り先の番号です。 + ハートビートの送受信に用いるネットワークデバイス名を指定します。 + パラメータ名の最後にある数字は「pgpool ノードID」で、0から始まります(たとえばheartbeat_device0)。 + 複数のネットワークデバイス名をセミコロン(;)で区切って指定することができます。 - heartbeat_destinationは、'heartbeat'に設定されている場合のみ有効です。 + heartbeat_deviceXは、'heartbeat'に設定されている場合のみ有効です。 このパラメータは、サーバ起動時にのみ設定できます。 + + + Heartbeat 信号を用いた死活監視の設定例 + + + Pgpool ノードが3つあり、それぞれのホストが server1、server2、server3 の場合、 + + 及びを以下のように設定します。 + + heartbeat_hostname0 = 'server1' + heartbeat_port0 = 9694 + heartbeat_device0 = '' + + heartbeat_hostname1 = 'server2' + heartbeat_port1 = 9694 + heartbeat_device1 = '' + + heartbeat_hostname2 = 'server3' + heartbeat_port2 = 9694 + heartbeat_device2 = '' + + + - - heartbeat_destination_port0 (integer) + + wd_heartbeat_keepalive (integer) - heartbeat_destination_port設定パラメータ + wd_heartbeat_keepalive設定パラメータ - ハートビート信号の送る先のポート番号を指定します。 - 複数のハートビート信号の送り先が指定可能です。 - 0から始まるパラメータの最後の部分は送り先の番号です。 - - - - heartbeat_destination_portは、'heartbeat'に設定されている場合のみ有効です。 + ハートビート信号を送信する間隔(秒)を指定します。 + デフォルトは2です。 + wd_heartbeat_keepaliveは、'heartbeat'に設定されている場合のみ有効です。 + - heartbeat_device設定パラメータ + wd_heartbeat_deadtime設定パラメータ - heartbeat_destinationX:heartbeat_destination_portXで指定されるハートビートの送信先に用いるネットワークデバイス名を指定します。 - パラメータ名の最後にあるXの値(送信先番号)を変えることにより、ハートビートの送信先ごとに異なるハートビートデバイス番号を設定することが可能です。 - 送信先番号は0から始まります。 - - - - heartbeat_deviceは、'heartbeat'に設定されている場合のみ有効です。 + このオプションで指定された間隔(秒)の間ハートビート信号が途絶えた場合、リモートのwatchdogに障害が発生したとみなされます。 + デフォルトは30です。 - Watchdogサーバの設定 - - - - other_pgpool_hostname0 (string) - - - other_pgpool_hostname設定パラメータ - - - - - - リモートのwatchdogノードに対するPgpool-IIサーバのホスト名を指定します。 - パラメータ名の最後にある数字は「サーバ番号」で、0から始まります。 - - - - このパラメータは、サーバ起動時にのみ設定できます。 - - - - - - other_pgpool_port0 (integer) - - - other_pgpool_port設定パラメータ - - - - - - リモートのwatchdogノードに対するPgpool-IIサーバのポート番号を指定します。 - パラメータ名の最後にある数字は「サーバ番号」で、0から始まります。 - - - - このパラメータは、サーバ起動時にのみ設定できます。 - - - - - - other_wd_port0 (integer) - - - other_wd_port0設定パラメータ - - - - - - リモートのPgpool-IIサーバにおけるwatchdogのポート番号を指定します。 - パラメータ名の最後にある数字は「サーバ番号」で、0から始まります。 - - - - このパラメータは、サーバ起動時にのみ設定できます。 - - - - - - diff --git a/doc/src/sgml/example-watchdog.sgml b/doc/src/sgml/example-watchdog.sgml index 1021843..3019354 100644 --- a/doc/src/sgml/example-watchdog.sgml +++ b/doc/src/sgml/example-watchdog.sgml @@ -82,10 +82,6 @@ Next, set the following parameters for each Pgpool-II. - Specify , - and - with the values of - other Pgpool-II server values. @@ -290,10 +286,10 @@ the type of lifecheck . The hearbeat method specify the time to detect a fault , the port number to - receive , the interval to send + receive , the interval to send , the IP address or hostname - of destination and finally - the destination port number . + of destination and finally + the destination port number . wd_lifecheck_method = 'heartbeat' # Method of watchdog lifecheck ('heartbeat' or 'query' or 'external') diff --git a/doc/src/sgml/watchdog.sgml b/doc/src/sgml/watchdog.sgml index 8562b70..b62020f 100644 --- a/doc/src/sgml/watchdog.sgml +++ b/doc/src/sgml/watchdog.sgml @@ -40,10 +40,10 @@ - - wd_hostname (string) + + hostnameX (string) - wd_hostname configuration parameter + hostnameX configuration parameter @@ -52,6 +52,8 @@ Pgpool-II 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). This parameter can only be set at server start. @@ -60,19 +62,62 @@ - wd_port (integer) + wd_portX (integer) - wd_port configuration parameter + wd_portX configuration parameter 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). + + + This parameter can only be set at server start. + + + + + + pgpool_portX (integer) + + pgpool_portX configuration parameter + + + + + Specifies the Pgpool-II 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). This parameter can only be set at server start. + + + Watchdog configuration + + If you have 3 pgpool nodes with hostname server1, server2 and server3, + you can set the , + and like below: + + hostname0 = 'server1' + wd_port0 = 9000 + pgpool_port0 = 9999 + + hostname1 = 'server2' + wd_port1 = 9000 + pgpool_port1 = 9999 + + hostname2 = 'server3' + wd_port2 = 9000 + pgpool_port2 = 9999 + + + @@ -850,131 +895,130 @@ Lifecheck Heartbeat mode configuration - - - wd_heartbeat_port (integer) + + heartbeat_hostnameX (string) - wd_heartbeat_port configuration parameter + heartbeat_hostnameX configuration parameter - Specifies the UDP port number to receive heartbeat signals. - Default is 9694. - wd_heartbeat_port is only applicable if the - is set to 'heartbeat' + Specifies the IP address or hostname + 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 IP address or hostname + by separating them using semicolon (;). - This parameter can only be set at server start. - - - - - - wd_heartbeat_keepalive (integer) - - wd_heartbeat_keepalive configuration parameter - - - - - Specifies the interval time in seconds between sending the heartbeat signals. - Default is 2. - wd_heartbeat_keepalive is only applicable if the + heartbeat_hostnameX is only applicable if the is set to 'heartbeat' - This parameter can only be set at server start. - - wd_heartbeat_deadtime (integer) + + heartbeat_portX (integer) - wd_heartbeat_deadtime configuration parameter + heartbeat_portX configuration parameter - 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 30 - wd_heartbeat_deadtime 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). + + + heartbeat_portX is only applicable if the is set to 'heartbeat' This parameter can only be set at server start. - - - heartbeat_destination0 (string) + + + heartbeat_deviceX (string) - heartbeat_destination configuration parameter + heartbeat_deviceX configuration parameter - Specifies the IP address or hostname of destination the remote - Pgpool-II 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 (;). - heartbeat_destination is only applicable if the + heartbeat_deviceX is only applicable if the is set to 'heartbeat' This parameter can only be set at server start. + + Heartbeat configuration + + If you have 3 pgpool nodes with hostname server1, server2 and server3, + you can set the , + and like below: + + heartbeat_hostname0 = 'server1' + heartbeat_port0 = 9694 + heartbeat_device0 = '' + + heartbeat_hostname1 = 'server2' + heartbeat_port1 = 9694 + heartbeat_device1 = '' + + heartbeat_hostname2 = 'server3' + heartbeat_port2 = 9694 + heartbeat_device2 = '' + + + - - heartbeat_destination_port0 (integer) + + wd_heartbeat_keepalive (integer) - heartbeat_destination_port configuration parameter + wd_heartbeat_keepalive configuration parameter - Specifies the destination port number of the remote - Pgpool-II 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. - - - heartbeat_destination_port is only applicable if the + Specifies the interval time in seconds between sending the heartbeat signals. + Default is 2. + wd_heartbeat_keepalive is only applicable if the is set to 'heartbeat' + This parameter can only be set at server start. - - heartbeat_device0 (string) + + wd_heartbeat_deadtime (integer) - heartbeat_device configuration parameter + wd_heartbeat_deadtime configuration parameter - 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_device 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 30 + wd_heartbeat_deadtime is only applicable if the is set to 'heartbeat' @@ -982,7 +1026,6 @@ - @@ -1132,66 +1175,4 @@ - - - Watchdog servers configurations - - - - other_pgpool_hostname0 (string) - - other_pgpool_hostname configuration parameter - - - - - Specifies the hostname of remote Pgpool-II server for watchdog node. - The number at the end of the parameter name is referred as "server id", and it starts from 0. - - - This parameter can only be set at server start. - - - - - - other_pgpool_port0 (integer) - - other_pgpool_port configuration parameter - - - - - Specifies the port number of the remote Pgpool-II - server for watchdog node. - The number at the end of the parameter name is referred - as "server id", and it starts from 0. - - - This parameter can only be set at server start. - - - - - - other_wd_port0 (integer) - - other_wd_port0 configuration parameter - - - - - Specifies the watchdog port number of the remote - Pgpool-II server for watchdog node. - The number at the end of the parameter name is referred - as "server id", and it starts from 0. - - - This parameter can only be set at server start. - - - - - - diff --git a/src/config/pool_config.c b/src/config/pool_config.c index ac6aa74..c116501 100644 --- a/src/config/pool_config.c +++ b/src/config/pool_config.c @@ -480,6 +480,8 @@ static char *yy_last_accepting_cpos; extern int yy_flex_debug; int yy_flex_debug = 0; +char *config_file_dir = NULL; /* directory path of config file pgpool.conf */ + /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ @@ -522,6 +524,7 @@ char *yytext; #include "pool_config.h" #include "pool_config_variables.h" #include "utils/regex_array.h" +#include "utils/pool_path.h" #ifndef POOL_PRIVATE #include "utils/elog.h" #else @@ -2062,9 +2065,15 @@ ParseConfigFile(const char *config_file, int elevel, char *key; char *val; ConfigVariable *item; - + char buf[POOLMAXPATHLEN + 1]; + *head_p = NULL; + /* get directory path of config file pgpool.conf */ + strlcpy(buf, config_file, sizeof(buf)); + get_parent_directory(buf); + config_file_dir = buf; + /* open config file */ fd = fopen(config_file, "r"); if (!fd) diff --git a/src/config/pool_config_variables.c b/src/config/pool_config_variables.c index 78a7dc1..3287140 100644 --- a/src/config/pool_config_variables.c +++ b/src/config/pool_config_variables.c @@ -105,8 +105,8 @@ static char **get_list_from_string_regex_delim(const char *str, const char *deli /*show functions */ static const char *IntValueShowFunc(int value); static const char *HBDestinationPortShowFunc(int index); -static const char *HBDestinationShowFunc(int index); static const char *HBDeviceShowFunc(int index); +static const char *HBHostnameShowFunc(int index); static const char *OtherWDPortShowFunc(int index); static const char *OtherPPPortShowFunc(int index); static const char *OtherPPHostShowFunc(int index); @@ -140,9 +140,9 @@ static bool BackendDataDirAssignFunc(ConfigContext context, char *newval, int in static bool BackendFlagsAssignFunc(ConfigContext context, char *newval, int index, int elevel); static bool BackendWeightAssignFunc(ConfigContext context, double newval, int index, int elevel); static bool BackendAppNameAssignFunc(ConfigContext context, char *newval, int index, int elevel); -static bool HBDestinationAssignFunc(ConfigContext context, char *newval, int index, int elevel); static bool HBDestinationPortAssignFunc(ConfigContext context, int newval, int index, int elevel); static bool HBDeviceAssignFunc(ConfigContext context, char *newval, int index, int elevel); +static bool HBHostnameAssignFunc(ConfigContext context, char *newval, int index, int elevel); static bool OtherWDPortAssignFunc(ConfigContext context, int newval, int index, int elevel); static bool OtherPPPortAssignFunc(ConfigContext context, int newval, int index, int elevel); static bool OtherPPHostAssignFunc(ConfigContext context, char *newval, int index, int elevel); @@ -160,6 +160,8 @@ static bool HealthCheckDatabaseAssignFunc(ConfigContext context, char *newval, i static bool LogDestinationProcessFunc(char *newval, int elevel); static bool SyslogIdentProcessFunc(char *newval, int elevel); static bool SyslogFacilityProcessFunc(int newval, int elevel); +static bool SetHBDestIfFunc(int elevel); +static bool SetPgpoolNodeId(int elevel); static struct config_generic *get_index_free_record_if_any(struct config_generic *record); @@ -1032,16 +1034,6 @@ static struct config_string ConfigureNamesString[] = }, { - {"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.", CONFIG_VAR_TYPE_STRING, false, 0 @@ -1448,8 +1440,8 @@ static struct config_int_array ConfigureNamesIntArray[] = }, { - {"heartbeat_destination_port", CFGCXT_RELOAD, WATCHDOG_LIFECHECK, - "Destination port for sending heartbeat.", + {"heartbeat_port", CFGCXT_RELOAD, WATCHDOG_LIFECHECK, + "Port for sending heartbeat.", CONFIG_VAR_TYPE_INT_ARRAY, true, 0, WD_MAX_IF_NUM }, NULL, @@ -1460,7 +1452,7 @@ static struct config_int_array ConfigureNamesIntArray[] = }, { - {"other_wd_port", CFGCXT_RELOAD, WATCHDOG_CONFIG, + {"wd_port", CFGCXT_RELOAD, WATCHDOG_CONFIG, "tcp/ip watchdog port number of other pgpool node for watchdog connection..", CONFIG_VAR_TYPE_INT_ARRAY, true, 0, MAX_WATCHDOG_NUM }, @@ -1472,7 +1464,7 @@ static struct config_int_array ConfigureNamesIntArray[] = }, { - {"other_pgpool_port", CFGCXT_RELOAD, WATCHDOG_CONFIG, + {"pgpool_port", CFGCXT_RELOAD, WATCHDOG_CONFIG, "tcp/ip pgpool port number of other pgpool node for watchdog connection.", CONFIG_VAR_TYPE_INT_ARRAY, true, 0, MAX_WATCHDOG_NUM }, @@ -1677,14 +1669,14 @@ static struct config_string_array ConfigureNamesStringArray[] = }, { - {"heartbeat_destination", CFGCXT_RELOAD, WATCHDOG_LIFECHECK, - "destination host for sending heartbeat signal.", + {"heartbeat_hostname", CFGCXT_RELOAD, WATCHDOG_LIFECHECK, + "Hostname for sending heartbeat signal.", CONFIG_VAR_TYPE_STRING_ARRAY, true, 0, WD_MAX_IF_NUM }, NULL, "", EMPTY_CONFIG_STRING, - HBDestinationAssignFunc, NULL, HBDestinationShowFunc, WdIFSlotEmptyCheckFunc + HBHostnameAssignFunc, NULL, HBHostnameShowFunc, WdIFSlotEmptyCheckFunc }, { @@ -1699,8 +1691,8 @@ static struct config_string_array ConfigureNamesStringArray[] = }, { - {"other_pgpool_hostname", CFGCXT_RELOAD, WATCHDOG_LIFECHECK, - "Hostname of other pgpool node for watchdog connection.", + {"hostname", CFGCXT_RELOAD, WATCHDOG_LIFECHECK, + "Hostname of pgpool node for watchdog connection.", CONFIG_VAR_TYPE_STRING_ARRAY, true, 0, MAX_WATCHDOG_NUM }, NULL, @@ -1942,17 +1934,6 @@ static struct config_int ConfigureNamesInt[] = }, { - {"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.", CONFIG_VAR_TYPE_INT, false, 0 @@ -1986,17 +1967,6 @@ static struct config_int ConfigureNamesInt[] = }, { - {"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.", CONFIG_VAR_TYPE_INT, false, GUC_UNIT_S @@ -2531,11 +2501,11 @@ build_variable_groups(void) ConfigureVarGroups[1].var_count = 3; ConfigureVarGroups[1].var_list = palloc0(sizeof(struct config_generic *) * ConfigureVarGroups[1].var_count); /* backend hostname */ - ConfigureVarGroups[1].var_list[0] = find_option("other_pgpool_hostname", FATAL); + ConfigureVarGroups[1].var_list[0] = find_option("hostname", FATAL); ConfigureVarGroups[1].var_list[0]->flags |= VAR_PART_OF_GROUP; - ConfigureVarGroups[1].var_list[1] = find_option("other_pgpool_port", FATAL); + ConfigureVarGroups[1].var_list[1] = find_option("pgpool_port", FATAL); ConfigureVarGroups[1].var_list[1]->flags |= VAR_PART_OF_GROUP; - ConfigureVarGroups[1].var_list[2] = find_option("other_wd_port", FATAL); + ConfigureVarGroups[1].var_list[2] = find_option("wd_port", FATAL); ConfigureVarGroups[1].var_list[2]->flags |= VAR_PART_OF_GROUP; ConfigureVarGroups[1].gen.max_elements = ConfigureVarGroups[1].var_list[0]->max_elements; @@ -2546,9 +2516,9 @@ build_variable_groups(void) /* backend hostname */ ConfigureVarGroups[2].var_list[0] = find_option("heartbeat_device", FATAL); ConfigureVarGroups[2].var_list[0]->flags |= VAR_PART_OF_GROUP; - ConfigureVarGroups[2].var_list[1] = find_option("heartbeat_destination", FATAL); + ConfigureVarGroups[2].var_list[1] = find_option("heartbeat_hostname", FATAL); ConfigureVarGroups[2].var_list[1]->flags |= VAR_PART_OF_GROUP; - ConfigureVarGroups[2].var_list[2] = find_option("heartbeat_destination_port", FATAL); + ConfigureVarGroups[2].var_list[2] = find_option("heartbeat_port", FATAL); ConfigureVarGroups[2].var_list[2]->flags |= VAR_PART_OF_GROUP; ConfigureVarGroups[2].gen.max_elements = ConfigureVarGroups[2].var_list[0]->max_elements; @@ -4338,50 +4308,50 @@ BackendSlotEmptyCheckFunc(int index) static bool WdSlotEmptyCheckFunc(int index) { - return (g_pool_config.wd_remote_nodes.wd_remote_node_info[index].pgpool_port == 0); + return (g_pool_config.wd_nodes.wd_node_info[index].pgpool_port == 0); } static bool WdIFSlotEmptyCheckFunc(int index) { - return (index >= g_pool_config.num_hb_if); + return (index >= g_pool_config.num_hb_dest_if); } static const char * OtherPPHostShowFunc(int index) { - return g_pool_config.wd_remote_nodes.wd_remote_node_info[index].hostname; + return g_pool_config.wd_nodes.wd_node_info[index].hostname; } static const char * OtherPPPortShowFunc(int index) { - return IntValueShowFunc(g_pool_config.wd_remote_nodes.wd_remote_node_info[index].pgpool_port); + return IntValueShowFunc(g_pool_config.wd_nodes.wd_node_info[index].pgpool_port); } static const char * OtherWDPortShowFunc(int index) { - return IntValueShowFunc(g_pool_config.wd_remote_nodes.wd_remote_node_info[index].wd_port); + return IntValueShowFunc(g_pool_config.wd_nodes.wd_node_info[index].wd_port); } static const char * HBDeviceShowFunc(int index) { - return g_pool_config.hb_if[index].if_name; + return g_pool_config.hb_ifs[index].if_name; } static const char * -HBDestinationShowFunc(int index) +HBHostnameShowFunc(int index) { - return g_pool_config.hb_if[index].addr; + return g_pool_config.hb_ifs[index].addr; } static const char * HBDestinationPortShowFunc(int index) { - return IntValueShowFunc(g_pool_config.hb_if[index].dest_port); + return IntValueShowFunc(g_pool_config.hb_ifs[index].dest_port); } static const char * @@ -4505,31 +4475,31 @@ HealthCheckDatabaseAssignFunc(ConfigContext context, char *newval, int index, in return true; } -/* Watchdog Assign functions */ -/*other_pgpool_hostname*/ +/* Watchdog hostname and heartbeat hostname assign functions */ +/* hostname */ static bool OtherPPHostAssignFunc(ConfigContext context, char *newval, int index, int elevel) { if (newval == NULL || strlen(newval) == 0) - g_pool_config.wd_remote_nodes.wd_remote_node_info[index].hostname[0] = '\0'; + g_pool_config.wd_nodes.wd_node_info[index].hostname[0] = '\0'; else - strlcpy(g_pool_config.wd_remote_nodes.wd_remote_node_info[index].hostname, newval, MAX_DB_HOST_NAMELEN - 1); + strlcpy(g_pool_config.wd_nodes.wd_node_info[index].hostname, newval, MAX_DB_HOST_NAMELEN - 1); return true; } -/*other_pgpool_port*/ +/* pgpool_port */ static bool OtherPPPortAssignFunc(ConfigContext context, int newval, int index, int elevel) { - g_pool_config.wd_remote_nodes.wd_remote_node_info[index].pgpool_port = newval; + g_pool_config.wd_nodes.wd_node_info[index].pgpool_port = newval; return true; } -/*other_wd_port*/ +/* wd_port */ static bool OtherWDPortAssignFunc(ConfigContext context, int newval, int index, int elevel) { - g_pool_config.wd_remote_nodes.wd_remote_node_info[index].wd_port = newval; + g_pool_config.wd_nodes.wd_node_info[index].wd_port = newval; return true; } @@ -4538,28 +4508,28 @@ static bool HBDeviceAssignFunc(ConfigContext context, char *newval, int index, int elevel) { if (newval == NULL || strlen(newval) == 0) - g_pool_config.hb_if[index].if_name[0] = '\0'; + g_pool_config.hb_ifs[index].if_name[0] = '\0'; else - strlcpy(g_pool_config.hb_if[index].if_name, newval, WD_MAX_IF_NAME_LEN); + strlcpy(g_pool_config.hb_ifs[index].if_name, newval, WD_MAX_IF_NAME_LEN - 1); return true; } -/*heartbeat_destination*/ +/*heartbeat_hostname*/ static bool -HBDestinationAssignFunc(ConfigContext context, char *newval, int index, int elevel) +HBHostnameAssignFunc(ConfigContext context, char *newval, int index, int elevel) { if (newval == NULL || strlen(newval) == 0) - g_pool_config.hb_if[index].addr[0] = '\0'; + g_pool_config.hb_ifs[index].addr[0] = '\0'; else - strlcpy(g_pool_config.hb_if[index].addr, newval, WD_MAX_HOST_NAMELEN - 1); + strlcpy(g_pool_config.hb_ifs[index].addr, newval, WD_MAX_HOST_NAMELEN - 1); return true; } -/*heartbeat_destination_port*/ +/*heartbeat_port*/ static bool HBDestinationPortAssignFunc(ConfigContext context, int newval, int index, int elevel) { - g_pool_config.hb_if[index].dest_port = newval; + g_pool_config.hb_ifs[index].dest_port = newval; return true; } @@ -4618,9 +4588,12 @@ check_redirect_node_spec(char *node_spec) static bool config_post_processor(ConfigContext context, int elevel) { - double total_weight = 0.0; + double total_weight = 0.0; sig_atomic_t local_num_backends = 0; - int i; + int i; + + /* read from pgpool_node_id */ + SetPgpoolNodeId(elevel); if (context == CFGCXT_BOOT) { @@ -4634,7 +4607,7 @@ config_post_processor(ConfigContext context, int elevel) errdetail("failed to get the local hostname"))); return false; } - g_pool_config.wd_hostname = pstrdup(localhostname); + strcpy(g_pool_config.wd_nodes.wd_node_info[g_pool_config.pgpool_node_id].hostname, localhostname); return true; } for (i = 0; i < MAX_CONNECTION_SLOTS; i++) @@ -4695,23 +4668,17 @@ config_post_processor(ConfigContext context, int elevel) } /* Set the number of configured Watchdog nodes */ - g_pool_config.wd_remote_nodes.num_wd = 0; + g_pool_config.wd_nodes.num_wd = 0; for (i = 0; i < MAX_WATCHDOG_NUM; i++) { - WdRemoteNodeInfo *wdNode = &g_pool_config.wd_remote_nodes.wd_remote_node_info[i]; + WdNodeInfo *wdNode = &g_pool_config.wd_nodes.wd_node_info[i]; if (wdNode->wd_port > 0) - g_pool_config.wd_remote_nodes.num_wd = i + 1; - } - - /* 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; + g_pool_config.wd_nodes.num_wd = i + 1; } + /* Set configured heartbeat destination interfaces */ + SetHBDestIfFunc(elevel); if (strcmp(pool_config->recovery_1st_stage_command, "") || strcmp(pool_config->recovery_2nd_stage_command, "")) @@ -4914,6 +4881,135 @@ MakeDBRedirectListRegex(char *newval, int elevel) return true; } +/* Read the pgpool_node_id file */ +static bool +SetPgpoolNodeId(int elevel) +{ + char pgpool_node_id_file[POOLMAXPATHLEN + 1]; + FILE *fd; + int length; + + if (g_pool_config.use_watchdog) + { + snprintf(pgpool_node_id_file, sizeof(pgpool_node_id_file), "%s/%s", config_file_dir, NODE_ID_FILE_NAME); + +#define MAXLINE 10 + char readbuf[MAXLINE]; + + fd = fopen(pgpool_node_id_file, "r"); + if (!fd) + ereport(elevel, + (errmsg("Pgpool node id file %s does not exist", pgpool_node_id_file), + errdetail("If watchdog is enable, pgpool_node_id file is required"))); + + readbuf[MAXLINE - 1] = '\0'; + if (fgets(readbuf, MAXLINE - 1, fd) == 0) + { + ereport(elevel, + (errmsg("pgpool_node_id file is empty"), + errdetail("If watchdog is enable, we need to specify pgpool node id in %s file", pgpool_node_id_file))); + } + + length = strlen(readbuf); + if (length > 0 && readbuf[length - 1] == '\n') + readbuf[length - 1] = '\0'; + + g_pool_config.pgpool_node_id = atoi(readbuf); + + if (g_pool_config.pgpool_node_id < 0 || g_pool_config.pgpool_node_id > MAX_WATCHDOG_NUM) + ereport(elevel, + (errmsg("Invalid pgpool node id \"%d\", must be between 0 and %d", + g_pool_config.pgpool_node_id, MAX_WATCHDOG_NUM))); + else + ereport(DEBUG1, + (errmsg("read pgpool node id file %s", pgpool_node_id_file), + errdetail("pgpool node id: %s", readbuf))); + } + + return true; +} + +/* Set configured heartbeat destination interfaces */ +static bool +SetHBDestIfFunc(int elevel) +{ + int idx = 0; + char **addrs; + char **if_names; + int i, j, + n_addr, + n_if_name; + + g_pool_config.num_hb_dest_if = 0; + + if (g_pool_config.wd_lifecheck_method != LIFECHECK_BY_HB) + { + return true; + } + + /* + * g_pool_config.hb_ifs is the information for sending/receiving heartbeat + * for all nodes specied in pgpool.conf. + * If it is local pgpool node information, set dest_port to g_pool_config.wd_heartbeat_port + * and ignore addr and if_name. + * g_pool_config.hb_dest_if is the heartbeat destination information. + */ + for (i = 0; i < WD_MAX_IF_NUM; i++) + { + if (g_pool_config.hb_ifs[i].dest_port > 0) + { + /* Ignore local pgpool node */ + if (i == g_pool_config.pgpool_node_id) + { + g_pool_config.wd_heartbeat_port = g_pool_config.hb_ifs[i].dest_port; + continue; + } + + WdHbIf *hbNodeInfo = &g_pool_config.hb_ifs[i]; + + addrs = get_list_from_string(hbNodeInfo->addr, ";", &n_addr); + if_names = get_list_from_string(hbNodeInfo->if_name, ";", &n_if_name); + + if (!addrs || n_addr < 0) + { + g_pool_config.hb_dest_if[idx].addr[0] = '\0'; + + if (addrs) + pfree(addrs); + + ereport(elevel, + (errmsg("invalid watchdog configuration"), + errdetail("heartbeat_hostname%d is not defined", i))); + + return false; + } + + for (j = 0; j < n_addr; j++) + { + strlcpy(g_pool_config.hb_dest_if[idx].addr, addrs[j], WD_MAX_HOST_NAMELEN - 1); + g_pool_config.hb_dest_if[idx].dest_port = hbNodeInfo->dest_port; + if (n_if_name > j + 1) + { + strlcpy(g_pool_config.hb_dest_if[idx].if_name, if_names[j], WD_MAX_IF_NAME_LEN - 1); + pfree(if_names[j]); + } + else + g_pool_config.hb_dest_if[idx].if_name[0] = '\0'; + + g_pool_config.num_hb_dest_if = idx + 1; + idx++; + pfree(addrs[j]); + } + + if (addrs) + pfree(addrs); + if (if_names) + pfree(if_names); + } + } + return true; +} + static struct config_generic * get_index_free_record_if_any(struct config_generic *record) { diff --git a/src/include/pool.h b/src/include/pool.h index c3ff2ec..1aa44d3 100644 --- a/src/include/pool.h +++ b/src/include/pool.h @@ -86,6 +86,9 @@ /* default string used to identify pgpool on syslog output */ #define DEFAULT_SYSLOG_IDENT "pgpool" +/* Pgpool node id file name */ +#define NODE_ID_FILE_NAME "pgpool_node_id" + /* function return codes */ #define GENERAL_ERROR (-1) #define RETRY (-2) diff --git a/src/include/pool_config.h b/src/include/pool_config.h index abcd2b3..524971b 100644 --- a/src/include/pool_config.h +++ b/src/include/pool_config.h @@ -130,18 +130,18 @@ typedef enum CHECK_TEMP_TABLE_OPTION /* * watchdog list */ -typedef struct WdRemoteNodeInfo +typedef struct WdNodeInfo { char hostname[WD_MAX_HOST_NAMELEN]; /* host name */ int pgpool_port; /* pgpool port */ int wd_port; /* watchdog port */ -} WdRemoteNodeInfo; +} WdNodeInfo; -typedef struct WdRemoteNodesConfig +typedef struct WdNodesConfig { int num_wd; /* number of watchdogs */ - WdRemoteNodeInfo wd_remote_node_info[MAX_WATCHDOG_NUM]; -} WdRemoteNodesConfig; + WdNodeInfo wd_node_info[MAX_WATCHDOG_NUM]; +} WdNodesConfig; typedef struct @@ -151,8 +151,8 @@ typedef struct int dest_port; } WdHbIf; -#define WD_INFO(wd_id) (pool_config->wd_remote_nodes.wd_remote_node_info[(wd_id)]) -#define WD_HB_IF(if_id) (pool_config->hb_if[(if_id)]) +#define WD_INFO(wd_id) (pool_config->wd_nodes.wd_node_info[(wd_id)]) +#define WD_HB_IF(if_id) (pool_config->hb_dest_if[(if_id)]) /* * Per node health check parameters @@ -543,11 +543,10 @@ typedef struct * on new active pgpool. */ char *wd_de_escalation_command; /* Executes this command when * master pgpool goes down. */ - char *wd_hostname; /* watchdog hostname */ - int wd_port; /* watchdog port */ int wd_priority; /* watchdog node priority, during leader * election */ - WdRemoteNodesConfig wd_remote_nodes; /* watchdog lists */ + int pgpool_node_id; /* pgpool (watchdog) node id */ + WdNodesConfig wd_nodes; /* watchdog lists */ char *trusted_servers; /* icmp reachable server list (A,B,C) */ char *delegate_IP; /* delegate IP address */ int wd_interval; /* lifecheck interval (sec) */ @@ -570,14 +569,16 @@ typedef struct * signal (sec) */ int wd_heartbeat_deadtime; /* Deadtime interval for heartbeat * signal (sec) */ - WdHbIf hb_if[WD_MAX_IF_NUM]; /* interface devices */ - int num_hb_if; /* number of interface devices */ + WdHbIf hb_ifs[WD_MAX_IF_NUM]; /* heartbeat interfaces of all watchdog nodes */ + WdHbIf hb_dest_if[WD_MAX_IF_NUM]; /* heartbeat destination interfaces */ + int num_hb_dest_if; /* number of interface devices */ char **wd_monitoring_interfaces_list; /* network interface name list * to be monitored by watchdog */ } POOL_CONFIG; extern POOL_CONFIG * pool_config; +extern char *config_file_dir; /* directory path of config file pgpool.conf */ typedef enum { diff --git a/src/sample/pgpool.conf.sample-logical b/src/sample/pgpool.conf.sample-logical index dff0276..2f9a18b 100644 --- a/src/sample/pgpool.conf.sample-logical +++ b/src/sample/pgpool.conf.sample-logical @@ -590,12 +590,25 @@ ping_path = '/bin' # - Watchdog communication Settings - -wd_hostname = '' - # Host name or IP address of this watchdog +hostname0 = '' + # Host name or IP address of pgpool node + # for watchdog connection # (change requires restart) -wd_port = 9000 - # port number for watchdog service +wd_port0 = 9000 + # Port number for watchdog service # (change requires restart) +pgpool_port0 = 9999 + # Port number for pgpool + # (change requires restart) + +#hostname1 = '' +#wd_port1 = 9000 +#pgpool_port1 = 9999 + +#wd_hostname2 = '' +#wd_port2 = 9000 +#pgpool_port2 = 9999 + wd_priority = 1 # priority of this watchdog in leader election # (change requires restart) @@ -693,23 +706,13 @@ wd_interval = 10 # -- heartbeat mode -- -wd_heartbeat_port = 9694 - # Port number for receiving heartbeat signal - # (change requires restart) -wd_heartbeat_keepalive = 2 - # Interval time of sending heartbeat signal (sec) - # (change requires restart) -wd_heartbeat_deadtime = 30 - # Deadtime interval for heartbeat signal (sec) - # (change requires restart) -heartbeat_destination0 = 'host0_ip1' - # Host name or IP address of destination 0 +heartbeat_hostname0 = '' + # Host name or IP address used # for sending heartbeat signal. # (change requires restart) -heartbeat_destination_port0 = 9694 - # Port number of destination 0 for sending - # heartbeat signal. Usually this is the - # same as wd_heartbeat_port. +heartbeat_port0 = 9694 + # Port number used for receiving/sending heartbeat signal + # Usually this is the same as heartbeat_portX. # (change requires restart) heartbeat_device0 = '' # Name of NIC device (such like 'eth0') @@ -719,9 +722,19 @@ heartbeat_device0 = '' # and pgpool has root privilege. # (change requires restart) -#heartbeat_destination1 = 'host0_ip2' -#heartbeat_destination_port1 = 9694 +#heartbeat_hostname1 = '' +#heartbeat_port1 = 9694 #heartbeat_device1 = '' +#heartbeat_hostname2 = '' +#heartbeat_port2 = 9694 +#heartbeat_device2 = '' + +wd_heartbeat_keepalive = 2 + # Interval time of sending heartbeat signal (sec) + # (change requires restart) +wd_heartbeat_deadtime = 30 + # Deadtime interval for heartbeat signal (sec) + # (change requires restart) # -- query mode -- diff --git a/src/sample/pgpool.conf.sample-raw b/src/sample/pgpool.conf.sample-raw index 4af69a7..5cbb26f 100644 --- a/src/sample/pgpool.conf.sample-raw +++ b/src/sample/pgpool.conf.sample-raw @@ -622,12 +622,25 @@ ping_path = '/bin' # - Watchdog communication Settings - -wd_hostname = '' - # Host name or IP address of this watchdog +hostname0 = '' + # Host name or IP address of pgpool node + # for watchdog connection # (change requires restart) -wd_port = 9000 - # port number for watchdog service +wd_port0 = 9000 + # Port number for watchdog service # (change requires restart) +pgpool_port0 = 9999 + # Port number for pgpool + # (change requires restart) + +#hostname1 = '' +#wd_port1 = 9000 +#pgpool_port1 = 9999 + +#wd_hostname2 = '' +#wd_port2 = 9000 +#pgpool_port2 = 9999 + wd_priority = 1 # priority of this watchdog in leader election # (change requires restart) @@ -642,7 +655,6 @@ wd_ipc_socket_dir = '/tmp' # /var/run/postgresql # (change requires restart) - # - Virtual IP control Setting - delegate_IP = '' @@ -731,23 +743,13 @@ wd_interval = 10 # -- heartbeat mode -- -wd_heartbeat_port = 9694 - # Port number for receiving heartbeat signal - # (change requires restart) -wd_heartbeat_keepalive = 2 - # Interval time of sending heartbeat signal (sec) - # (change requires restart) -wd_heartbeat_deadtime = 30 - # Deadtime interval for heartbeat signal (sec) - # (change requires restart) -heartbeat_destination0 = 'host0_ip1' - # Host name or IP address of destination 0 +heartbeat_hostname0 = '' + # Host name or IP address used # for sending heartbeat signal. # (change requires restart) -heartbeat_destination_port0 = 9694 - # Port number of destination 0 for sending - # heartbeat signal. Usually this is the - # same as wd_heartbeat_port. +heartbeat_port0 = 9694 + # Port number used for receiving/sending heartbeat signal + # Usually this is the same as heartbeat_portX. # (change requires restart) heartbeat_device0 = '' # Name of NIC device (such like 'eth0') @@ -757,9 +759,19 @@ heartbeat_device0 = '' # and pgpool has root privilege. # (change requires restart) -#heartbeat_destination1 = 'host0_ip2' -#heartbeat_destination_port1 = 9694 +#heartbeat_hostname1 = '' +#heartbeat_port1 = 9694 #heartbeat_device1 = '' +#heartbeat_hostname2 = '' +#heartbeat_port2 = 9694 +#heartbeat_device2 = '' + +wd_heartbeat_keepalive = 2 + # Interval time of sending heartbeat signal (sec) + # (change requires restart) +wd_heartbeat_deadtime = 30 + # Deadtime interval for heartbeat signal (sec) + # (change requires restart) # -- query mode -- diff --git a/src/sample/pgpool.conf.sample-replication b/src/sample/pgpool.conf.sample-replication index dac3134..2df7162 100644 --- a/src/sample/pgpool.conf.sample-replication +++ b/src/sample/pgpool.conf.sample-replication @@ -632,12 +632,24 @@ ping_path = '/bin' # - Watchdog communication Settings - -wd_hostname = '' - # Host name or IP address of this watchdog +hostname0 = '' + # Host name or IP address of pgpool node + # for watchdog connection # (change requires restart) -wd_port = 9000 - # port number for watchdog service +wd_port0 = 9000 + # Port number for watchdog service # (change requires restart) +pgpool_port0 = 9999 + # Port number for pgpool + # (change requires restart) + +#hostname1 = '' +#wd_port1 = 9000 +#pgpool_port1 = 9999 + +#wd_hostname2 = '' +#wd_port2 = 9000 +#pgpool_port2 = 9999 wd_priority = 1 # priority of this watchdog in leader election @@ -744,23 +756,13 @@ wd_interval = 10 # -- heartbeat mode -- -wd_heartbeat_port = 9694 - # Port number for receiving heartbeat signal - # (change requires restart) -wd_heartbeat_keepalive = 2 - # Interval time of sending heartbeat signal (sec) - # (change requires restart) -wd_heartbeat_deadtime = 30 - # Deadtime interval for heartbeat signal (sec) - # (change requires restart) -heartbeat_destination0 = 'host0_ip1' - # Host name or IP address of destination 0 +heartbeat_hostname0 = '' + # Host name or IP address used # for sending heartbeat signal. # (change requires restart) -heartbeat_destination_port0 = 9694 - # Port number of destination 0 for sending - # heartbeat signal. Usually this is the - # same as wd_heartbeat_port. +heartbeat_port0 = 9694 + # Port number used for receiving/sending heartbeat signal + # Usually this is the same as heartbeat_portX. # (change requires restart) heartbeat_device0 = '' # Name of NIC device (such like 'eth0') @@ -770,9 +772,19 @@ heartbeat_device0 = '' # and pgpool has root privilege. # (change requires restart) -#heartbeat_destination1 = 'host0_ip2' -#heartbeat_destination_port1 = 9694 +#heartbeat_hostname1 = '' +#heartbeat_port1 = 9694 #heartbeat_device1 = '' +#heartbeat_hostname2 = '' +#heartbeat_port2 = 9694 +#heartbeat_device2 = '' + +wd_heartbeat_keepalive = 2 + # Interval time of sending heartbeat signal (sec) + # (change requires restart) +wd_heartbeat_deadtime = 30 + # Deadtime interval for heartbeat signal (sec) + # (change requires restart) # -- query mode -- diff --git a/src/sample/pgpool.conf.sample-slony b/src/sample/pgpool.conf.sample-slony index d600dfc..f24c09f 100644 --- a/src/sample/pgpool.conf.sample-slony +++ b/src/sample/pgpool.conf.sample-slony @@ -623,12 +623,25 @@ ping_path = '/bin' # - Watchdog communication Settings - -wd_hostname = '' - # Host name or IP address of this watchdog +hostname0 = '' + # Host name or IP address of pgpool node + # for watchdog connection # (change requires restart) -wd_port = 9000 - # port number for watchdog service +wd_port0 = 9000 + # Port number for watchdog service # (change requires restart) +pgpool_port0 = 9999 + # Port number for pgpool + # (change requires restart) + +#hostname1 = '' +#wd_port1 = 9000 +#pgpool_port1 = 9999 + +#wd_hostname2 = '' +#wd_port2 = 9000 +#pgpool_port2 = 9999 + wd_priority = 1 # priority of this watchdog in leader election # (change requires restart) @@ -732,23 +745,13 @@ wd_interval = 10 # -- heartbeat mode -- -wd_heartbeat_port = 9694 - # Port number for receiving heartbeat signal - # (change requires restart) -wd_heartbeat_keepalive = 2 - # Interval time of sending heartbeat signal (sec) - # (change requires restart) -wd_heartbeat_deadtime = 30 - # Deadtime interval for heartbeat signal (sec) - # (change requires restart) -heartbeat_destination0 = 'host0_ip1' - # Host name or IP address of destination 0 +heartbeat_hostname0 = '' + # Host name or IP address used # for sending heartbeat signal. # (change requires restart) -heartbeat_destination_port0 = 9694 - # Port number of destination 0 for sending - # heartbeat signal. Usually this is the - # same as wd_heartbeat_port. +heartbeat_port0 = 9694 + # Port number used for receiving/sending heartbeat signal + # Usually this is the same as heartbeat_portX. # (change requires restart) heartbeat_device0 = '' # Name of NIC device (such like 'eth0') @@ -758,9 +761,19 @@ heartbeat_device0 = '' # and pgpool has root privilege. # (change requires restart) -#heartbeat_destination1 = 'host0_ip2' -#heartbeat_destination_port1 = 9694 +#heartbeat_hostname1 = '' +#heartbeat_port1 = 9694 #heartbeat_device1 = '' +#heartbeat_hostname2 = '' +#heartbeat_port2 = 9694 +#heartbeat_device2 = '' + +wd_heartbeat_keepalive = 2 + # Interval time of sending heartbeat signal (sec) + # (change requires restart) +wd_heartbeat_deadtime = 30 + # Deadtime interval for heartbeat signal (sec) + # (change requires restart) # -- query mode -- diff --git a/src/sample/pgpool.conf.sample-snapshot b/src/sample/pgpool.conf.sample-snapshot index aae37cd..8e891e3 100644 --- a/src/sample/pgpool.conf.sample-snapshot +++ b/src/sample/pgpool.conf.sample-snapshot @@ -632,12 +632,24 @@ ping_path = '/bin' # - Watchdog communication Settings - -wd_hostname = '' - # Host name or IP address of this watchdog +hostname0 = '' + # Host name or IP address of pgpool node + # for watchdog connection # (change requires restart) -wd_port = 9000 - # port number for watchdog service +wd_port0 = 9000 + # Port number for watchdog service # (change requires restart) +pgpool_port0 = 9999 + # Port number for pgpool + # (change requires restart) + +#hostname1 = '' +#wd_port1 = 9000 +#pgpool_port1 = 9999 + +#wd_hostname2 = '' +#wd_port2 = 9000 +#pgpool_port2 = 9999 wd_priority = 1 # priority of this watchdog in leader election @@ -744,23 +756,13 @@ wd_interval = 10 # -- heartbeat mode -- -wd_heartbeat_port = 9694 - # Port number for receiving heartbeat signal - # (change requires restart) -wd_heartbeat_keepalive = 2 - # Interval time of sending heartbeat signal (sec) - # (change requires restart) -wd_heartbeat_deadtime = 30 - # Deadtime interval for heartbeat signal (sec) - # (change requires restart) -heartbeat_destination0 = 'host0_ip1' - # Host name or IP address of destination 0 +heartbeat_hostname0 = '' + # Host name or IP address used # for sending heartbeat signal. # (change requires restart) -heartbeat_destination_port0 = 9694 - # Port number of destination 0 for sending - # heartbeat signal. Usually this is the - # same as wd_heartbeat_port. +heartbeat_port0 = 9694 + # Port number used for receiving/sending heartbeat signal + # Usually this is the same as heartbeat_portX. # (change requires restart) heartbeat_device0 = '' # Name of NIC device (such like 'eth0') @@ -770,9 +772,19 @@ heartbeat_device0 = '' # and pgpool has root privilege. # (change requires restart) -#heartbeat_destination1 = 'host0_ip2' -#heartbeat_destination_port1 = 9694 +#heartbeat_hostname1 = '' +#heartbeat_port1 = 9694 #heartbeat_device1 = '' +#heartbeat_hostname2 = '' +#heartbeat_port2 = 9694 +#heartbeat_device2 = '' + +wd_heartbeat_keepalive = 2 + # Interval time of sending heartbeat signal (sec) + # (change requires restart) +wd_heartbeat_deadtime = 30 + # Deadtime interval for heartbeat signal (sec) + # (change requires restart) # -- query mode -- @@ -794,22 +806,6 @@ wd_lifecheck_password = '' # Password in pool_passwd file before using the empty password # (change requires restart) -# - Other pgpool Connection Settings - - -#other_pgpool_hostname0 = 'host0' - # Host name or IP address to connect to for other pgpool 0 - # (change requires restart) -#other_pgpool_port0 = 5432 - # Port number for other pgpool 0 - # (change requires restart) -#other_wd_port0 = 9000 - # Port number for other watchdog 0 - # (change requires restart) -#other_pgpool_hostname1 = 'host1' -#other_pgpool_port1 = 5432 -#other_wd_port1 = 9000 - - #------------------------------------------------------------------------------ # OTHERS #------------------------------------------------------------------------------ diff --git a/src/sample/pgpool.conf.sample-stream b/src/sample/pgpool.conf.sample-stream index 48e0a28..3c98139 100644 --- a/src/sample/pgpool.conf.sample-stream +++ b/src/sample/pgpool.conf.sample-stream @@ -624,12 +624,25 @@ ping_path = '/bin' # - Watchdog communication Settings - -wd_hostname = '' - # Host name or IP address of this watchdog +hostname0 = '' + # Host name or IP address of pgpool node + # for watchdog connection # (change requires restart) -wd_port = 9000 - # port number for watchdog service +wd_port0 = 9000 + # Port number for watchdog service # (change requires restart) +pgpool_port0 = 9999 + # Port number for pgpool + # (change requires restart) + +#hostname1 = '' +#wd_port1 = 9000 +#pgpool_port1 = 9999 + +#wd_hostname2 = '' +#wd_port2 = 9000 +#pgpool_port2 = 9999 + wd_priority = 1 # priority of this watchdog in leader election # (change requires restart) @@ -733,23 +746,13 @@ wd_interval = 10 # -- heartbeat mode -- -wd_heartbeat_port = 9694 - # Port number for receiving heartbeat signal - # (change requires restart) -wd_heartbeat_keepalive = 2 - # Interval time of sending heartbeat signal (sec) - # (change requires restart) -wd_heartbeat_deadtime = 30 - # Deadtime interval for heartbeat signal (sec) - # (change requires restart) -heartbeat_destination0 = 'host0_ip1' - # Host name or IP address of destination 0 +heartbeat_hostname0 = '' + # Host name or IP address used # for sending heartbeat signal. # (change requires restart) -heartbeat_destination_port0 = 9694 - # Port number of destination 0 for sending - # heartbeat signal. Usually this is the - # same as wd_heartbeat_port. +heartbeat_port0 = 9694 + # Port number used for receiving/sending heartbeat signal + # Usually this is the same as heartbeat_portX. # (change requires restart) heartbeat_device0 = '' # Name of NIC device (such like 'eth0') @@ -759,9 +762,19 @@ heartbeat_device0 = '' # and pgpool has root privilege. # (change requires restart) -#heartbeat_destination1 = 'host0_ip2' -#heartbeat_destination_port1 = 9694 +#heartbeat_hostname1 = '' +#heartbeat_port1 = 9694 #heartbeat_device1 = '' +#heartbeat_hostname2 = '' +#heartbeat_port2 = 9694 +#heartbeat_device2 = '' + +wd_heartbeat_keepalive = 2 + # Interval time of sending heartbeat signal (sec) + # (change requires restart) +wd_heartbeat_deadtime = 30 + # Deadtime interval for heartbeat signal (sec) + # (change requires restart) # -- query mode -- @@ -783,22 +796,6 @@ wd_lifecheck_password = '' # Password in pool_passwd file before using the empty password # (change requires restart) -# - Other pgpool Connection Settings - - -#other_pgpool_hostname0 = 'host0' - # Host name or IP address to connect to for other pgpool 0 - # (change requires restart) -#other_pgpool_port0 = 5432 - # Port number for other pgpool 0 - # (change requires restart) -#other_wd_port0 = 9000 - # Port number for other watchdog 0 - # (change requires restart) -#other_pgpool_hostname1 = 'host1' -#other_pgpool_port1 = 5432 -#other_wd_port1 = 9000 - - #------------------------------------------------------------------------------ # OTHERS #------------------------------------------------------------------------------ diff --git a/src/test/regression/tests/004.watchdog/master.conf b/src/test/regression/tests/004.watchdog/master.conf index f6bb682..a1d1464 100644 --- a/src/test/regression/tests/004.watchdog/master.conf +++ b/src/test/regression/tests/004.watchdog/master.conf @@ -2,15 +2,17 @@ use_watchdog = on wd_interval = 1 wd_priority = 2 -wd_hostname = 'localhost' -wd_port = 21004 -wd_heartbeat_port = 21005 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21105 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port0 = 11100 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11100 -other_wd_port0 = 21104 +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port01 = 21105 enable_consensus_with_half_votes = on diff --git a/src/test/regression/tests/004.watchdog/standby.conf b/src/test/regression/tests/004.watchdog/standby.conf index 5da1695..65c18da 100644 --- a/src/test/regression/tests/004.watchdog/standby.conf +++ b/src/test/regression/tests/004.watchdog/standby.conf @@ -4,14 +4,17 @@ pcp_port = 11105 use_watchdog = on wd_interval = 1 wd_priority = 1 -wd_hostname = 'localhost' -wd_port = 21104 -wd_heartbeat_port = 21105 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21005 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11000 -other_wd_port0 = 21004 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port0 = 11100 + +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port01 = 21105 enable_consensus_with_half_votes = on diff --git a/src/test/regression/tests/004.watchdog/test.sh b/src/test/regression/tests/004.watchdog/test.sh index b9489b5..599775d 100755 --- a/src/test/regression/tests/004.watchdog/test.sh +++ b/src/test/regression/tests/004.watchdog/test.sh @@ -27,6 +27,7 @@ cp -r etc ../$STANDBY_DIR/ source ./bashrc.ports cat ../master.conf >> etc/pgpool.conf +echo 0 > etc/pgpool_node_id ./startall wait_for_pgpool_startup @@ -43,6 +44,7 @@ echo -n "creating standby pgpool..." cat standby.conf >> $STANDBY_DIR/etc/pgpool.conf # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf echo "pid_file_name = '$PWD/pgpool2.pid'" >> $STANDBY_DIR/etc/pgpool.conf +echo 1 > $STANDBY_DIR/etc/pgpool_node_id # start the stnadby pgpool-II by hand $PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY_DIR/etc/pgpool.conf -F $STANDBY_DIR/etc/pcp.conf -a $STANDBY_DIR/etc/pool_hba.conf > $STANDBY_DIR/log/pgpool.log 2>&1 & diff --git a/src/test/regression/tests/011.watchdog_quorum_failover/master.conf b/src/test/regression/tests/011.watchdog_quorum_failover/master.conf index 289ca5a..a7d78c4 100644 --- a/src/test/regression/tests/011.watchdog_quorum_failover/master.conf +++ b/src/test/regression/tests/011.watchdog_quorum_failover/master.conf @@ -2,19 +2,20 @@ use_watchdog = on wd_interval = 1 wd_priority = 5 -wd_hostname = 'localhost' -wd_port = 21004 -wd_heartbeat_port = 21005 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21105 -heartbeat_destination1 = 'localhost' -heartbeat_destination_port1 = 21205 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port1 = 11100 +hostname2 = 'localhost' +wd_port2 = 21204 +pgpool_port2 = 11200 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11100 -other_wd_port0 = 21104 - -other_pgpool_hostname1 = 'localhost' -other_pgpool_port1 = 11200 -other_wd_port1 = 21204 +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port1 = 21105 +heartbeat_hostname2 = 'localhost' +heartbeat_port2 = 21205 diff --git a/src/test/regression/tests/011.watchdog_quorum_failover/standby.conf b/src/test/regression/tests/011.watchdog_quorum_failover/standby.conf index 120bcb0..012307b 100644 --- a/src/test/regression/tests/011.watchdog_quorum_failover/standby.conf +++ b/src/test/regression/tests/011.watchdog_quorum_failover/standby.conf @@ -4,19 +4,20 @@ pcp_port = 11105 use_watchdog = on wd_interval = 1 wd_priority = 3 -wd_hostname = 'localhost' -wd_port = 21104 -wd_heartbeat_port = 21105 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21005 -heartbeat_destination1 = 'localhost' -heartbeat_destination_port1 = 21205 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11000 -other_wd_port0 = 21004 - -other_pgpool_hostname1 = 'localhost' -other_pgpool_port1 = 11200 -other_wd_port1 = 21204 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port1 = 11100 +hostname2 = 'localhost' +wd_port2 = 21204 +pgpool_port2 = 11200 +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port1 = 21105 +heartbeat_hostname2 = 'localhost' +heartbeat_port2 = 21205 diff --git a/src/test/regression/tests/011.watchdog_quorum_failover/standby2.conf b/src/test/regression/tests/011.watchdog_quorum_failover/standby2.conf index d5da7ff..9025478 100644 --- a/src/test/regression/tests/011.watchdog_quorum_failover/standby2.conf +++ b/src/test/regression/tests/011.watchdog_quorum_failover/standby2.conf @@ -4,19 +4,20 @@ pcp_port = 11205 use_watchdog = on wd_interval = 1 wd_priority = 1 -wd_hostname = 'localhost' -wd_port = 21204 -wd_heartbeat_port = 21205 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21005 -heartbeat_destination1 = 'localhost' -heartbeat_destination_port1 = 21105 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11000 -other_wd_port0 = 21004 - -other_pgpool_hostname1 = 'localhost' -other_pgpool_port1 = 11100 -other_wd_port1 = 21104 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port1 = 11100 +hostname2 = 'localhost' +wd_port2 = 21204 +pgpool_port2 = 11200 +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port1 = 21105 +heartbeat_hostname2 = 'localhost' +heartbeat_port2 = 21205 diff --git a/src/test/regression/tests/011.watchdog_quorum_failover/test.sh b/src/test/regression/tests/011.watchdog_quorum_failover/test.sh index 431d888..74843aa 100755 --- a/src/test/regression/tests/011.watchdog_quorum_failover/test.sh +++ b/src/test/regression/tests/011.watchdog_quorum_failover/test.sh @@ -40,6 +40,7 @@ cp -r etc ../$STANDBY2_DIR/ source ./bashrc.ports cat ../master.conf >> etc/pgpool.conf +echo 0 > etc/pgpool_node_id ./startall wait_for_pgpool_startup @@ -57,6 +58,7 @@ cat standby.conf >> $STANDBY_DIR/etc/pgpool.conf # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf echo "pid_file_name = '$PWD/pgpool2.pid'" >> $STANDBY_DIR/etc/pgpool.conf echo "logdir = $STANDBY_DIR/log" >> $STANDBY_DIR/etc/pgpool.conf +echo 1 > $STANDBY_DIR/etc/pgpool_node_id # start the stnadby pgpool-II by hand $PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY_DIR/etc/pgpool.conf -F $STANDBY_DIR/etc/pcp.conf -a $STANDBY_DIR/etc/pool_hba.conf > $STANDBY_DIR/log/pgpool.log 2>&1 & @@ -68,6 +70,7 @@ cat standby2.conf >> $STANDBY2_DIR/etc/pgpool.conf # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf echo "pid_file_name = '$PWD/pgpool3.pid'" >> $STANDBY2_DIR/etc/pgpool.conf echo "logdir = $STANDBY2_DIR/log" >> $STANDBY2_DIR/etc/pgpool.conf +echo 2 > $STANDBY2_DIR/etc/pgpool_node_id # start the stnadby pgpool-II by hand $PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY2_DIR/etc/pgpool.conf -F $STANDBY2_DIR/etc/pcp.conf -a $STANDBY2_DIR/etc/pool_hba.conf > $STANDBY2_DIR/log/pgpool.log 2>&1 & diff --git a/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/master.conf b/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/master.conf index 0b83c71..37efa3d 100644 --- a/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/master.conf +++ b/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/master.conf @@ -6,19 +6,20 @@ failover_require_consensus = false allow_multiple_failover_requests_from_node = false wd_interval = 1 wd_priority = 5 -wd_hostname = 'localhost' -wd_port = 21004 -wd_heartbeat_port = 21005 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21105 -heartbeat_destination1 = 'localhost' -heartbeat_destination_port1 = 21205 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port1 = 11100 +hostname2 = 'localhost' +wd_port2 = 21204 +pgpool_port2 = 11200 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11100 -other_wd_port0 = 21104 - -other_pgpool_hostname1 = 'localhost' -other_pgpool_port1 = 11200 -other_wd_port1 = 21204 +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port1 = 21105 +heartbeat_hostname2 = 'localhost' +heartbeat_port2 = 21205 diff --git a/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/standby.conf b/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/standby.conf index e03412d..72b5ca0 100644 --- a/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/standby.conf +++ b/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/standby.conf @@ -8,19 +8,20 @@ failover_require_consensus = false allow_multiple_failover_requests_from_node = false wd_interval = 1 wd_priority = 3 -wd_hostname = 'localhost' -wd_port = 21104 -wd_heartbeat_port = 21105 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21005 -heartbeat_destination1 = 'localhost' -heartbeat_destination_port1 = 21205 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11000 -other_wd_port0 = 21004 - -other_pgpool_hostname1 = 'localhost' -other_pgpool_port1 = 11200 -other_wd_port1 = 21204 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port1 = 11100 +hostname2 = 'localhost' +wd_port2 = 21204 +pgpool_port2 = 11200 +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port1 = 21105 +heartbeat_hostname2 = 'localhost' +heartbeat_port2 = 21205 diff --git a/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/standby2.conf b/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/standby2.conf index f28bd9d..ae9a053 100644 --- a/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/standby2.conf +++ b/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/standby2.conf @@ -8,19 +8,20 @@ failover_require_consensus = false allow_multiple_failover_requests_from_node = false wd_interval = 1 wd_priority = 1 -wd_hostname = 'localhost' -wd_port = 21204 -wd_heartbeat_port = 21205 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21005 -heartbeat_destination1 = 'localhost' -heartbeat_destination_port1 = 21105 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11000 -other_wd_port0 = 21004 - -other_pgpool_hostname1 = 'localhost' -other_pgpool_port1 = 11100 -other_wd_port1 = 21104 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port1 = 11100 +hostname2 = 'localhost' +wd_port2 = 21204 +pgpool_port2 = 11200 +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port1 = 21105 +heartbeat_hostname2 = 'localhost' +heartbeat_port2 = 21205 diff --git a/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/test.sh b/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/test.sh index 6fa0620..819f5a2 100755 --- a/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/test.sh +++ b/src/test/regression/tests/012.watchdog_failover_when_quorum_exists/test.sh @@ -42,6 +42,7 @@ cp -r etc ../$STANDBY2_DIR/ source ./bashrc.ports cat ../master.conf >> etc/pgpool.conf +echo 0 > etc/pgpool_node_id ./startall wait_for_pgpool_startup @@ -59,6 +60,7 @@ cat standby.conf >> $STANDBY_DIR/etc/pgpool.conf # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf echo "pid_file_name = '$PWD/pgpool2.pid'" >> $STANDBY_DIR/etc/pgpool.conf echo "logdir = $STANDBY_DIR/log" >> $STANDBY_DIR/etc/pgpool.conf +echo 1 > $STANDBY_DIR/etc/pgpool_node_id # start the stnadby pgpool-II by hand #$PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY_DIR/etc/pgpool.conf -F $STANDBY_DIR/etc/pcp.conf -a $STANDBY_DIR/etc/pool_hba.conf > $STANDBY_DIR/log/pgpool.log 2>&1 & @@ -70,6 +72,7 @@ cat standby2.conf >> $STANDBY2_DIR/etc/pgpool.conf # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf echo "pid_file_name = '$PWD/pgpool3.pid'" >> $STANDBY2_DIR/etc/pgpool.conf echo "logdir = $STANDBY2_DIR/log" >> $STANDBY2_DIR/etc/pgpool.conf +echo 2 > $STANDBY2_DIR/etc/pgpool_node_id # start the stnadby pgpool-II by hand #$PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY2_DIR/etc/pgpool.conf -F $STANDBY2_DIR/etc/pcp.conf -a $STANDBY2_DIR/etc/pool_hba.conf > $STANDBY2_DIR/log/pgpool.log 2>&1 & diff --git a/src/test/regression/tests/013.watchdog_failover_require_consensus/master.conf b/src/test/regression/tests/013.watchdog_failover_require_consensus/master.conf index 58e6f4b..d8af08b 100644 --- a/src/test/regression/tests/013.watchdog_failover_require_consensus/master.conf +++ b/src/test/regression/tests/013.watchdog_failover_require_consensus/master.conf @@ -6,19 +6,20 @@ failover_require_consensus = true allow_multiple_failover_requests_from_node = false wd_interval = 1 wd_priority = 5 -wd_hostname = 'localhost' -wd_port = 21004 -wd_heartbeat_port = 21005 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21105 -heartbeat_destination1 = 'localhost' -heartbeat_destination_port1 = 21205 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port1 = 11100 +hostname2 = 'localhost' +wd_port2 = 21204 +pgpool_port2 = 11200 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11100 -other_wd_port0 = 21104 - -other_pgpool_hostname1 = 'localhost' -other_pgpool_port1 = 11200 -other_wd_port1 = 21204 +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port1 = 21105 +heartbeat_hostname2 = 'localhost' +heartbeat_port2 = 21205 diff --git a/src/test/regression/tests/013.watchdog_failover_require_consensus/standby.conf b/src/test/regression/tests/013.watchdog_failover_require_consensus/standby.conf index 710cbb7..8c8a14d 100644 --- a/src/test/regression/tests/013.watchdog_failover_require_consensus/standby.conf +++ b/src/test/regression/tests/013.watchdog_failover_require_consensus/standby.conf @@ -8,19 +8,20 @@ failover_require_consensus = true allow_multiple_failover_requests_from_node = false wd_interval = 1 wd_priority = 3 -wd_hostname = 'localhost' -wd_port = 21104 -wd_heartbeat_port = 21105 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21005 -heartbeat_destination1 = 'localhost' -heartbeat_destination_port1 = 21205 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11000 -other_wd_port0 = 21004 - -other_pgpool_hostname1 = 'localhost' -other_pgpool_port1 = 11200 -other_wd_port1 = 21204 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port1 = 11100 +hostname2 = 'localhost' +wd_port2 = 21204 +pgpool_port2 = 11200 +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port1 = 21105 +heartbeat_hostname2 = 'localhost' +heartbeat_port2 = 21205 diff --git a/src/test/regression/tests/013.watchdog_failover_require_consensus/standby2.conf b/src/test/regression/tests/013.watchdog_failover_require_consensus/standby2.conf index f447141..f094054 100644 --- a/src/test/regression/tests/013.watchdog_failover_require_consensus/standby2.conf +++ b/src/test/regression/tests/013.watchdog_failover_require_consensus/standby2.conf @@ -8,19 +8,20 @@ failover_require_consensus = true allow_multiple_failover_requests_from_node = false wd_interval = 1 wd_priority = 1 -wd_hostname = 'localhost' -wd_port = 21204 -wd_heartbeat_port = 21205 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21005 -heartbeat_destination1 = 'localhost' -heartbeat_destination_port1 = 21105 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11000 -other_wd_port0 = 21004 - -other_pgpool_hostname1 = 'localhost' -other_pgpool_port1 = 11100 -other_wd_port1 = 21104 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port1 = 11100 +hostname2 = 'localhost' +wd_port2 = 21204 +pgpool_port2 = 11200 +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port1 = 21105 +heartbeat_hostname2 = 'localhost' +heartbeat_port2 = 21205 diff --git a/src/test/regression/tests/013.watchdog_failover_require_consensus/test.sh b/src/test/regression/tests/013.watchdog_failover_require_consensus/test.sh index f424983..f0c77b5 100755 --- a/src/test/regression/tests/013.watchdog_failover_require_consensus/test.sh +++ b/src/test/regression/tests/013.watchdog_failover_require_consensus/test.sh @@ -42,6 +42,7 @@ cp -r etc ../$STANDBY2_DIR/ source ./bashrc.ports cat ../master.conf >> etc/pgpool.conf +echo 0 > etc/pgpool_node_id ./startall wait_for_pgpool_startup @@ -59,6 +60,7 @@ cat standby.conf >> $STANDBY_DIR/etc/pgpool.conf # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf echo "pid_file_name = '$PWD/pgpool2.pid'" >> $STANDBY_DIR/etc/pgpool.conf echo "logdir = $STANDBY_DIR/log" >> $STANDBY_DIR/etc/pgpool.conf +echo 1 > $STANDBY_DIR/etc/pgpool_node_id # start the stnadby pgpool-II by hand $PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY_DIR/etc/pgpool.conf -F $STANDBY_DIR/etc/pcp.conf -a $STANDBY_DIR/etc/pool_hba.conf > $STANDBY_DIR/log/pgpool.log 2>&1 & @@ -69,6 +71,7 @@ cat standby2.conf >> $STANDBY2_DIR/etc/pgpool.conf # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf echo "pid_file_name = '$PWD/pgpool3.pid'" >> $STANDBY2_DIR/etc/pgpool.conf echo "logdir = $STANDBY2_DIR/log" >> $STANDBY2_DIR/etc/pgpool.conf +echo 2 > $STANDBY2_DIR/etc/pgpool_node_id # start the stnadby pgpool-II by hand $PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY2_DIR/etc/pgpool.conf -F $STANDBY2_DIR/etc/pcp.conf -a $STANDBY2_DIR/etc/pool_hba.conf > $STANDBY2_DIR/log/pgpool.log 2>&1 & diff --git a/src/test/regression/tests/014.watchdog_test_quorum_bypass/master.conf b/src/test/regression/tests/014.watchdog_test_quorum_bypass/master.conf index 58e6f4b..d8af08b 100644 --- a/src/test/regression/tests/014.watchdog_test_quorum_bypass/master.conf +++ b/src/test/regression/tests/014.watchdog_test_quorum_bypass/master.conf @@ -6,19 +6,20 @@ failover_require_consensus = true allow_multiple_failover_requests_from_node = false wd_interval = 1 wd_priority = 5 -wd_hostname = 'localhost' -wd_port = 21004 -wd_heartbeat_port = 21005 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21105 -heartbeat_destination1 = 'localhost' -heartbeat_destination_port1 = 21205 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port1 = 11100 +hostname2 = 'localhost' +wd_port2 = 21204 +pgpool_port2 = 11200 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11100 -other_wd_port0 = 21104 - -other_pgpool_hostname1 = 'localhost' -other_pgpool_port1 = 11200 -other_wd_port1 = 21204 +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port1 = 21105 +heartbeat_hostname2 = 'localhost' +heartbeat_port2 = 21205 diff --git a/src/test/regression/tests/014.watchdog_test_quorum_bypass/test.sh b/src/test/regression/tests/014.watchdog_test_quorum_bypass/test.sh index 7898f33..1ead154 100755 --- a/src/test/regression/tests/014.watchdog_test_quorum_bypass/test.sh +++ b/src/test/regression/tests/014.watchdog_test_quorum_bypass/test.sh @@ -34,6 +34,7 @@ echo "master setup done." source ./bashrc.ports cat ../master.conf >> etc/pgpool.conf +echo 0 > etc/pgpool_node_id ./startall wait_for_pgpool_startup diff --git a/src/test/regression/tests/015.watchdog_master_and_backend_fail/master.conf b/src/test/regression/tests/015.watchdog_master_and_backend_fail/master.conf index 58e6f4b..d8af08b 100644 --- a/src/test/regression/tests/015.watchdog_master_and_backend_fail/master.conf +++ b/src/test/regression/tests/015.watchdog_master_and_backend_fail/master.conf @@ -6,19 +6,20 @@ failover_require_consensus = true allow_multiple_failover_requests_from_node = false wd_interval = 1 wd_priority = 5 -wd_hostname = 'localhost' -wd_port = 21004 -wd_heartbeat_port = 21005 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21105 -heartbeat_destination1 = 'localhost' -heartbeat_destination_port1 = 21205 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port1 = 11100 +hostname2 = 'localhost' +wd_port2 = 21204 +pgpool_port2 = 11200 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11100 -other_wd_port0 = 21104 - -other_pgpool_hostname1 = 'localhost' -other_pgpool_port1 = 11200 -other_wd_port1 = 21204 +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port1 = 21105 +heartbeat_hostname2 = 'localhost' +heartbeat_port2 = 21205 diff --git a/src/test/regression/tests/015.watchdog_master_and_backend_fail/standby.conf b/src/test/regression/tests/015.watchdog_master_and_backend_fail/standby.conf index 710cbb7..8c8a14d 100644 --- a/src/test/regression/tests/015.watchdog_master_and_backend_fail/standby.conf +++ b/src/test/regression/tests/015.watchdog_master_and_backend_fail/standby.conf @@ -8,19 +8,20 @@ failover_require_consensus = true allow_multiple_failover_requests_from_node = false wd_interval = 1 wd_priority = 3 -wd_hostname = 'localhost' -wd_port = 21104 -wd_heartbeat_port = 21105 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21005 -heartbeat_destination1 = 'localhost' -heartbeat_destination_port1 = 21205 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11000 -other_wd_port0 = 21004 - -other_pgpool_hostname1 = 'localhost' -other_pgpool_port1 = 11200 -other_wd_port1 = 21204 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port1 = 11100 +hostname2 = 'localhost' +wd_port2 = 21204 +pgpool_port2 = 11200 +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port1 = 21105 +heartbeat_hostname2 = 'localhost' +heartbeat_port2 = 21205 diff --git a/src/test/regression/tests/015.watchdog_master_and_backend_fail/standby2.conf b/src/test/regression/tests/015.watchdog_master_and_backend_fail/standby2.conf index f447141..f094054 100644 --- a/src/test/regression/tests/015.watchdog_master_and_backend_fail/standby2.conf +++ b/src/test/regression/tests/015.watchdog_master_and_backend_fail/standby2.conf @@ -8,19 +8,20 @@ failover_require_consensus = true allow_multiple_failover_requests_from_node = false wd_interval = 1 wd_priority = 1 -wd_hostname = 'localhost' -wd_port = 21204 -wd_heartbeat_port = 21205 -heartbeat_destination0 = 'localhost' -heartbeat_destination_port0 = 21005 -heartbeat_destination1 = 'localhost' -heartbeat_destination_port1 = 21105 -other_pgpool_hostname0 = 'localhost' -other_pgpool_port0 = 11000 -other_wd_port0 = 21004 - -other_pgpool_hostname1 = 'localhost' -other_pgpool_port1 = 11100 -other_wd_port1 = 21104 +hostname0 = 'localhost' +wd_port0 = 21004 +pgpool_port0 = 11000 +hostname1 = 'localhost' +wd_port1 = 21104 +pgpool_port1 = 11100 +hostname2 = 'localhost' +wd_port2 = 21204 +pgpool_port2 = 11200 +heartbeat_hostname0 = 'localhost' +heartbeat_port0 = 21005 +heartbeat_hostname1 = 'localhost' +heartbeat_port1 = 21105 +heartbeat_hostname2 = 'localhost' +heartbeat_port2 = 21205 diff --git a/src/test/regression/tests/015.watchdog_master_and_backend_fail/test.sh b/src/test/regression/tests/015.watchdog_master_and_backend_fail/test.sh index 4aa2f68..f253d33 100755 --- a/src/test/regression/tests/015.watchdog_master_and_backend_fail/test.sh +++ b/src/test/regression/tests/015.watchdog_master_and_backend_fail/test.sh @@ -42,6 +42,7 @@ cp -r etc ../$STANDBY2_DIR/ source ./bashrc.ports cat ../master.conf >> etc/pgpool.conf +echo 0 > etc/pgpool_node_id ./startall wait_for_pgpool_startup @@ -59,6 +60,7 @@ cat standby.conf >> $STANDBY_DIR/etc/pgpool.conf # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf echo "pid_file_name = '$PWD/pgpool2.pid'" >> $STANDBY_DIR/etc/pgpool.conf echo "logdir = $STANDBY_DIR/log" >> $STANDBY_DIR/etc/pgpool.conf +echo 1 > $STANDBY_DIR/etc/pgpool_node_id # start the stnadby pgpool-II by hand $PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY_DIR/etc/pgpool.conf -F $STANDBY_DIR/etc/pcp.conf -a $STANDBY_DIR/etc/pool_hba.conf > $STANDBY_DIR/log/pgpool.log 2>&1 & @@ -69,6 +71,7 @@ cat standby2.conf >> $STANDBY2_DIR/etc/pgpool.conf # since we are using the same pgpool-II conf as of master. so change the pid file path in standby pgpool conf echo "pid_file_name = '$PWD/pgpool3.pid'" >> $STANDBY2_DIR/etc/pgpool.conf echo "logdir = $STANDBY2_DIR/log" >> $STANDBY2_DIR/etc/pgpool.conf +echo 2 > $STANDBY2_DIR/etc/pgpool_node_id # start the stnadby pgpool-II by hand $PGPOOL_INSTALL_DIR/bin/pgpool -D -n -f $STANDBY2_DIR/etc/pgpool.conf -F $STANDBY2_DIR/etc/pcp.conf -a $STANDBY2_DIR/etc/pool_hba.conf > $STANDBY2_DIR/log/pgpool.log 2>&1 & diff --git a/src/test/watchdog_setup b/src/test/watchdog_setup index 1bbbbeb..6a14b8e 100755 --- a/src/test/watchdog_setup +++ b/src/test/watchdog_setup @@ -171,35 +171,30 @@ function set_watchdog_params { priority=`expr $num_pgpool - $id` n=0 conf=etc/pgpool.conf - wd_port=`expr $base_port + \( $id \* $num_ports_per_node \) + 2` - wd_heartbeat_port=`expr $wd_port + 1` + node_id_file=etc/pgpool_node_id cat >> $conf <> $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 } ################################################################################# diff --git a/src/tools/pgmd5/Makefile.am b/src/tools/pgmd5/Makefile.am index ec0d9ba..1bf535a 100644 --- a/src/tools/pgmd5/Makefile.am +++ b/src/tools/pgmd5/Makefile.am @@ -9,7 +9,8 @@ nodist_pg_md5_SOURCES = md5.c \ regex_array.c \ pool_config_variables.c \ pool_config.c \ - fe_memutils.c + fe_memutils.c \ + pool_path.c DEFS = @DEFS@ \ -DDEFAULT_CONFIGDIR=\"$(sysconfdir)\" -DPOOL_TOOLS @@ -20,6 +21,8 @@ md5.h: ../../../src/include/auth/md5.h rm -f $@ && ln -s $< . pool_passwd.c: ../../../src/auth/pool_passwd.c rm -f $@ && ln -s $< . +pool_path.c: ../../../src/utils/pool_path.c + rm -f $@ && ln -s $< . strlcpy.c: ../../../src/utils/strlcpy.c rm -f $@ && ln -s $< . regex_array.c: ../../../src/utils/regex_array.c diff --git a/src/tools/watchdog/Makefile.am b/src/tools/watchdog/Makefile.am index e54df85..c405e81 100644 --- a/src/tools/watchdog/Makefile.am +++ b/src/tools/watchdog/Makefile.am @@ -14,6 +14,7 @@ nodist_wd_cli_SOURCES = ssl_utils.c \ json.c \ pool_config_variables.c \ pool_config.c \ + pool_path.c \ fe_memutils.c \ stringinfo.h \ stringinfo.c \ @@ -64,6 +65,8 @@ pool_config_variables.c: ../../../src/config/pool_config_variables.c rm -f $@ && ln -s $< . pool_config.c: ../../../src/config/pool_config.c rm -f $@ && ln -s $< . +pool_path.c: ../../../src/utils/pool_path.c + rm -f $@ && ln -s $< . fe_memutils.c: ../../../src/tools/fe_memutils.c rm -f $@ && ln -s $< . diff --git a/src/tools/watchdog/wd_cli.c b/src/tools/watchdog/wd_cli.c index 0824e01..441e215 100644 --- a/src/tools/watchdog/wd_cli.c +++ b/src/tools/watchdog/wd_cli.c @@ -334,14 +334,15 @@ main(int argc, char **argv) } if (debug) - printf("DEBUG: From config %s:%d\n",pool_config->wd_ipc_socket_dir, pool_config->wd_port); + printf("DEBUG: From config %s:%d\n",pool_config->wd_ipc_socket_dir, + pool_config->wd_nodes.wd_node_info[pool_config->pgpool_node_id].wd_port); pfree(conf_file_path); /* only use values from pg_config that are not provided explicitely*/ if (wd_authkey == NULL) wd_authkey = pstrdup(pool_config->wd_authkey); if (port < 0) - port = pool_config->wd_port; + port = pool_config->wd_nodes.wd_node_info[pool_config->pgpool_node_id].wd_port;; if (socket_dir == NULL) socket_dir = pstrdup(pool_config->wd_ipc_socket_dir); } diff --git a/src/utils/pool_process_reporting.c b/src/utils/pool_process_reporting.c index 9ecd8e0..f570d20 100644 --- a/src/utils/pool_process_reporting.c +++ b/src/utils/pool_process_reporting.c @@ -774,16 +774,6 @@ get_config(int *nrows) StrNCpy(status[i].desc, "delegate IP address of master pgpool", POOLCONFIG_MAXDESCLEN); i++; - StrNCpy(status[i].name, "wd_hostname", POOLCONFIG_MAXNAMELEN); - snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->wd_hostname); - StrNCpy(status[i].desc, "Host name or IP address of this watchdog", POOLCONFIG_MAXDESCLEN); - i++; - - StrNCpy(status[i].name, "wd_port", POOLCONFIG_MAXNAMELEN); - snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->wd_port); - StrNCpy(status[i].desc, "watchdog port number", POOLCONFIG_MAXDESCLEN); - i++; - StrNCpy(status[i].name, "wd_priority", POOLCONFIG_MAXNAMELEN); snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->wd_priority); StrNCpy(status[i].desc, "watchdog priority", POOLCONFIG_MAXDESCLEN); @@ -1030,35 +1020,57 @@ get_config(int *nrows) if (WD_INFO(j).pgpool_port == 0) continue; - snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "other_pgpool_hostname%d", j); - snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_INFO(j).hostname); - snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d hostname", j); - i++; - - snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "other_pgpool_port%d", j); - snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_INFO(j).pgpool_port); - snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d port number", j); - i++; - - snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "other_pgpool_wd_port%d", j); - snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_INFO(j).wd_port); - snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d watchdog port number", j); - i++; - + if (j == pool_config->pgpool_node_id) + { + snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "hostname%d", j); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_INFO(j).hostname); + snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "Host name or IP address of this watchdog"); + i++; + + snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "pgpool_port%d", j); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_INFO(j).pgpool_port); + snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "local pgpool port number"); + i++; + + snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "wd_port%d", j); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_INFO(j).wd_port); + snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "local pgpool watchdog port number"); + i++; + } + else + { + snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "hostname%d", j); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_INFO(j).hostname); + snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d hostname", j); + i++; + + snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "pgpool_port%d", j); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_INFO(j).pgpool_port); + snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d port number", j); + i++; + + snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "wd_port%d", j); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_INFO(j).wd_port); + snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d watchdog port number", j); + i++; + } } - for (j = 0; j < pool_config->num_hb_if; j++) + for (j = 0; j < pool_config->num_hb_dest_if; j++) { - snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "heartbeat_device%d", j); - snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_HB_IF(j).if_name); - snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "name of NIC device #%d for sending hearbeat", j); - i++; + if (j == pool_config->pgpool_node_id) + continue; snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "heartbeat_destination%d", j); snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_HB_IF(j).addr); snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "destination host for sending heartbeat using NIC device %d", j); i++; + snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "heartbeat_device%d", j); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_HB_IF(j).if_name); + snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "name of NIC device #%d for sending hearbeat", j); + i++; + snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "heartbeat_destination_port%d", j); snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_HB_IF(j).dest_port); snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "destination port for sending heartbeat using NIC device %d", j); diff --git a/src/watchdog/watchdog.c b/src/watchdog/watchdog.c index 841a349..d014d77 100644 --- a/src/watchdog/watchdog.c +++ b/src/watchdog/watchdog.c @@ -617,7 +617,7 @@ initialize_watchdog(void) static void wd_check_config(void) { - if (pool_config->wd_remote_nodes.num_wd == 0) + if (pool_config->wd_nodes.num_wd == 0) ereport(ERROR, (errmsg("invalid watchdog configuration. other pgpools setting is not defined"))); @@ -627,7 +627,7 @@ wd_check_config(void) MAX_PASSWORD_SIZE))); if (pool_config->wd_lifecheck_method == LIFECHECK_BY_HB) { - if (pool_config->num_hb_if <= 0) + if (pool_config->num_hb_dest_if <= 0) ereport(ERROR, (errmsg("invalid lifecheck configuration. no heartbeat interfaces defined"))); } @@ -714,22 +714,24 @@ static void wd_cluster_initialize(void) { int i = 0; + int pgpool_node_id = pool_config->pgpool_node_id; - if (pool_config->wd_remote_nodes.num_wd <= 0) + if (pool_config->wd_nodes.num_wd <= 0) { /* should also have upper limit??? */ ereport(ERROR, (errmsg("initializing watchdog failed. no watchdog nodes configured"))); } + /* initialize local node settings */ g_cluster.localNode = palloc0(sizeof(WatchdogNode)); - g_cluster.localNode->wd_port = pool_config->wd_port; + g_cluster.localNode->wd_port = pool_config->wd_nodes.wd_node_info[pgpool_node_id].wd_port; + g_cluster.localNode->pgpool_port = pool_config->wd_nodes.wd_node_info[pgpool_node_id].pgpool_port; g_cluster.localNode->wd_priority = pool_config->wd_priority; - g_cluster.localNode->pgpool_port = pool_config->port; g_cluster.localNode->private_id = 0; gettimeofday(&g_cluster.localNode->startup_time, NULL); - strncpy(g_cluster.localNode->hostname, pool_config->wd_hostname, sizeof(g_cluster.localNode->hostname) - 1); + strncpy(g_cluster.localNode->hostname, pool_config->wd_nodes.wd_node_info[pgpool_node_id].hostname, sizeof(g_cluster.localNode->hostname) - 1); strncpy(g_cluster.localNode->delegate_ip, pool_config->delegate_IP, sizeof(g_cluster.localNode->delegate_ip) - 1); /* Assign the node name */ { @@ -737,8 +739,8 @@ wd_cluster_initialize(void) uname(&unameData); snprintf(g_cluster.localNode->nodeName, sizeof(g_cluster.localNode->nodeName), "%s:%d %s %s", - pool_config->wd_hostname, - pool_config->port, + pool_config->wd_nodes.wd_node_info[pgpool_node_id].hostname, + pool_config->wd_nodes.wd_node_info[pgpool_node_id].pgpool_port, unameData.sysname, unameData.nodename); /* should also have upper limit??? */ @@ -747,24 +749,30 @@ wd_cluster_initialize(void) } /* initialize remote nodes */ - g_cluster.remoteNodeCount = pool_config->wd_remote_nodes.num_wd; + g_cluster.remoteNodeCount = pool_config->wd_nodes.num_wd - 1; g_cluster.remoteNodes = palloc0((sizeof(WatchdogNode) * g_cluster.remoteNodeCount)); 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++) + 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].private_id = i + 1; + 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; @@ -7397,14 +7405,14 @@ verify_pool_configurations(WatchdogNode * wdNode, POOL_CONFIG * config) } } - if (config->wd_remote_nodes.num_wd != pool_config->wd_remote_nodes.num_wd) + if (config->wd_nodes.num_wd != pool_config->wd_nodes.num_wd) { ereport(WARNING, (errmsg("the number of configured watchdog nodes on node \"%s\" are different", wdNode->nodeName), errdetail("this node has %d watchdog nodes while \"%s\" is configured with %d watchdog nodes", - pool_config->wd_remote_nodes.num_wd, + pool_config->wd_nodes.num_wd, wdNode->nodeName, - config->wd_remote_nodes.num_wd))); + config->wd_nodes.num_wd))); } } diff --git a/src/watchdog/wd_heartbeat.c b/src/watchdog/wd_heartbeat.c index 88a5914..b2e8f4d 100644 --- a/src/watchdog/wd_heartbeat.c +++ b/src/watchdog/wd_heartbeat.c @@ -551,7 +551,7 @@ wd_hb_sender(int fork_wait_time, WdHbIf * hb_if) /* contents of packet */ gettimeofday(&pkt.send_time, NULL); - strlcpy(pkt.from, pool_config->wd_hostname, sizeof(pkt.from)); + strlcpy(pkt.from, pool_config->wd_nodes.wd_node_info[pool_config->pgpool_node_id].hostname, sizeof(pkt.from)); pkt.from_pgpool_port = pool_config->port; /* authentication key */ diff --git a/src/watchdog/wd_ipc_conn.c b/src/watchdog/wd_ipc_conn.c index 4515747..207a580 100644 --- a/src/watchdog/wd_ipc_conn.c +++ b/src/watchdog/wd_ipc_conn.c @@ -80,7 +80,7 @@ wd_ipc_conn_initialize(void) { if (watchdog_ipc_address == NULL) { - wd_set_ipc_address(pool_config->wd_ipc_socket_dir, pool_config->wd_port); + wd_set_ipc_address(pool_config->wd_ipc_socket_dir, pool_config->wd_nodes.wd_node_info[pool_config->pgpool_node_id].wd_port); } } diff --git a/src/watchdog/wd_json_data.c b/src/watchdog/wd_json_data.c index a7576e1..39001dc 100644 --- a/src/watchdog/wd_json_data.c +++ b/src/watchdog/wd_json_data.c @@ -104,8 +104,6 @@ get_pool_config_from_json(char *json_data, int data_len) goto ERROR_EXIT; if (json_get_bool_value_for_key(root, "clear_memqcache_on_escalation", &config->clear_memqcache_on_escalation)) goto ERROR_EXIT; - if (json_get_int_value_for_key(root, "wd_port", &config->wd_port)) - goto ERROR_EXIT; if (json_get_int_value_for_key(root, "wd_priority", &config->wd_priority)) goto ERROR_EXIT; if (json_get_int_value_for_key(root, "master_slave_sub_mode", (int *) &config->master_slave_sub_mode)) @@ -137,25 +135,25 @@ get_pool_config_from_json(char *json_data, int data_len) strncpy(config->backend_desc->backend_info[i].backend_hostname, ptr, sizeof(config->backend_desc->backend_info[i].backend_hostname) - 1); } - /* wd_remote_nodes array */ - value = json_get_value_for_key(root, "wd_remote_nodes"); + /* wd_nodes array */ + value = json_get_value_for_key(root, "wd_nodes"); if (value == NULL || value->type != json_array) goto ERROR_EXIT; - config->wd_remote_nodes.num_wd = value->u.array.length; - for (i = 0; i < config->wd_remote_nodes.num_wd; i++) + config->wd_nodes.num_wd = value->u.array.length; + for (i = 0; i < config->wd_nodes.num_wd; i++) { json_value *arr_value = value->u.array.values[i]; char *ptr; - if (json_get_int_value_for_key(arr_value, "wd_port", &config->wd_remote_nodes.wd_remote_node_info[i].wd_port)) + if (json_get_int_value_for_key(arr_value, "wd_port", &config->wd_nodes.wd_node_info[i].wd_port)) goto ERROR_EXIT; - if (json_get_int_value_for_key(arr_value, "pgpool_port", &config->wd_remote_nodes.wd_remote_node_info[i].pgpool_port)) + if (json_get_int_value_for_key(arr_value, "pgpool_port", &config->wd_nodes.wd_node_info[i].pgpool_port)) goto ERROR_EXIT; ptr = json_get_string_value_for_key(arr_value, "hostname"); if (ptr == NULL) goto ERROR_EXIT; - strncpy(config->wd_remote_nodes.wd_remote_node_info[i].hostname, ptr, sizeof(config->wd_remote_nodes.wd_remote_node_info[i].hostname) - 1); + strncpy(config->wd_nodes.wd_node_info[i].hostname, ptr, sizeof(config->wd_nodes.wd_node_info[i].hostname) - 1); } json_value_free(root); @@ -206,7 +204,6 @@ get_pool_config_json(void) jw_put_bool(jNode, "memory_cache_enabled", pool_config->memory_cache_enabled); jw_put_bool(jNode, "use_watchdog", pool_config->use_watchdog); jw_put_bool(jNode, "clear_memqcache_on_escalation", pool_config->clear_memqcache_on_escalation); - jw_put_int(jNode, "wd_port", pool_config->wd_port); jw_put_int(jNode, "wd_priority", pool_config->wd_priority); jw_put_int(jNode, "master_slave_sub_mode", pool_config->master_slave_sub_mode); @@ -225,17 +222,17 @@ get_pool_config_json(void) } jw_end_element(jNode); /* backend_desc array End */ - /* Array of wd_remote_nodes */ - jw_start_array(jNode, "wd_remote_nodes"); - for (i = 0; i < pool_config->wd_remote_nodes.num_wd; i++) + /* Array of wd_nodes */ + jw_start_array(jNode, "wd_nodes"); + for (i = 0; i < pool_config->wd_nodes.num_wd; i++) { - jw_start_object(jNode, "WdRemoteNodesConfig"); - jw_put_string(jNode, "hostname", pool_config->wd_remote_nodes.wd_remote_node_info[i].hostname); - jw_put_int(jNode, "wd_port", pool_config->wd_remote_nodes.wd_remote_node_info[i].wd_port); - jw_put_int(jNode, "pgpool_port", pool_config->wd_remote_nodes.wd_remote_node_info[i].pgpool_port); + jw_start_object(jNode, "WdNodesConfig"); + jw_put_string(jNode, "hostname", pool_config->wd_nodes.wd_node_info[i].hostname); + jw_put_int(jNode, "wd_port", pool_config->wd_nodes.wd_node_info[i].wd_port); + jw_put_int(jNode, "pgpool_port", pool_config->wd_nodes.wd_node_info[i].pgpool_port); jw_end_element(jNode); } - jw_end_element(jNode); /* wd_remote_nodes array End */ + jw_end_element(jNode); /* wd_nodes array End */ jw_finish_document(jNode); json_str = pstrdup(jw_get_json_string(jNode)); diff --git a/src/watchdog/wd_lifecheck.c b/src/watchdog/wd_lifecheck.c index ad6f920..4af8e2e 100644 --- a/src/watchdog/wd_lifecheck.c +++ b/src/watchdog/wd_lifecheck.c @@ -134,7 +134,7 @@ lifecheck_child_name(pid_t pid) { int i; - for (i = 0; i < pool_config->num_hb_if; i++) + for (i = 0; i < pool_config->num_hb_dest_if; i++) { if (g_hb_receiver_pid && pid == g_hb_receiver_pid[i]) return "heartBeat receiver"; @@ -213,13 +213,13 @@ wd_reaper_lifecheck(pid_t pid, int status) if (g_hb_receiver_pid == NULL && g_hb_sender_pid == NULL) return -1; - for (i = 0; i < pool_config->num_hb_if; i++) + for (i = 0; i < pool_config->num_hb_dest_if; i++) { if (g_hb_receiver_pid && pid == g_hb_receiver_pid[i]) { if (restart_child) { - g_hb_receiver_pid[i] = wd_hb_receiver(1, &(pool_config->hb_if[i])); + g_hb_receiver_pid[i] = wd_hb_receiver(1, &(pool_config->hb_dest_if[i])); ereport(LOG, (errmsg("fork a new %s process with pid: %d", proc_name, g_hb_receiver_pid[i]))); } @@ -233,7 +233,7 @@ wd_reaper_lifecheck(pid_t pid, int status) { if (restart_child) { - g_hb_sender_pid[i] = wd_hb_sender(1, &(pool_config->hb_if[i])); + g_hb_sender_pid[i] = wd_hb_sender(1, &(pool_config->hb_dest_if[i])); ereport(LOG, (errmsg("fork a new %s process with pid: %d", proc_name, g_hb_sender_pid[i]))); } @@ -256,7 +256,7 @@ lifecheck_kill_all_children(int sig) { int i; - for (i = 0; i < pool_config->num_hb_if; i++) + for (i = 0; i < pool_config->num_hb_dest_if; i++) { pid_t pid_child = g_hb_receiver_pid[i]; @@ -468,16 +468,16 @@ spawn_lifecheck_children(void) { int i; - g_hb_receiver_pid = palloc0(sizeof(pid_t) * pool_config->num_hb_if); - g_hb_sender_pid = palloc0(sizeof(pid_t) * pool_config->num_hb_if); + g_hb_receiver_pid = palloc0(sizeof(pid_t) * pool_config->num_hb_dest_if); + g_hb_sender_pid = palloc0(sizeof(pid_t) * pool_config->num_hb_dest_if); - for (i = 0; i < pool_config->num_hb_if; i++) + for (i = 0; i < pool_config->num_hb_dest_if; i++) { /* heartbeat receiver process */ - g_hb_receiver_pid[i] = wd_hb_receiver(1, &(pool_config->hb_if[i])); + g_hb_receiver_pid[i] = wd_hb_receiver(1, &(pool_config->hb_dest_if[i])); /* heartbeat sender process */ - g_hb_sender_pid[i] = wd_hb_sender(1, &(pool_config->hb_if[i])); + g_hb_sender_pid[i] = wd_hb_sender(1, &(pool_config->hb_dest_if[i])); } } }