summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpengbo2017-11-07 13:51:50 +0000
committerpengbo2017-11-07 13:51:50 +0000
commit694502da1929a643875c661fe34b278e6efaa142 (patch)
treeabc630ae0085421c62030908f63dfc3a4cab5893
parent00216b09a8ab5408f3b395f824170e017c48581c (diff)
Add 3.7 config parameters.
-rw-r--r--bootstrap.php2
-rw-r--r--common.php65
-rw-r--r--conf/pgmgt.conf.php2
-rw-r--r--definePgpoolConfParam.php52
-rw-r--r--install/checkParameter.php2
-rw-r--r--install/index.php2
-rw-r--r--js/pgconfig.js147
-rw-r--r--lang/ja.lang.php14
-rw-r--r--libs/plugins/function.custom_tr_pgconfig.php17
-rw-r--r--pgconfig.php125
-rw-r--r--templates/pgconfig.tpl88
-rw-r--r--version.php2
12 files changed, 439 insertions, 79 deletions
diff --git a/bootstrap.php b/bootstrap.php
index 7edd935..a719370 100644
--- a/bootstrap.php
+++ b/bootstrap.php
@@ -30,7 +30,7 @@ define('NODE_NOT_LOADED', -1); // only for pgpoolAdmin
// watchdog status in "pcp_watchdog_info" result (- 3.4)
// (defined in $src/inclucde/watchdog/watchdog.h
$g_watchdog_status_str_arr = array();
-if (_PGPOOL2_VERSION < 3.5) {
+if (defined('_PGPOOL2_VERSION') && _PGPOOL2_VERSION < 3.5) {
define('WATCHDOG_END', 0);
define('WATCHDOG_INIT', 1);
define('WATCHDOG_NORMAL', 2);
diff --git a/common.php b/common.php
index f83b960..4bf57a7 100644
--- a/common.php
+++ b/common.php
@@ -315,7 +315,7 @@ function readLogDir()
function readConfigParams($paramList = array())
{
$rtn = array();
- global $pgpoolConfigParam, $pgpoolConfigBackendParam ,
+ global $pgpoolConfigParam, $pgpoolConfigBackendParam,
$pgpoolConfigWdOtherParam, $pgpoolConfigHbDestinationParam;
// Try to read pgpool.conf
@@ -339,6 +339,8 @@ function readConfigParams($paramList = array())
}
list($key, $value) = explode('=', $line);
+
+ // 設定ファイルのパラメータのキー
$key = trim($key);
switch ($key) {
@@ -348,6 +350,7 @@ function readConfigParams($paramList = array())
break;
default:
+ // In case of "health_check_*0", the number is left.
$num = preg_replace('/[^0-9]/', NULL, $key);
$key_wo_num = str_replace($num, NULL, $key);
break;
@@ -361,6 +364,13 @@ function readConfigParams($paramList = array())
// Remove quotes and comments
$value = trimValue($value);
+ // Change true/false to on/off
+ if ($value == 'true') {
+ $value = 'on';
+ } elseif ($value == 'false') {
+ $value = 'off';
+ }
+
if (! isset($defines_arr[$key_wo_num])) {
continue;
@@ -373,7 +383,12 @@ function readConfigParams($paramList = array())
} else {
// Ignore param not defined definePgpoolConfParam.php
- $rtn[$key_wo_num] = $value;
+ if (preg_match('/^(health_check|connect_time).*[0-9]$/', $key)) {
+ // In case of "health_check_*0", the number is left.
+ $rtn[$key] = $value;
+ } else {
+ $rtn[$key_wo_num] = $value;
+ }
}
}
@@ -494,6 +509,21 @@ function paramExists($param)
/* Add */
switch ($param) {
+ // params added in 3.7
+ case 'failover_when_quorum_exists':
+ case 'failover_require_consensus':
+ case 'enable_multiple_failover_requests_from_node':
+ case 'health_check_period0':
+ case 'health_check_timeout0':
+ case 'health_check_user0':
+ case 'health_check_password0':
+ case 'health_check_database0':
+ case 'health_check_max_retries0':
+ case 'health_check_retry_delay0':
+ case 'connect_timeout0':
+ $add_version = 3.7;
+ break;
+
// params added in 3.5
case 'if_cmd_path':
case 'health_check_database':
@@ -622,6 +652,11 @@ function paramExists($param)
/* Delete */
switch ($param) {
+ // params deleted in 3.7
+ case 'debug_level':
+ $del_version = 3.7;
+ break;
+
// params deleted in 3.5
case 'ifconfig_path':
$del_version = 3.5;
@@ -671,7 +706,7 @@ function paramExists($param)
function versions()
{
- return array('3.6', '3.5', '3.4', '3.3', '3.2', '3.1', '3.0',
+ return array('3.7', '3.6', '3.5', '3.4', '3.3', '3.2', '3.1', '3.0',
'2.3', '2.2', '2.1', '2.0');
}
@@ -790,6 +825,24 @@ function getMultiParams()
return $rtn;
}
+/*
+ * Return per node health check parameters
+ */
+function getPerNodeHealthCheckParams()
+{
+ $rtn = array();
+ $rtn = array('health_check_period',
+ 'health_check_timeout',
+ 'health_check_user',
+ 'health_check_password',
+ 'health_check_database',
+ 'health_check_max_retries',
+ 'health_check_retry_delay',
+ 'connect_timeout');
+
+ return $rtn;
+}
+
/* --------------------------------------------------------------------- */
/* function (other) */
/* --------------------------------------------------------------------- */
@@ -805,6 +858,12 @@ function isTrue($value)
return in_array($value, array('on', 'true'));
}
+function definedHealthCheckParam($params, $param_name, $backend_num)
+{
+ return isset($params[$param_name . $backend_num]) ?
+ $param_name . $backend_num : null;
+}
+
function errorPage($errorCode)
{
global $tpl;
diff --git a/conf/pgmgt.conf.php b/conf/pgmgt.conf.php
index d846688..58c10d5 100644
--- a/conf/pgmgt.conf.php
+++ b/conf/pgmgt.conf.php
@@ -1,6 +1,6 @@
<?php
define('_PGPOOL2_LANG', 'ja');
-define('_PGPOOL2_VERSION', '3.6');
+define('_PGPOOL2_VERSION', '3.7');
define('_PGPOOL2_CONFIG_FILE', '/usr/local/etc/pgpool.conf');
define('_PGPOOL2_PASSWORD_FILE', '/usr/local/etc/pcp.conf');
define('_PGPOOL2_COMMAND', '/usr/local/bin/pgpool');
diff --git a/definePgpoolConfParam.php b/definePgpoolConfParam.php
index e293370..a8a9927 100644
--- a/definePgpoolConfParam.php
+++ b/definePgpoolConfParam.php
@@ -26,6 +26,7 @@ $pgpoolConfigParam = array();
$pgpoolConfigBackendParam = array();
$pgpoolConfigWdOtherParam = array();
$pgpoolConfigHbDestinationParam = array();
+$pgpoolConfigHealthCheckParam = array();
define('NUM_MAX', 65535);
@@ -133,7 +134,7 @@ $pgpoolConfigBackendParam[$key]['multiple'] = TRUE;
$key = 'backend_flag';
$pgpoolConfigBackendParam[$key]['type'] = 'C';
$pgpoolConfigBackendParam[$key]['default'] = 'ALLOW_TO_FAILOVER';
-$pgpoolConfigBackendParam[$key]['select'] = array('ALLOW_TO_FAILOVER', 'DISALLOW_TO_FAILOVER');
+$pgpoolConfigBackendParam[$key]['select'] = array('ALLOW_TO_FAILOVER', 'DISALLOW_TO_FAILOVER', 'ALWAYS_MASTER');
$pgpoolConfigBackendParam[$key]['regexp'] = selectreg($pgpoolConfigBackendParam[$key]['select']);
$pgpoolConfigBackendParam[$key]['multiple'] = TRUE;
@@ -297,12 +298,6 @@ $pgpoolConfigParam[$key]['parent'] = array('log_destination' => 'syslog');
# - Debug -
-$key = 'debug_level';
-$pgpoolConfigParam[$key]['type'] = 'N';
-$pgpoolConfigParam[$key]['default'] = '0';
-$pgpoolConfigParam[$key]['min'] = 0;
-$pgpoolConfigParam[$key]['max'] = NUM_MAX;
-
$key = 'log_error_verbosity';
$pgpoolConfigParam[$key]['type'] = 'C';
$pgpoolConfigParam[$key]['default'] = 'DEFAULT';
@@ -448,8 +443,8 @@ $pgpoolConfigParam[$key]['restart'] = TRUE;
$key = 'master_slave_sub_mode';
$pgpoolConfigParam[$key]['type'] = 'C';
-$pgpoolConfigParam[$key]['default'] = 'slony';
-$pgpoolConfigParam[$key]['select'] = array('slony', 'stream');
+$pgpoolConfigParam[$key]['default'] = 'stream';
+$pgpoolConfigParam[$key]['select'] = array('stream', 'slony');
$pgpoolConfigParam[$key]['regexp'] = selectreg($pgpoolConfigParam[$key]['select']);
$pgpoolConfigParam[$key]['restart'] = TRUE;
$pgpoolConfigParam[$key]['parent'] = array('master_slave_mode' => 'on');
@@ -563,7 +558,7 @@ $pgpoolConfigParam[$key]['restart'] = TRUE;
$pgpoolConfigParam[$key]['parent'] = array('parallel_mode' => 'on');
#------------------------------------------------------------------------------
-# HEALTH CHECK
+# HEALTH CHECK GLOBAL PARAMETERS
#------------------------------------------------------------------------------
$key = 'health_check_period';
@@ -571,45 +566,53 @@ $pgpoolConfigParam[$key]['type'] = 'N';
$pgpoolConfigParam[$key]['default'] =0;
$pgpoolConfigParam[$key]['min'] = 0;
$pgpoolConfigParam[$key]['max'] = NUM_MAX;
+$pgpoolConfigParam[$key]['healthcheck'] = TRUE;
$key = 'health_check_timeout';
$pgpoolConfigParam[$key]['type'] = 'N';
$pgpoolConfigParam[$key]['default'] =20;
$pgpoolConfigParam[$key]['min'] = 0;
$pgpoolConfigParam[$key]['max'] = NUM_MAX;
+$pgpoolConfigParam[$key]['healthcheck'] = TRUE;
$key = 'health_check_user';
$pgpoolConfigParam[$key]['type'] = 'C';
-$pgpoolConfigParam[$key]['default'] = 'nodoby';
+$pgpoolConfigParam[$key]['default'] = 'noboby';
$pgpoolConfigParam[$key]['regexp'] = $userreg;
+$pgpoolConfigParam[$key]['healthcheck'] = TRUE;
$key = 'health_check_password';
$pgpoolConfigParam[$key]['type'] = 'C';
$pgpoolConfigParam[$key]['default'] = '';
$pgpoolConfigParam[$key]['regexp'] = $anyelse;
+$pgpoolConfigParam[$key]['healthcheck'] = TRUE;
$key = 'health_check_database';
$pgpoolConfigParam[$key]['type'] = 'C';
$pgpoolConfigParam[$key]['default'] = '';
$pgpoolConfigParam[$key]['regexp'] = $anyelse;
+$pgpoolConfigParam[$key]['healthcheck'] = TRUE;
$key = 'health_check_max_retries';
$pgpoolConfigParam[$key]['type'] = 'N';
$pgpoolConfigParam[$key]['default'] = 0;
$pgpoolConfigParam[$key]['min'] = 0;
$pgpoolConfigParam[$key]['max'] = NUM_MAX;
+$pgpoolConfigParam[$key]['healthcheck'] = TRUE;
$key = 'health_check_retry_delay';
$pgpoolConfigParam[$key]['type'] = 'N';
$pgpoolConfigParam[$key]['default'] = 1;
$pgpoolConfigParam[$key]['min'] = 0;
$pgpoolConfigParam[$key]['max'] = NUM_MAX;
+$pgpoolConfigParam[$key]['healthcheck'] = TRUE;
$key = 'connect_timeout';
$pgpoolConfigParam[$key]['type'] = 'N';
$pgpoolConfigParam[$key]['default'] = 10000;
$pgpoolConfigParam[$key]['min'] = 0;
$pgpoolConfigParam[$key]['max'] = NUM_MAX;
+$pgpoolConfigParam[$key]['healthcheck'] = TRUE;
#------------------------------------------------------------------------------
# FAILOVER AND FAILBACK
@@ -631,7 +634,7 @@ $pgpoolConfigParam[$key]['default'] = 'on';
$key = 'search_primary_node_timeout';
$pgpoolConfigParam[$key]['type'] = 'N';
-$pgpoolConfigParam[$key]['default'] = 10;
+$pgpoolConfigParam[$key]['default'] = 300;
$pgpoolConfigParam[$key]['min'] = 0;
$pgpoolConfigParam[$key]['max'] = NUM_MAX;
@@ -796,16 +799,33 @@ $pgpoolConfigParam[$key]['default'] = '';
$pgpoolConfigParam[$key]['regexp'] = $anyelse;
$pgpoolConfigParam[$key]['parent'] = array('use_watchdog' => 'on');
-$key = 'wd_monitoring_interfaces_list';
-$pgpoolConfigParam[$key]['type'] = 'C';
-$pgpoolConfigParam[$key]['default'] = '';
-$pgpoolConfigParam[$key]['regexp'] = $anyelse;
+# Controlling the Failover behavior
+
+$key = 'failover_when_quorum_exists';
+$pgpoolConfigParam[$key]['type'] = 'B';
+$pgpoolConfigParam[$key]['default'] = 'on';
+$pgpoolConfigParam[$key]['parent'] = array('use_watchdog' => 'on');
+
+$key = 'failover_require_consensus';
+$pgpoolConfigParam[$key]['type'] = 'B';
+$pgpoolConfigParam[$key]['default'] = 'on';
+$pgpoolConfigParam[$key]['parent'] = array('use_watchdog' => 'on');
+
+$key = 'allow_multiple_failover_requests_from_node';
+$pgpoolConfigParam[$key]['type'] = 'B';
+$pgpoolConfigParam[$key]['default'] = 'off';
$pgpoolConfigParam[$key]['parent'] = array('use_watchdog' => 'on');
# Life checking pgpool-II
# (Common)
+$key = 'wd_monitoring_interfaces_list';
+$pgpoolConfigParam[$key]['type'] = 'C';
+$pgpoolConfigParam[$key]['default'] = '';
+$pgpoolConfigParam[$key]['regexp'] = $anyelse;
+$pgpoolConfigParam[$key]['parent'] = array('use_watchdog' => 'on');
+
$key = 'wd_lifecheck_method';
$pgpoolConfigParam[$key]['type'] = 'C';
$pgpoolConfigParam[$key]['default'] = 'heartbeat';
diff --git a/install/checkParameter.php b/install/checkParameter.php
index 5ff9f95..1847694 100644
--- a/install/checkParameter.php
+++ b/install/checkParameter.php
@@ -466,7 +466,7 @@ else {
function versions()
{
- return array('3.6', '3.5', '3.4', '3.3', '3.2', '3.1', '3.0',
+ return array('3.7', '3.6', '3.5', '3.4', '3.3', '3.2', '3.1', '3.0',
'2.3', '2.2', '2.1', '2.0');
}
diff --git a/install/index.php b/install/index.php
index c5241f4..b10617b 100644
--- a/install/index.php
+++ b/install/index.php
@@ -28,7 +28,7 @@ require_once('../version.php');
$messageList = array();
$res_dir = opendir('lang/');
while ($file_name = readdir( $res_dir )) {
- if (ereg('^[^\.]', $file_name)) {
+ if (preg_match('/^[^\.]/', $file_name)) {
include('lang/' . $file_name);
$messageList[$message['lang']] = $message['strLang'];
}
diff --git a/js/pgconfig.js b/js/pgconfig.js
index ab13187..218ce6c 100644
--- a/js/pgconfig.js
+++ b/js/pgconfig.js
@@ -1,3 +1,66 @@
+$(window).load(function()
+{
+ $('input[type="radio"], select').each(function()
+ {
+ toggleTbody($(this));
+ });
+ $('input[type="radio"], select').change(function()
+ {
+ toggleTbody($(this));
+ });
+
+ /* ========================================================================= */
+ /* If no health check config of this node, */
+ /* don't show the per node health check form. */
+ /* ========================================================================= */
+
+ $('[id^=tr_hc_node_num_]').each(function()
+ {
+ var tt = null;
+ tt = $(this).nextAll('tr').find('input[value!=""]').val();
+ if ( tt === undefined) {
+ $(this).nextAll('tr').css('display', 'none');
+ }
+ });
+
+ /* ========================================================================= */
+ /* In per node health check form, */
+ /* input "name" is like "health_check_period0", "health_check_period1" */
+ /* ========================================================================= */
+ $('[id^=tb_per_node_healthcheck_]').find('input[name^=health_check], input[name=connect_timeout]').each(function()
+ {
+ var node_num = $(this).parents('tbody').attr('id').split('_')[4];
+ var name = $(this).attr('name');
+ $(this).attr('name', name + node_num)
+ });
+
+ /* ========================================================================= */
+ /* Click "add" button */
+ /* ========================================================================= */
+
+ /* Click "add" button to add backends form and add per node health_check row */
+ $('#add_backends_node').click(function()
+ {
+ var next_node_num = $('[id^=tb_backends_node_]').length;
+ addBackendForm(next_node_num);
+ addPerNodeHealthCheck(next_node_num);
+ });
+
+ /* Click "add" button to add per node health_check. */
+ $('[id^=add_per_node_health_check_]').on({'click': addPerNodeHealthCheckForm});
+
+ /* ========================================================================= */
+ /* Click "delete" button */
+ /* ========================================================================= */
+
+ /* Delete backends form */
+ $('[id^=delete_backends_node_]').on({'click': deleteBackendForm});
+
+ /* Delete per node health_check form. */
+ $('[id^=delete_per_node_health_check_]').on({'click': deletePerNodeHealthCheckForm});
+
+});
+
function sendForm(action, num)
{
$('#pgconfig_action').val(action);
@@ -42,14 +105,86 @@ function toggleTbody(item)
});
}
-$(window).load(function()
+/*
+ * Add backends form by using "add" button
+ */
+function addBackendForm(next_node_num)
{
- $('input[type="radio"], select').each(function()
+
+ var html = '<tbody id="tb_backends_node_' + next_node_num + '">' +
+ '<tr id="tr_ba_node_num_' + next_node_num +
+ '" name="tr_ba_node_num"><th colspan="2">' +
+ '<span class="param_group">Backend node ' + next_node_num + '</span>' +
+ '</th></tr>';
+
+ $('tr[name="tr_ba_node_num"]').last().nextAll('tr').each(function()
{
- toggleTbody($(this));
+ html += '<tr>' + $(this).html() + '</tr>';
});
- $('input[type="radio"], select').change(function()
+ html += '</tbody>';
+
+ $('#t_backends').append(html);
+ $('#tr_ba_node_num_' + next_node_num).nextAll('tr').find('input').val('');
+
+}
+
+/*
+ * clicking backends "add" button to add per node health_check row.
+ */
+function addPerNodeHealthCheck(next_node_num)
+{
+ var html = '<tbody id="tb_per_node_healthcheck_' + next_node_num + '">' +
+ '<tr id="tr_hc_node_num_' + next_node_num +
+ '" name="tr_hc_node_num"><th colspan="2">' +
+ '<span class="param_group">Backend node ' + next_node_num + '</span>' +
+ '<input id="add_per_node_health_check_' + next_node_num +
+ '" type="button" name="add" value="Add" onclick="addPerNodeHealthCheckForm($(this))" />' +
+ '</th></tr>';
+
+ $('#tb_global_healthcheck').find('tr').each(function()
{
- toggleTbody($(this));
+ html += '<tr style="display: none">' + $(this).html() + '</tr>';
});
-});
+
+ html += '</tbody>';
+
+ $('#t_healthcheck').append(html);
+ $('#tr_hc_node_num_' + next_node_num).nextAll('tr').find('input').val('');
+
+ $('#tb_per_node_healthcheck_' + next_node_num).find('input[name^=health_check], input[name=connect_timeout]').each(function()
+ {
+ var name = $(this).attr('name');
+ $(this).attr('name', name + next_node_num)
+ });
+}
+
+/*
+ * Add per node health check form by using "add" button of health check table.
+ */
+var addPerNodeHealthCheckForm = function()
+{
+ var node_num = $(this).parents('tbody').attr('id').split('_')[4];
+
+ $(this).parents('tbody').find('tr').show();
+ $('#tr_hc_node_num_' + node_num).nextAll('tr').find('input').val('');
+}
+
+/*
+ * Delete backend node form
+ */
+var deleteBackendForm = function()
+{
+ var deleted_node_num = $(this).attr('id').split('_')[3];
+ $('#tb_backends_node_' + deleted_node_num).remove();
+}
+
+/*
+ * Delete per node health check form
+ */
+var deletePerNodeHealthCheckForm = function()
+{
+ var node_num = $(this).parents('tbody').attr('id').split('_')[4];
+
+ $('#tr_hc_node_num_' + node_num).nextAll('tr').find('input').val('');
+ $(this).parents('tr').nextAll('tr').css('display', 'none');
+}
diff --git a/lang/ja.lang.php b/lang/ja.lang.php
index 67fb8de..f1da802 100644
--- a/lang/ja.lang.php
+++ b/lang/ja.lang.php
@@ -27,6 +27,7 @@ $message = array(
'lang' => 'ja',
'strLang' => '日本語',
+ 'descAllow_multiple_failover_requests_from_node' => '単一のPgpool-IIノードが複数のフェイルオーバ投票ができるどうか',
'descAllow_sql_comments' => '負荷分散やクエリキャッシュができるかどうかの判定の際に、SQLコメントを無視するかどうか',
'descApp_name_redirect_preference_list' => 'アプリケーション名によって負荷分散をしたいノード番号を、"アプリケーション名:ノード番号"で指定',
'descArping_path' => 'IP アドレス切り替え後に ARP リクエストを送信するコマンドのパス',
@@ -51,6 +52,7 @@ $message = array(
'descConnection_cache' => 'コネクションキャッシュ機能の有無',
'descConnection_life_time' => 'コネクションプール中のコネクションの有効期間(秒)',
'descConnect_timeout' => 'connect()システムコールを使ってバックエンドに接続する際のタイムアウト値を指定(ミリ秒)',
+ 'descConnect_timeout0' => 'connect()システムコールを使ってバックエンドに接続する際のタイムアウト値を指定(ミリ秒)',
'descDatabase_redirect_preference_list' => 'データベース名によって負荷分散をしたいノード番号を、"データベース名:ノード番号"で指定',
'descDebug_level' => 'デバッグメッセージの詳細レベル(0は無効)',
'descDelay_threshold' => '許容するスタンバイサーバの遅延(バイト)',
@@ -60,18 +62,30 @@ $message = array(
'descFailover_command' => 'ノード切り離し時に起動するコマンド',
'descFailback_command' => 'ノード復帰時に起動するコマンド',
'descFailover_if_affected_tuples_mismatch' => '更新行数が一致しないときにフェイルオーバ',
+ 'descFailover_require_consensus' => 'クォーラム投票によりフェイルオーバを実行するかどうか',
+ 'descFailover_when_quorum_exists' => 'クォーラム機能によりフェイルオーバを実行するかどうか',
'descFail_over_on_backend_error' => 'DBノードへのソケット通信エラー時にフェイルオーバ',
'descFollow_master_command' => 'マスタのフェイルオーバ後に実行するコマンド',
'descHeartbeat_destination' => 'ハートビート信号の送信先ホスト名または IP アドレス',
+ 'descHeartbeat_destination0' => 'ハートビート信号の送信先ホスト名または IP アドレス',
'descHeartbeat_destination_port' => 'ハートビート信号の送信先ポート番号',
+ 'descHeartbeat_destination_port0' => 'ハートビート信号の送信先ポート番号',
'descHeartbeat_device' => 'ハートビートの送受信に用いるネットワークデバイス名',
+ 'descHeartbeat_device0' => 'ハートビートの送受信に用いるネットワークデバイス名',
'descHealth_check_database' => 'ヘルスチェックを行う対象のデータベース名',
+ 'descHealth_check_database0' => 'ヘルスチェックを行う対象のデータベース名',
'descHealth_check_period' => 'ヘルスチェックを行なう間隔(秒)',
+ 'descHealth_check_period0' => 'ヘルスチェックを行なう間隔(秒)',
'descHealth_check_timeout' => 'ヘルスチェックが長時間待たされるのを防ぐためのタイムアウト値(秒)',
+ 'descHealth_check_timeout0' => 'ヘルスチェックが長時間待たされるのを防ぐためのタイムアウト値(秒)',
'descHealth_check_user' => 'ヘルスチェックを行うためのPostgreSQLユーザ名',
+ 'descHealth_check_user0' => 'ヘルスチェックを行うためのPostgreSQLユーザ名',
'descHealth_check_password' => 'ヘルスチェックを行うためのPostgreSQLパスワード',
+ 'descHealth_check_password0' => 'ヘルスチェックを行うためのPostgreSQLパスワード',
'descHealth_check_max_retries' => 'ヘルスチェックに失敗した後にリトライする回数',
+ 'descHealth_check_max_retries0' => 'ヘルスチェックに失敗した後にリトライする回数',
'descHealth_check_retry_delay' => 'ヘルスチェックのリトライの間の間隔(秒)',
+ 'descHealth_check_retry_delay0' => 'ヘルスチェックのリトライの間の間隔(秒)',
'descIfconfig_path' => 'ifconfig コマンドのパス',
'descIf_cmd_path' => 'if コマンドのパス',
'descIf_down_cmd' => '仮想 IP を停止するために実行するコマンド',
diff --git a/libs/plugins/function.custom_tr_pgconfig.php b/libs/plugins/function.custom_tr_pgconfig.php
index 122ba13..663da6a 100644
--- a/libs/plugins/function.custom_tr_pgconfig.php
+++ b/libs/plugins/function.custom_tr_pgconfig.php
@@ -62,7 +62,13 @@ function input($param, $param_in_form, $num)
$val_arr = $select_options[$param];
- $user_val = $params[$param];
+ // in case of per node health_check parameters,
+ // key is "health_check_period0"
+ if (preg_match('/^(health_check|connect_time).*[a-z]$/', $param)) {
+ $user_val = $params[$param . $num];
+ } else {
+ $user_val = $params[$param];
+ }
if (is_array($user_val)) {
$user_val = ($num !== NULL) ? $user_val[$num] : NULL;
}
@@ -85,7 +91,14 @@ function select($param, $param_in_form, $num)
{
global $params, $errors, $pgpoolConfigParamAll;
- $user_val = $params[$param];
+ // in case of per node health_check parameters,
+ // key is "health_check_period0"
+ if (preg_match('/^(health_check|connect_time).*[a-z]$/', $param)) {
+ $user_val = $params[$param . $num];
+ } else {
+ $user_val = $params[$param];
+ }
+
if ($user_val == '') {
$user_val = $param_info['default'];
}
diff --git a/pgconfig.php b/pgconfig.php
index 1ce0ea2..c3ee583 100644
--- a/pgconfig.php
+++ b/pgconfig.php
@@ -74,6 +74,7 @@ switch ($action) {
$tpl->assign('isAdd', ($action == 'add'));
$tpl->assign('isAddWd', ($action == 'add_wd'));
$tpl->assign('isAddHeartbeatDestination', ($action == 'add_heartbeat_destination'));
+ $tpl->assign('isAddHealthcheckPerNode', ($action == 'add_healthcheck_per_node'));
$tpl->display('pgconfig.tpl');
return;
@@ -104,9 +105,11 @@ switch ($action) {
switch ($action) {
case 'update':
$configValue = arrangePostData();
+
$error = doCheck();
if (! $error) {
+
if (is_writable(_PGPOOL2_CONFIG_FILE)) {
writeConfigFile($configValue, $pgpoolConfigParamAll);
$tpl->assign('status', 'success');
@@ -130,6 +133,7 @@ switch ($action) {
case 'delete':
case 'delete_wd':
case 'delete_heartbeat_destination':
+ case 'delete_healthcheck_per_node':
$num = $_POST['num'];
switch ($action) {
@@ -139,19 +143,8 @@ switch ($action) {
deleteWdOther($num, $configValue); break;
case 'delete_heartbeat_destination':
deleteHeartbeatDestination($num, $configValue); break;
- }
-
- if (is_writable(_PGPOOL2_CONFIG_FILE)) {
- writeConfigFile($configValue, $pgpoolConfigParamAll);
-
- // Read all params again
- $configValue = readConfigParams();
-
- } else {
- $errorCode = 'e4003';
- $tpl->assign('errorCode', $errorCode);
- $tpl->display('error.tpl');
- exit();
+ case 'delete_healthcheck_per_node':
+ deleteHealthcheckPerNode($num, $configValue); break;
}
break;
@@ -181,6 +174,12 @@ if (! isset($configValue['other_pgpool_hostname'])) {
$configValue['other_wd_port'][0] = NULL;
}
+if (! isset($configValue['health_check_period'])) {
+ $configValue['health_check_period0'][0] = NULL;
+ $configValue['other_pgpool_port'][0] = NULL;
+ $configValue['other_wd_port'][0] = NULL;
+}
+
$tpl->assign('error', $error);
$tpl->assign('params', $configValue);
$params = $configValue; // referenced by smarty_function_custom_tr_pgconfig()
@@ -408,7 +407,7 @@ function checkLogical($configValue)
function writeConfigFile($configValue, $pgpoolConfigParamAll)
{
$configFile = array();
-
+
$originalConfigFile = @file(_PGPOOL2_CONFIG_FILE);
foreach ($originalConfigFile as $line) {
// Not-empty lines
@@ -416,14 +415,14 @@ function writeConfigFile($configValue, $pgpoolConfigParamAll)
list($key, $value) = explode("=", $line);
$key = trim($key);
- $num = preg_replace('/[^0-9]/', NULL, $key);
- $key_wo_num = str_replace($num, NULL, $key);
+ $key_wo_num = preg_replace('/\d*$/', '', $key);
// Modify the parameter' value if posted.
- // (Ignore the params like "backend_hostname_0" which will be arranged in below)
- if (! isset($pgpoolConfigParamAll[$key_wo_num]['multiple'])) {
+ // (Ignore the params like "backend_hostname_0" and "health_check_*" which will be arranged in below)
+ if (! isset($pgpoolConfigParamAll[$key_wo_num]['multiple']) &&
+ ! isset($pgpoolConfigParamAll[$key_wo_num]['healthcheck'])) {
if (isset($configValue[$key_wo_num])) {
- $value = $configValue[$key];
+ $value = $configValue[$key_wo_num];
if (strcmp($pgpoolConfigParamAll[$key_wo_num]['type'], "C") == 0) {
$value = "'{$value}'";
}
@@ -440,7 +439,47 @@ function writeConfigFile($configValue, $pgpoolConfigParamAll)
}
}
+ /*
+ * global health check parameters
+ */
+ $health_check_params = getPerNodeHealthCheckParams();
+ if (isset($configValue['health_check_period'])) {
+ foreach ($health_check_params as $key) {
+ $value = (isset($configValue[$key])) ? $configValue[$key] : NULL;
+
+ if (strcmp($pgpoolConfigParamAll[$key]['type'], "C") == 0) {
+ $value = "'{$value}'";
+ }
+
+ $configFile[] = "{$key} = {$value}\n";
+ }
+ }
+
+ /*
+ * per node health check parameters
+ */
+ $i = 0;
+
+ foreach ($configValue as $k => $v) {
+ if (preg_match("/^health_check_period\d+$/", $k)) {
+ $num = preg_replace("/[^0-9]/", '', $k);
+ foreach ($health_check_params as $key) {
+ $value = (isset($configValue[$key . $num])) ? $configValue[$key . $num] : NULL;
+
+ if (strcmp($pgpoolConfigParamAll[$key]['type'], "C") == 0) {
+ $value = "'{$value}'";
+ }
+ $configFile[] = "{$key}{$num} = {$value}\n";
+ }
+ }
+
+ }
+
+ /*
+ * multiple parameters
+ */
$param_names = getMultiParams();
+
foreach ($param_names as $group => $key_arr) {
if (! isset($configValue[$key_arr[0]])) {
continue;
@@ -528,6 +567,23 @@ function deleteHeartbeatDestination($num, &$configValue)
}
/**
+ * Delete an heartbeat device
+ */
+function deleteHealthcheckPerNode($num, &$configValue)
+{
+ if (!isset($configValue['heartbeat_destination'])) { return; }
+
+ unset($configValue['heartbeat_destination'][$num]);
+ $configValue['heartbeat_destination'] = array_values($configValue['heartbeat_destination']);
+
+ unset($configValue['heartbeat_destination_port'][$num]);
+ $configValue['heartbeat_destination_port'] = array_values($configValue['heartbeat_destination_port']);
+
+ unset($configValue['heartbeat_device'][$num]);
+ $configValue['heartbeat_device'] = array_values($configValue['heartbeat_device']);
+}
+
+/**
* Arrange post data
*/
function arrangePostData()
@@ -703,6 +759,7 @@ function doCheck()
global $pgpoolConfigBackendParam;
global $pgpoolConfigHbDestinationParam;
global $pgpoolConfigWdOtherParam;
+ global $pgpoolConfigHealthCheckParam;
global $_POST;
$error = array();
@@ -715,10 +772,38 @@ function doCheck()
}
/*
+ * Delete empty backend node
+ */
+ foreach ($_POST['backend_hostname'] as $no => $str) {
+ if ($str == '') {
+ foreach ($pgpoolConfigBackendParam as $key => $value) {
+ unset($_POST[$key][$no]);
+ }
+ }
+ }
+
+ /*
* copy backend value from POST data to $configValue
*/
foreach ($pgpoolConfigBackendParam as $key => $value) {
- if (isset($_POST[$key])) {
+ if (isset($_POST[$key]) && $_POST[$key] != '') {
+
+ /*
+ * set per node health check params
+ */
+ if ($key == 'backend_hostname') {
+
+ foreach ($_POST[$key] as $no => $str) {
+ if (isset($_POST['health_check_period' . $no]) &&
+ $_POST['health_check_period' . $no] != '') {
+ $health_check_params = getPerNodeHealthCheckParams();
+ foreach ($health_check_params as $param) {
+ $configValue[$param . $no] = trim($_POST[$param . $no]);
+ }
+ }
+ }
+ }
+
$configValue[$key] = $_POST[$key];
}
}
diff --git a/templates/pgconfig.tpl b/templates/pgconfig.tpl
index 5424da0..abbc86f 100644
--- a/templates/pgconfig.tpl
+++ b/templates/pgconfig.tpl
@@ -151,21 +151,20 @@
<h3 id="backends">Backends</h3>
{* ===================================================================== *}
- <table>
- {custom_table_pgconfig}
+ <table id="t_backends">
+ {custom_table_pgconfig}
- <tbody id="tb_backends_node">
{* --------------------------------------------------------------------- *}
<tr><th class="category" colspan="2">Backend node
- <input type="button" name="add" value="{$message.strAdd|escape}" onclick="sendForm('add')" />
+ <input id="add_backends_node" type="button" name="add" value="{$message.strAdd|escape}" />
</th></tr>
{* --------------------------------------------------------------------- *}
- {foreach from=$params.backend_hostname key=node_num item=v}
- <tr><th colspan="2">
+ {foreach from=$params.backend_hostname key=node_num item=v}
+ <tbody id="tb_backends_node_{$node_num}">
+ <tr id="tr_ba_node_num_{$node_num}" name="tr_ba_node_num"><th colspan="2">
<span class="param_group">Backend node {$node_num}</span>
- <input type="button" name="delete" value="{$message.strDelete|escape}"
- onclick="sendForm('delete', {$node_num})" />
+ <input id="delete_backends_node_{$node_num}" type="button" name="delete" value="{$message.strDelete|escape}" />
</th></tr>
{custom_tr_pgconfig param='backend_hostname' num=$node_num}
{custom_tr_pgconfig param='backend_port' num=$node_num}
@@ -174,23 +173,9 @@
{if paramExists('backend_flag')}
{custom_tr_pgconfig param='backend_flag' num=$node_num}
{/if}
- {/foreach}
+ </tbody>
+ {/foreach}
- {if isset($isAdd) && $isAdd == true}
- <tr><th class="category" colspan="2">
- <span class="param_group">Backend node {$node_num + 1}</span>
- <input type="button" name="delete" value="{$message.strDelete|escape}"
- onclick="sendForm('delete', {$node_num})" />
- </th></tr>
- {custom_tr_pgconfig param='backend_hostname' num=$node_num+1}
- {custom_tr_pgconfig param='backend_port' num=$node_num+1}
- {custom_tr_pgconfig param='backend_weight' num=$node_num+1}
- {custom_tr_pgconfig param='backend_data_directory' num=$node_num+1}
- {if paramExists('backend_flag')}
- {custom_tr_pgconfig param='backend_flag' num=$node_num+1}
- {/if}
- {/if}
- </tbody>
</table>
{* ===================================================================== *}
@@ -443,13 +428,14 @@
{/if}
{* ===================================================================== *}
- <h3 id="health-check">Health Check</h3>
+ <h3 id="health-check">Health Check GLOBAL PARAMETERS</h3>
{* ===================================================================== *}
- <table>
+ <table id="t_healthcheck">
{custom_table_pgconfig}
- <tbody id="tb_healthcheck">
+ <tbody id="tb_global_healthcheck">
+
{custom_tr_pgconfig param='health_check_period'}
{custom_tr_pgconfig param='health_check_timeout'}
{custom_tr_pgconfig param='health_check_user'}
@@ -468,7 +454,44 @@
{if paramExists('connect_timeout')}
{custom_tr_pgconfig param='connect_timeout'}
{/if}
+
</tbody>
+
+ <tr><th class="category" colspan="2">Per Node Parameters</th></tr>
+
+ {foreach from=$params.backend_hostname key=node_num item=v}
+ <tbody id="tb_per_node_healthcheck_{$node_num}">
+ <tr id="tr_hc_node_num_{$node_num}"><th colspan="2">
+ <span class="param_group">Backend node {$node_num}</span>
+ {if definedHealthCheckParam($params, 'health_check_period', $node_num)}
+ <input id="delete_per_node_health_check_{$node_num}" type="button" name="delete" value="{$message.strDelete|escape}" />
+ {/if}
+ {if ! definedHealthCheckParam($params, 'health_check_period', $node_num)}
+ <input id="add_per_node_health_check_{$node_num}" type="button" name="add" value="{$message.strAdd|escape}" />
+ {/if}
+ </tr>
+
+ {custom_tr_pgconfig param='health_check_period' num=$node_num}
+ {custom_tr_pgconfig param='health_check_timeout' num=$node_num}
+ {custom_tr_pgconfig param='health_check_user' num=$node_num}
+ {if paramExists('health_check_password')}
+ {custom_tr_pgconfig param='health_check_password' num=$node_num}
+ {/if}
+ {if paramExists('health_check_database')}
+ {custom_tr_pgconfig param='health_check_database' num=$node_num}
+ {/if}
+ {if paramExists('health_check_max_retries')}
+ {custom_tr_pgconfig param='health_check_max_retries' num=$node_num}
+ {/if}
+ {if paramExists('health_check_retry_delay')}
+ {custom_tr_pgconfig param='health_check_retry_delay' num=$node_num}
+ {/if}
+ {if paramExists('connect_timeout')}
+ {custom_tr_pgconfig param='connect_timeout' num=$node_num}
+ {/if}
+
+ </tbody>
+ {/foreach}
</table>
{* ===================================================================== *}
@@ -580,6 +603,17 @@
{/if}
</tbody>
+ <tbody id="tb_watchdog_use_watchdog_on_failover">
+
+ {* --------------------------------------------------------------------- *}
+ <tr><th class="category" colspan="4">Quorum failover behavior Setting</th></tr>
+ {* --------------------------------------------------------------------- *}
+
+ {custom_tr_pgconfig param='failover_when_quorum_exists'}
+ {custom_tr_pgconfig param='failover_require_consensus'}
+ {custom_tr_pgconfig param='allow_multiple_failover_requests_from_node'}
+ </tbody>
+
<tbody id="tb_watchdog_use_watchdog_on_lifecheck_common">
{* --------------------------------------------------------------------- *}
<tr><th class="category" colspan="4">Lifecheck Setting (common)</th></tr>
diff --git a/version.php b/version.php
index 566cea2..de18373 100644
--- a/version.php
+++ b/version.php
@@ -23,6 +23,6 @@
* @version SVN: $Id$
*/
-$version = '3.6.2';
+$version = '3.7.0';
?>