diff --git a/doc.ja/src/sgml/example-cluster.sgml b/doc.ja/src/sgml/example-cluster.sgml index 809f1f050..ef92431e9 100644 --- a/doc.ja/src/sgml/example-cluster.sgml +++ b/doc.ja/src/sgml/example-cluster.sgml @@ -813,7 +813,7 @@ PCP_USER=pgpool オンラインリカバリの設定 - 続いて、オンラインリカバリを実行するPostgreSQLユーザ及びオンラインリカバリ時に呼び出されるスクリプトを設定します。 + 続いて、オンラインリカバリ()を実行するPostgreSQLユーザ及びオンラインリカバリ時に呼び出されるスクリプトを設定します。 オンラインリカバリで実行されるpgpool_recovery関数は PostgreSQLのスーパーユーザ権限が必要なため、recovery_userスーパーユーザを指定しなければなりません。 ここでは、postgresユーザを指定します。 @@ -852,9 +852,9 @@ PGHOME=/usr/pgsql-17 - また、オンラインリカバリ機能を使用するには、pgpool_recovery、 - pgpool_remote_startpgpool_switch_xlogという関数が必要になるので、 - server1のtemplate1にpgpool_recoveryをインストールしておきます。 + また、オンラインリカバリ機能を使用するには、pgpool_recoverypgpool_remote_startpgpool_switch_xlogの各関数をあらかじめで指定されたデータベース(デフォルトは'template1'です)に作成しておく必要があります。 + server1上で以下のコマンドを実行し、これらの関数をtemplate1に作成します。 + にデフォルト以外の値が設定されている場合は、template1をその設定値に置き換えてください。 [root@server1 ~]# psql -U postgres template1 -c "CREATE EXTENSION pgpool_recovery" diff --git a/doc.ja/src/sgml/example-replication-si-mode.sgml b/doc.ja/src/sgml/example-replication-si-mode.sgml index 4ed4ee3e1..51d007970 100644 --- a/doc.ja/src/sgml/example-replication-si-mode.sgml +++ b/doc.ja/src/sgml/example-replication-si-mode.sgml @@ -567,13 +567,12 @@ PGHOME=/usr/pgsql-15 - また、オンラインリカバリ機能を使用するには、pgpool_recovery、 - pgpool_remote_startpgpool_switch_xlogという関数が必要になるので、 - server1のtemplate1にpgpool_recoveryをインストールしておきます。 + また、オンラインリカバリ機能を使用するには、pgpool_recoverypgpool_remote_startpgpool_switch_xlogの各関数をあらかじめで指定されたデータベース(デフォルトは'template1'です)に作成しておく必要があります。 + server1上で以下のコマンドを実行し、これらの関数をtemplate1に作成します。 + にデフォルト以外の値が設定されている場合は、template1をその設定値に置き換えてください。 -[server1]# su - postgres -[server1]$ psql template1 -c "CREATE EXTENSION pgpool_recovery" +[server1]# psql -U postgres template1 -c "CREATE EXTENSION pgpool_recovery" diff --git a/doc.ja/src/sgml/installation.sgml b/doc.ja/src/sgml/installation.sgml index 439f77ffe..b7282a1c8 100644 --- a/doc.ja/src/sgml/installation.sgml +++ b/doc.ja/src/sgml/installation.sgml @@ -526,7 +526,7 @@ make install It is enough, if these function installed in template1 first. These function do not needed that install in all databases. --> - 後述の オンラインリカバリ の機能を使う場合には、 pgpool_recovery, pgpool_remote_start, pgpool_switch_xlog という関数が必要です。 + 後述のオンラインリカバリの機能を使う場合には、 pgpool_recoverypgpool_remote_start、およびpgpool_switch_xlogという関数が必要です。 また管理ツールである pgpoolAdmin の画面上から、バックエンドノードの PostgreSQL を停止・再起動・設定再読み込みを行なうことができますが、これには pgpool_pgctl という関数が使われます。 これらの関数は、すべてのデータベースにインストールされている必要はなく、template1 にだけで 構いません。 @@ -543,9 +543,17 @@ $ make $ make install - この後に以下か、 + この後、以下のコマンドを実行して、で指定されたデータベースに(デフォルトは'template1'です)pgpool_recoverypgpool_remote_startおよびpgpool_switch_xlog関数を作成します。 + にデフォルト以外の値が設定されている場合は、"template1"をその設定値に置き換えてください。 $ psql template1 =# CREATE EXTENSION pgpool_recovery; diff --git a/doc.ja/src/sgml/online-recovery.sgml b/doc.ja/src/sgml/online-recovery.sgml index aa0617b1b..a391c7471 100644 --- a/doc.ja/src/sgml/online-recovery.sgml +++ b/doc.ja/src/sgml/online-recovery.sgml @@ -346,6 +346,58 @@ + + recovery_database (string) + + + recovery_database 設定パラメータ + + + + + + オンラインリカバリを行うためのPostgreSQLデータベースです。 + デフォルトは'template1'です。 + 空文字('')が指定された場合、Pgpool-IIは + 「postgres」データベースの使用を試みます。 + + + + このパラメータはPgpool-IIの設定を再読み込みすることで変更可能です。 + + + + + オンラインリカバリを実行するには、パラメータで指定されたデータベースに、pgpool_recovery、pgpool_remote_start、および pgpool_switch_xlog 関数を作成しておく必要があります。 + これらの関数をデフォルトのデータベースtemplate1に作成するには、以下のコマンドを実行してください。 + (デフォルト値以外が設定されている場合は、template1に設定された値に置き換えてください) + +$ psql template1 -c "CREATE EXTENSION pgpool_recovery" + + + + + + recovery_1st_stage_command (string) diff --git a/doc/src/sgml/example-cluster.sgml b/doc/src/sgml/example-cluster.sgml index d5a4150ea..71f3f474e 100644 --- a/doc/src/sgml/example-cluster.sgml +++ b/doc/src/sgml/example-cluster.sgml @@ -866,7 +866,8 @@ PCP_USER=pgpool Pgpool-II Online Recovery Configurations - Next, configure the required parameters to perform online recovery. + Next, configure the required parameters to perform online recovery + (). Because Superuser privilege in PostgreSQL is required for performing online recovery, we specify postgres user in . In this example, we leave @@ -909,11 +910,16 @@ PGHOME=/usr/pgsql-17 - In order to use the online recovery functionality, the functions of - pgpool_recovery, pgpool_remote_start, - pgpool_switch_xlog are required, so we need to install - pgpool_recovery on template1 of PostgreSQL server - server1. + In addition, to perform online recovery, the functions + pgpool_recovery, pgpool_remote_start + and pgpool_switch_xlog must be created in advance + in the database specified by + (the default is 'template1'). + Execute the following command to create these functions in + template1 on server1. + If a value other than the default is configured for + , replace template1 + with the configured value. [root@server1 ~]# psql -U postgres template1 -c "CREATE EXTENSION pgpool_recovery" diff --git a/doc/src/sgml/example-replication-si-mode.sgml b/doc/src/sgml/example-replication-si-mode.sgml index e06b91e77..395c7c23c 100644 --- a/doc/src/sgml/example-replication-si-mode.sgml +++ b/doc/src/sgml/example-replication-si-mode.sgml @@ -559,15 +559,19 @@ PGHOME=/usr/pgsql-14 - In order to use the online recovery functionality, the functions of - pgpool_recovery, pgpool_remote_start, - pgpool_switch_xlog are required, so we need to install - pgpool_recovery on template1 of PostgreSQL server - server1. + In addition, to perform online recovery, the functions + pgpool_recovery, pgpool_remote_start + and pgpool_switch_xlog must be created in advance + in the database specified by + (the default is 'template1'). + Execute the following command to create these functions in + template1 on server1. + If a value other than the default is configured for + , replace template1 + with the configured value. -[server1]# su - postgres -[server1]$ psql template1 -c "CREATE EXTENSION pgpool_recovery" +[server1]# psql -U postgres template1 -c "CREATE EXTENSION pgpool_recovery" diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml index aae7de632..422ee8c63 100644 --- a/doc/src/sgml/installation.sgml +++ b/doc/src/sgml/installation.sgml @@ -455,7 +455,14 @@ $ cd pgpool-II-&version/src/sql/pgpool-recovery $ make $ make install - After this: + After this, execute the following command to create the functions + pgpool_recovery, pgpool_remote_start + and pgpool_switch_xlog in the database specified in + + (The default is 'template1'). + If a value other than the default is configured for + , replace "template1" + with the setting of . $ psql template1 =# CREATE EXTENSION pgpool_recovery; diff --git a/doc/src/sgml/online-recovery.sgml b/doc/src/sgml/online-recovery.sgml index 55092a744..6207ed230 100644 --- a/doc/src/sgml/online-recovery.sgml +++ b/doc/src/sgml/online-recovery.sgml @@ -248,6 +248,41 @@ + + recovery_database (string) + + recovery_database configuration parameter + + + + + Specifies the PostgreSQL database name to be used for online recovery. + The default is 'template1'. If an empty string ('') + is specified, Pgpool-II will attempt to use + the "postgres" database. + + + This parameter can be changed by reloading the Pgpool-II configurations. + + + + To perform online recovery, the functions pgpool_recovery, + pgpool_remote_start and + pgpool_switch_xlog must be created in the database + specified by the parameter. + To install these functions in the default database + "template1", execute the following command + (if a value other than the default is configured, replace + "template1" with the setting of + recovery_database): + +$ psql template1 -c "CREATE EXTENSION pgpool_recovery" + + + + + + recovery_1st_stage_command (string) diff --git a/src/config/pool_config_variables.c b/src/config/pool_config_variables.c index 5e61f02db..734cfc7c9 100644 --- a/src/config/pool_config_variables.c +++ b/src/config/pool_config_variables.c @@ -1027,6 +1027,16 @@ static struct config_string ConfigureNamesString[] = NULL, NULL, NULL, NULL }, + { + {"recovery_database", CFGCXT_RELOAD, RECOVERY_CONFIG, + "The database name for online recovery.", + CONFIG_VAR_TYPE_STRING, false, 0 + }, + &g_pool_config.recovery_database, + "template1", + NULL, NULL, NULL, NULL + }, + { {"recovery_1st_stage_command", CFGCXT_RELOAD, RECOVERY_CONFIG, "Command to execute in first stage recovery.", diff --git a/src/include/pool_config.h b/src/include/pool_config.h index 96b15af54..4dece394e 100644 --- a/src/include/pool_config.h +++ b/src/include/pool_config.h @@ -184,8 +184,7 @@ typedef struct int health_check_period; /* health check period */ char *health_check_user; /* PostgreSQL user name for health check */ char *health_check_password; /* password for health check username */ - char *health_check_database; /* database name for health check - * username */ + char *health_check_database; /* database name for health check */ int health_check_max_retries; /* health check max retries */ int health_check_retry_delay; /* amount of time to wait between * retries */ @@ -352,8 +351,7 @@ typedef struct int health_check_period; /* health check period */ char *health_check_user; /* PostgreSQL user name for health check */ char *health_check_password; /* password for health check username */ - char *health_check_database; /* database name for health check - * username */ + char *health_check_database; /* database name for health check */ int health_check_max_retries; /* health check max retries */ int health_check_retry_delay; /* amount of time to wait between * retries */ @@ -386,6 +384,7 @@ typedef struct char *recovery_user; /* PostgreSQL user name for online recovery */ char *recovery_password; /* PostgreSQL user password for online * recovery */ + char *recovery_database; /* Database name for recovery */ char *recovery_1st_stage_command; /* Online recovery command in 1st * stage */ char *recovery_2nd_stage_command; /* Online recovery command in 2nd diff --git a/src/pcp_con/recovery.c b/src/pcp_con/recovery.c index a104b4c06..f2381d04e 100644 --- a/src/pcp_con/recovery.c +++ b/src/pcp_con/recovery.c @@ -463,16 +463,25 @@ connect_backend_libpq(BackendInfo * backend) { char port_str[16]; PGconn *conn; + char *dbname; char *password = get_pgpool_config_user_password(pool_config->recovery_user, pool_config->recovery_password); snprintf(port_str, sizeof(port_str), "%d", backend->backend_port); + /* + * If database is not specified, "postgres" database is assumed. + */ + if (*pool_config->recovery_database == '\0') + dbname = "postgres"; + else + dbname = pool_config->recovery_database; + conn = PQsetdbLogin(backend->backend_hostname, port_str, NULL, NULL, - "template1", + pool_config->recovery_database, pool_config->recovery_user, password ? password : ""); diff --git a/src/sample/pgpool.conf.sample-stream b/src/sample/pgpool.conf.sample-stream index 217e9d055..bfc05cb10 100644 --- a/src/sample/pgpool.conf.sample-stream +++ b/src/sample/pgpool.conf.sample-stream @@ -666,6 +666,9 @@ backend_clustering_mode = 'streaming_replication' # Leaving it empty will make Pgpool-II to first look for the # Password in pool_passwd file before using the empty password +#recovery_database = 'template1' + # Database name for online recovery + #recovery_1st_stage_command = '' # Executes a command in first stage #recovery_2nd_stage_command = '' diff --git a/src/utils/pool_process_reporting.c b/src/utils/pool_process_reporting.c index 71f871bc4..506265d29 100644 --- a/src/utils/pool_process_reporting.c +++ b/src/utils/pool_process_reporting.c @@ -774,6 +774,11 @@ get_config(int *nrows) StrNCpy(status[i].desc, "online recovery user", POOLCONFIG_MAXDESCLEN); i++; + StrNCpy(status[i].name, "recovery_database", POOLCONFIG_MAXNAMELEN); + snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->recovery_database); + StrNCpy(status[i].desc, "database name for online recovery", POOLCONFIG_MAXDESCLEN); + i++; + StrNCpy(status[i].name, "recovery_1st_stage_command", POOLCONFIG_MAXNAMELEN); snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->recovery_1st_stage_command); StrNCpy(status[i].desc, "execute a command in first stage.", POOLCONFIG_MAXDESCLEN);