mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 15:16:29 +00:00
Compare commits
73 Commits
REL4_2_STA
...
REL4_1_STA
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
222f7e6080 | ||
|
|
446695e328 | ||
|
|
ec3da13e22 | ||
|
|
1488c014ff | ||
|
|
f471316504 | ||
|
|
726299f7ef | ||
|
|
7fda2a1bcf | ||
|
|
d26141b8ab | ||
|
|
4a6b5fe913 | ||
|
|
a71e644255 | ||
|
|
8646fd6004 | ||
|
|
3e1bb1a523 | ||
|
|
f5e58fc062 | ||
|
|
6b95a96f3a | ||
|
|
bd146ae9ac | ||
|
|
c7f8e48d12 | ||
|
|
322190516c | ||
|
|
31a49ff781 | ||
|
|
a6f99b58dd | ||
|
|
09b041433e | ||
|
|
058c8168e1 | ||
|
|
0468e47ef3 | ||
|
|
216326f316 | ||
|
|
3fb20ce774 | ||
|
|
e468ca859e | ||
|
|
623c84c022 | ||
|
|
c2dded1d7b | ||
|
|
457dbbd267 | ||
|
|
5485c06bc1 | ||
|
|
00ae42eb07 | ||
|
|
33525491ae | ||
|
|
8c84f7a214 | ||
|
|
efe4bed88e | ||
|
|
9ba8dcbac3 | ||
|
|
a8996a5bfa | ||
|
|
4cbba98193 | ||
|
|
23e6b85de3 | ||
|
|
d5ecb09f22 | ||
|
|
719dd93676 | ||
|
|
5747f1d446 | ||
|
|
9313b43cb1 | ||
|
|
5aeb1b0589 | ||
|
|
6c93388848 | ||
|
|
d4ad8ce20c | ||
|
|
bacab8d31c | ||
|
|
14856e3a4d | ||
|
|
ca9242badb | ||
|
|
ff0929e882 | ||
|
|
8cd1811edb | ||
|
|
bf15c0d40f | ||
|
|
9ae9d31165 | ||
|
|
d5064bdc02 | ||
|
|
9d0524a008 | ||
|
|
5398fd2d22 | ||
|
|
4c44c01380 | ||
|
|
5113ab0274 | ||
|
|
25f68bb283 | ||
|
|
730f67258c | ||
|
|
ca0e4de1ee | ||
|
|
2fb0f056fe | ||
|
|
3a789d53e0 | ||
|
|
fb67b2cd4f | ||
|
|
9f07804b6a | ||
|
|
d5b2fa2309 | ||
|
|
d696c4019e | ||
|
|
e6ffbcc67a | ||
|
|
e1410831e0 | ||
|
|
cb4f6f6e3f | ||
|
|
75e5d79654 | ||
|
|
55fbe12971 | ||
|
|
db4199e08f | ||
|
|
0d9ed02729 | ||
|
|
8e9f0b802b |
4
FAQ.md
4
FAQ.md
@@ -1,10 +1,8 @@
|
|||||||
FAQ - Frequently Asked Questions about repmgr
|
FAQ - Frequently Asked Questions about repmgr
|
||||||
=============================================
|
=============================================
|
||||||
|
|
||||||
The repmgr 4 FAQ is located here: [repmgr FAQ (Frequently Asked Questions)](https://repmgr.org/docs/current/appendix-faq.html "repmgr FAQ")
|
The repmgr 4 FAQ is located here: [repmgr FAQ (Frequently Asked Questions)](https://repmgr.org/docs/4.0/appendix-faq.html "repmgr FAQ")
|
||||||
|
|
||||||
The repmgr 3.x FAQ can be found here:
|
The repmgr 3.x FAQ can be found here:
|
||||||
|
|
||||||
https://github.com/2ndQuadrant/repmgr/blob/REL3_3_STABLE/FAQ.md
|
https://github.com/2ndQuadrant/repmgr/blob/REL3_3_STABLE/FAQ.md
|
||||||
|
|
||||||
Note that repmgr 3.x is no longer supported.
|
|
||||||
|
|||||||
11
HISTORY
11
HISTORY
@@ -1,14 +1,3 @@
|
|||||||
4.2 2018-10-24
|
|
||||||
repmgr: add parameter "shutdown_check_timeout" for use by "standby switchover";
|
|
||||||
GitHub #504 (Ian)
|
|
||||||
repmgr: add "--node-id" option to "repmgr cluster cleanup"; GitHub #493 (Ian)
|
|
||||||
repmgr: report unreachable nodes when running "repmgr cluster (matrix|crosscheck);
|
|
||||||
GitHub #246 (Ian)
|
|
||||||
repmgr: add configuration file parameter "repmgr_bindir"; GitHub #246 (Ian)
|
|
||||||
repmgr: fix "Missing replication slots" label in "node check"; GitHub #507 (Ian)
|
|
||||||
repmgrd: fix parsing of -d/--daemonize option (Ian)
|
|
||||||
repmgrd: support "pausing" of repmgrd (Ian)
|
|
||||||
|
|
||||||
4.1.1 2018-09-05
|
4.1.1 2018-09-05
|
||||||
logging: explicitly log the text of failed queries as ERRORs to
|
logging: explicitly log the text of failed queries as ERRORs to
|
||||||
assist logfile analysis; GitHub #498
|
assist logfile analysis; GitHub #498
|
||||||
|
|||||||
15
Makefile.in
15
Makefile.in
@@ -13,9 +13,8 @@ DATA = \
|
|||||||
repmgr--unpackaged--4.0.sql \
|
repmgr--unpackaged--4.0.sql \
|
||||||
repmgr--4.0.sql \
|
repmgr--4.0.sql \
|
||||||
repmgr--4.0--4.1.sql \
|
repmgr--4.0--4.1.sql \
|
||||||
repmgr--4.1.sql \
|
repmgr--4.1.sql
|
||||||
repmgr--4.1--4.2.sql \
|
|
||||||
repmgr--4.2.sql
|
|
||||||
|
|
||||||
REGRESS = repmgr_extension
|
REGRESS = repmgr_extension
|
||||||
|
|
||||||
@@ -30,24 +29,19 @@ all: \
|
|||||||
PG_CPPFLAGS = -std=gnu89 -I$(includedir_internal) -I$(libpq_srcdir) -Wall -Wmissing-prototypes -Wmissing-declarations $(EXTRA_CFLAGS)
|
PG_CPPFLAGS = -std=gnu89 -I$(includedir_internal) -I$(libpq_srcdir) -Wall -Wmissing-prototypes -Wmissing-declarations $(EXTRA_CFLAGS)
|
||||||
SHLIB_LINK = $(libpq)
|
SHLIB_LINK = $(libpq)
|
||||||
|
|
||||||
|
HEADERS = $(wildcard *.h)
|
||||||
|
|
||||||
OBJS = \
|
OBJS = \
|
||||||
repmgr.o
|
repmgr.o
|
||||||
|
|
||||||
include Makefile.global
|
include Makefile.global
|
||||||
|
|
||||||
ifeq ($(vpath_build),yes)
|
|
||||||
HEADERS = $(wildcard *.h)
|
|
||||||
else
|
|
||||||
HEADERS_built = $(wildcard *.h)
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(info Building against PostgreSQL $(MAJORVERSION))
|
$(info Building against PostgreSQL $(MAJORVERSION))
|
||||||
|
|
||||||
REPMGR_CLIENT_OBJS = repmgr-client.o \
|
REPMGR_CLIENT_OBJS = repmgr-client.o \
|
||||||
repmgr-action-primary.o repmgr-action-standby.o repmgr-action-witness.o \
|
repmgr-action-primary.o repmgr-action-standby.o repmgr-action-witness.o \
|
||||||
repmgr-action-bdr.o repmgr-action-cluster.o repmgr-action-node.o repmgr-action-daemon.o \
|
repmgr-action-bdr.o repmgr-action-cluster.o repmgr-action-node.o \
|
||||||
configfile.o log.o strutil.o controldata.o dirutil.o compat.o dbutils.o
|
configfile.o log.o strutil.o controldata.o dirutil.o compat.o dbutils.o
|
||||||
REPMGRD_OBJS = repmgrd.o repmgrd-physical.o repmgrd-bdr.o configfile.o log.o dbutils.o strutil.o controldata.o compat.o
|
REPMGRD_OBJS = repmgrd.o repmgrd-physical.o repmgrd-bdr.o configfile.o log.o dbutils.o strutil.o controldata.o compat.o
|
||||||
DATE=$(shell date "+%Y-%m-%d")
|
DATE=$(shell date "+%Y-%m-%d")
|
||||||
@@ -91,7 +85,6 @@ additional-clean:
|
|||||||
rm -f repmgr-action-bdr.o
|
rm -f repmgr-action-bdr.o
|
||||||
rm -f repmgr-action-node.o
|
rm -f repmgr-action-node.o
|
||||||
rm -f repmgr-action-cluster.o
|
rm -f repmgr-action-cluster.o
|
||||||
rm -f repmgr-action-daemon.o
|
|
||||||
rm -f repmgrd.o
|
rm -f repmgrd.o
|
||||||
rm -f repmgrd-physical.o
|
rm -f repmgrd-physical.o
|
||||||
rm -f repmgrd-bdr.o
|
rm -f repmgrd-bdr.o
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ operations.
|
|||||||
`repmgr 4` is a complete rewrite of the existing `repmgr` codebase, allowing
|
`repmgr 4` is a complete rewrite of the existing `repmgr` codebase, allowing
|
||||||
the use of all of the latest features in PostgreSQL replication.
|
the use of all of the latest features in PostgreSQL replication.
|
||||||
|
|
||||||
PostgreSQL 11, 10, 9.6 and 9.5 are fully supported.
|
PostgreSQL 10, 9.6 and 9.5 are fully supported.
|
||||||
PostgreSQL 9.4 and 9.3 are supported, with some restrictions.
|
PostgreSQL 9.4 and 9.3 are supported, with some restrictions.
|
||||||
|
|
||||||
`repmgr` is distributed under the GNU GPL 3 and maintained by 2ndQuadrant.
|
`repmgr` is distributed under the GNU GPL 3 and maintained by 2ndQuadrant.
|
||||||
@@ -19,7 +19,7 @@ PostgreSQL 9.4 and 9.3 are supported, with some restrictions.
|
|||||||
|
|
||||||
`repmgr 4` supports monitoring of a two-node BDR 2.0 cluster on PostgreSQL 9.6
|
`repmgr 4` supports monitoring of a two-node BDR 2.0 cluster on PostgreSQL 9.6
|
||||||
only. Note that BDR 2.0 is not publicly available; please contact 2ndQuadrant
|
only. Note that BDR 2.0 is not publicly available; please contact 2ndQuadrant
|
||||||
for details.
|
for details. `repmgr 4` will support future public BDR releases.
|
||||||
|
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
@@ -27,7 +27,7 @@ Documentation
|
|||||||
|
|
||||||
The main `repmgr` documentation is available here:
|
The main `repmgr` documentation is available here:
|
||||||
|
|
||||||
> [repmgr 4 documentation](https://repmgr.org/docs/4.2/index.html)
|
> [repmgr 4 documentation](https://repmgr.org/docs/4.0/index.html)
|
||||||
|
|
||||||
The `README` file for `repmgr` 3.x is available here:
|
The `README` file for `repmgr` 3.x is available here:
|
||||||
|
|
||||||
|
|||||||
24
configfile.c
24
configfile.c
@@ -88,7 +88,8 @@ load_config(const char *config_file, bool verbose, bool terse, t_configuration_o
|
|||||||
|
|
||||||
if (pwd != NULL)
|
if (pwd != NULL)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&fullpath, pwd);
|
appendPQExpBuffer(&fullpath,
|
||||||
|
"%s", pwd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -104,7 +105,9 @@ load_config(const char *config_file, bool verbose, bool terse, t_configuration_o
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBufferStr(&fullpath, cwd);
|
appendPQExpBuffer(&fullpath,
|
||||||
|
"%s",
|
||||||
|
cwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBuffer(&fullpath,
|
appendPQExpBuffer(&fullpath,
|
||||||
@@ -285,7 +288,6 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
|||||||
memset(options->data_directory, 0, sizeof(options->data_directory));
|
memset(options->data_directory, 0, sizeof(options->data_directory));
|
||||||
memset(options->config_directory, 0, sizeof(options->data_directory));
|
memset(options->config_directory, 0, sizeof(options->data_directory));
|
||||||
memset(options->pg_bindir, 0, sizeof(options->pg_bindir));
|
memset(options->pg_bindir, 0, sizeof(options->pg_bindir));
|
||||||
memset(options->repmgr_bindir, 0, sizeof(options->repmgr_bindir));
|
|
||||||
options->replication_type = REPLICATION_TYPE_PHYSICAL;
|
options->replication_type = REPLICATION_TYPE_PHYSICAL;
|
||||||
|
|
||||||
/*-------------
|
/*-------------
|
||||||
@@ -333,7 +335,6 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
|||||||
* standby switchover settings
|
* standby switchover settings
|
||||||
*------------------------
|
*------------------------
|
||||||
*/
|
*/
|
||||||
options->shutdown_check_timeout = DEFAULT_SHUTDOWN_CHECK_TIMEOUT;
|
|
||||||
options->standby_reconnect_timeout = DEFAULT_STANDBY_RECONNECT_TIMEOUT;
|
options->standby_reconnect_timeout = DEFAULT_STANDBY_RECONNECT_TIMEOUT;
|
||||||
|
|
||||||
/*-----------------
|
/*-----------------
|
||||||
@@ -488,8 +489,6 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
|||||||
}
|
}
|
||||||
else if (strcmp(name, "pg_bindir") == 0)
|
else if (strcmp(name, "pg_bindir") == 0)
|
||||||
strncpy(options->pg_bindir, value, MAXPGPATH);
|
strncpy(options->pg_bindir, value, MAXPGPATH);
|
||||||
else if (strcmp(name, "repmgr_bindir") == 0)
|
|
||||||
strncpy(options->repmgr_bindir, value, MAXPGPATH);
|
|
||||||
|
|
||||||
else if (strcmp(name, "replication_type") == 0)
|
else if (strcmp(name, "replication_type") == 0)
|
||||||
{
|
{
|
||||||
@@ -546,8 +545,6 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
|||||||
options->standby_follow_timeout = repmgr_atoi(value, name, error_list, 0);
|
options->standby_follow_timeout = repmgr_atoi(value, name, error_list, 0);
|
||||||
|
|
||||||
/* standby switchover settings */
|
/* standby switchover settings */
|
||||||
else if (strcmp(name, "shutdown_check_timeout") == 0)
|
|
||||||
options->shutdown_check_timeout = repmgr_atoi(value, name, error_list, 0);
|
|
||||||
else if (strcmp(name, "standby_reconnect_timeout") == 0)
|
else if (strcmp(name, "standby_reconnect_timeout") == 0)
|
||||||
options->standby_reconnect_timeout = repmgr_atoi(value, name, error_list, 0);
|
options->standby_reconnect_timeout = repmgr_atoi(value, name, error_list, 0);
|
||||||
|
|
||||||
@@ -816,13 +813,13 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
|||||||
if (options->archive_ready_warning >= options->archive_ready_critical)
|
if (options->archive_ready_warning >= options->archive_ready_critical)
|
||||||
{
|
{
|
||||||
item_list_append(error_list,
|
item_list_append(error_list,
|
||||||
_("\"archive_ready_critical\" must be greater than \"archive_ready_warning\""));
|
_("\archive_ready_critical\" must be greater than \"archive_ready_warning\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options->replication_lag_warning >= options->replication_lag_critical)
|
if (options->replication_lag_warning >= options->replication_lag_critical)
|
||||||
{
|
{
|
||||||
item_list_append(error_list,
|
item_list_append(error_list,
|
||||||
_("\"replication_lag_critical\" must be greater than \"replication_lag_warning\""));
|
_("\replication_lag_critical\" must be greater than \"replication_lag_warning\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options->standby_reconnect_timeout < options->node_rejoin_timeout)
|
if (options->standby_reconnect_timeout < options->node_rejoin_timeout)
|
||||||
@@ -1108,8 +1105,8 @@ reload_config(t_configuration_options *orig_options, t_server_type server_type)
|
|||||||
|
|
||||||
initPQExpBuffer(&errors);
|
initPQExpBuffer(&errors);
|
||||||
|
|
||||||
appendPQExpBufferStr(&errors,
|
appendPQExpBuffer(&errors,
|
||||||
"following errors were detected:\n");
|
"following errors were detected:\n");
|
||||||
|
|
||||||
for (cell = config_errors.head; cell; cell = cell->next)
|
for (cell = config_errors.head; cell; cell = cell->next)
|
||||||
{
|
{
|
||||||
@@ -1531,9 +1528,6 @@ parse_bool(const char *s, const char *config_item, ItemList *error_list)
|
|||||||
{
|
{
|
||||||
PQExpBufferData errors;
|
PQExpBufferData errors;
|
||||||
|
|
||||||
if (s == NULL)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (strcasecmp(s, "0") == 0)
|
if (strcasecmp(s, "0") == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ typedef struct
|
|||||||
char data_directory[MAXPGPATH];
|
char data_directory[MAXPGPATH];
|
||||||
char config_directory[MAXPGPATH];
|
char config_directory[MAXPGPATH];
|
||||||
char pg_bindir[MAXPGPATH];
|
char pg_bindir[MAXPGPATH];
|
||||||
char repmgr_bindir[MAXPGPATH];
|
|
||||||
int replication_type;
|
int replication_type;
|
||||||
|
|
||||||
/* log settings */
|
/* log settings */
|
||||||
@@ -104,7 +103,6 @@ typedef struct
|
|||||||
int standby_follow_timeout;
|
int standby_follow_timeout;
|
||||||
|
|
||||||
/* standby switchover settings */
|
/* standby switchover settings */
|
||||||
int shutdown_check_timeout;
|
|
||||||
int standby_reconnect_timeout;
|
int standby_reconnect_timeout;
|
||||||
|
|
||||||
/* node rejoin settings */
|
/* node rejoin settings */
|
||||||
@@ -172,7 +170,7 @@ typedef struct
|
|||||||
|
|
||||||
#define T_CONFIGURATION_OPTIONS_INITIALIZER { \
|
#define T_CONFIGURATION_OPTIONS_INITIALIZER { \
|
||||||
/* node information */ \
|
/* node information */ \
|
||||||
UNKNOWN_NODE_ID, "", "", "", "", "", "", "", REPLICATION_TYPE_PHYSICAL, \
|
UNKNOWN_NODE_ID, "", "", "", "", "", "", REPLICATION_TYPE_PHYSICAL, \
|
||||||
/* log settings */ \
|
/* log settings */ \
|
||||||
"", "", "", DEFAULT_LOG_STATUS_INTERVAL, \
|
"", "", "", DEFAULT_LOG_STATUS_INTERVAL, \
|
||||||
/* standby clone settings */ \
|
/* standby clone settings */ \
|
||||||
@@ -183,7 +181,6 @@ typedef struct
|
|||||||
DEFAULT_PRIMARY_FOLLOW_TIMEOUT, \
|
DEFAULT_PRIMARY_FOLLOW_TIMEOUT, \
|
||||||
DEFAULT_STANDBY_FOLLOW_TIMEOUT, \
|
DEFAULT_STANDBY_FOLLOW_TIMEOUT, \
|
||||||
/* standby switchover settings */ \
|
/* standby switchover settings */ \
|
||||||
DEFAULT_SHUTDOWN_CHECK_TIMEOUT, \
|
|
||||||
DEFAULT_STANDBY_RECONNECT_TIMEOUT, \
|
DEFAULT_STANDBY_RECONNECT_TIMEOUT, \
|
||||||
/* node rejoin settings */ \
|
/* node rejoin settings */ \
|
||||||
DEFAULT_NODE_REJOIN_TIMEOUT, \
|
DEFAULT_NODE_REJOIN_TIMEOUT, \
|
||||||
|
|||||||
18
configure
vendored
18
configure
vendored
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Guess values for system-dependent variables and create Makefiles.
|
# Guess values for system-dependent variables and create Makefiles.
|
||||||
# Generated by GNU Autoconf 2.69 for repmgr 4.2.
|
# Generated by GNU Autoconf 2.69 for repmgr 4.1.2.
|
||||||
#
|
#
|
||||||
# Report bugs to <pgsql-bugs@postgresql.org>.
|
# Report bugs to <pgsql-bugs@postgresql.org>.
|
||||||
#
|
#
|
||||||
@@ -582,8 +582,8 @@ MAKEFLAGS=
|
|||||||
# Identity of this package.
|
# Identity of this package.
|
||||||
PACKAGE_NAME='repmgr'
|
PACKAGE_NAME='repmgr'
|
||||||
PACKAGE_TARNAME='repmgr'
|
PACKAGE_TARNAME='repmgr'
|
||||||
PACKAGE_VERSION='4.2'
|
PACKAGE_VERSION='4.1.2'
|
||||||
PACKAGE_STRING='repmgr 4.2'
|
PACKAGE_STRING='repmgr 4.1.2'
|
||||||
PACKAGE_BUGREPORT='pgsql-bugs@postgresql.org'
|
PACKAGE_BUGREPORT='pgsql-bugs@postgresql.org'
|
||||||
PACKAGE_URL='https://2ndquadrant.com/en/resources/repmgr/'
|
PACKAGE_URL='https://2ndquadrant.com/en/resources/repmgr/'
|
||||||
|
|
||||||
@@ -1178,7 +1178,7 @@ if test "$ac_init_help" = "long"; then
|
|||||||
# Omit some internal or obsolete options to make the list less imposing.
|
# Omit some internal or obsolete options to make the list less imposing.
|
||||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||||
cat <<_ACEOF
|
cat <<_ACEOF
|
||||||
\`configure' configures repmgr 4.2 to adapt to many kinds of systems.
|
\`configure' configures repmgr 4.1.2 to adapt to many kinds of systems.
|
||||||
|
|
||||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||||
|
|
||||||
@@ -1239,7 +1239,7 @@ fi
|
|||||||
|
|
||||||
if test -n "$ac_init_help"; then
|
if test -n "$ac_init_help"; then
|
||||||
case $ac_init_help in
|
case $ac_init_help in
|
||||||
short | recursive ) echo "Configuration of repmgr 4.2:";;
|
short | recursive ) echo "Configuration of repmgr 4.1.2:";;
|
||||||
esac
|
esac
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
|
|
||||||
@@ -1313,7 +1313,7 @@ fi
|
|||||||
test -n "$ac_init_help" && exit $ac_status
|
test -n "$ac_init_help" && exit $ac_status
|
||||||
if $ac_init_version; then
|
if $ac_init_version; then
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
repmgr configure 4.2
|
repmgr configure 4.1.2
|
||||||
generated by GNU Autoconf 2.69
|
generated by GNU Autoconf 2.69
|
||||||
|
|
||||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||||
@@ -1332,7 +1332,7 @@ cat >config.log <<_ACEOF
|
|||||||
This file contains any messages produced by compilers while
|
This file contains any messages produced by compilers while
|
||||||
running configure, to aid debugging if configure makes a mistake.
|
running configure, to aid debugging if configure makes a mistake.
|
||||||
|
|
||||||
It was created by repmgr $as_me 4.2, which was
|
It was created by repmgr $as_me 4.1.2, which was
|
||||||
generated by GNU Autoconf 2.69. Invocation command line was
|
generated by GNU Autoconf 2.69. Invocation command line was
|
||||||
|
|
||||||
$ $0 $@
|
$ $0 $@
|
||||||
@@ -2359,7 +2359,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
|||||||
# report actual input values of CONFIG_FILES etc. instead of their
|
# report actual input values of CONFIG_FILES etc. instead of their
|
||||||
# values after options handling.
|
# values after options handling.
|
||||||
ac_log="
|
ac_log="
|
||||||
This file was extended by repmgr $as_me 4.2, which was
|
This file was extended by repmgr $as_me 4.1.2, which was
|
||||||
generated by GNU Autoconf 2.69. Invocation command line was
|
generated by GNU Autoconf 2.69. Invocation command line was
|
||||||
|
|
||||||
CONFIG_FILES = $CONFIG_FILES
|
CONFIG_FILES = $CONFIG_FILES
|
||||||
@@ -2422,7 +2422,7 @@ _ACEOF
|
|||||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||||
ac_cs_version="\\
|
ac_cs_version="\\
|
||||||
repmgr config.status 4.2
|
repmgr config.status 4.1.2
|
||||||
configured by $0, generated by GNU Autoconf 2.69,
|
configured by $0, generated by GNU Autoconf 2.69,
|
||||||
with options \\"\$ac_cs_config\\"
|
with options \\"\$ac_cs_config\\"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
AC_INIT([repmgr], [4.2], [pgsql-bugs@postgresql.org], [repmgr], [https://2ndquadrant.com/en/resources/repmgr/])
|
AC_INIT([repmgr], [4.1.2], [pgsql-bugs@postgresql.org], [repmgr], [https://2ndquadrant.com/en/resources/repmgr/])
|
||||||
|
|
||||||
AC_COPYRIGHT([Copyright (c) 2010-2018, 2ndQuadrant Ltd.])
|
AC_COPYRIGHT([Copyright (c) 2010-2018, 2ndQuadrant Ltd.])
|
||||||
|
|
||||||
|
|||||||
638
dbutils.c
638
dbutils.c
@@ -30,8 +30,6 @@
|
|||||||
#include "controldata.h"
|
#include "controldata.h"
|
||||||
#include "dirutil.h"
|
#include "dirutil.h"
|
||||||
|
|
||||||
#define NODE_RECORD_PARAM_COUNT 11
|
|
||||||
|
|
||||||
/* mainly for use by repmgrd */
|
/* mainly for use by repmgrd */
|
||||||
int server_version_num = UNKNOWN_SERVER_VERSION_NUM;
|
int server_version_num = UNKNOWN_SERVER_VERSION_NUM;
|
||||||
|
|
||||||
@@ -117,20 +115,20 @@ wrap_ddl_query(PQExpBufferData *query_buf, int replication_type, const char *fmt
|
|||||||
if (replication_type == REPLICATION_TYPE_BDR)
|
if (replication_type == REPLICATION_TYPE_BDR)
|
||||||
{
|
{
|
||||||
if (bdr_version_num < 3)
|
if (bdr_version_num < 3)
|
||||||
appendPQExpBufferStr(query_buf, "SELECT bdr.bdr_replicate_ddl_command($repmgr$");
|
appendPQExpBuffer(query_buf, "SELECT bdr.bdr_replicate_ddl_command($repmgr$");
|
||||||
else
|
else
|
||||||
appendPQExpBufferStr(query_buf, "SELECT bdr.replicate_ddl_command($repmgr$");
|
appendPQExpBuffer(query_buf, "SELECT bdr.replicate_ddl_command($repmgr$");
|
||||||
}
|
}
|
||||||
|
|
||||||
va_start(arglist, fmt);
|
va_start(arglist, fmt);
|
||||||
vsnprintf(buf, MAXLEN, fmt, arglist);
|
vsnprintf(buf, MAXLEN, fmt, arglist);
|
||||||
va_end(arglist);
|
va_end(arglist);
|
||||||
|
|
||||||
appendPQExpBufferStr(query_buf, buf);
|
appendPQExpBuffer(query_buf, "%s", buf);
|
||||||
|
|
||||||
if (replication_type == REPLICATION_TYPE_BDR)
|
if (replication_type == REPLICATION_TYPE_BDR)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(query_buf, "$repmgr$)");
|
appendPQExpBuffer(query_buf, "$repmgr$)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1072,9 +1070,9 @@ get_cluster_size(PGconn *conn, char *size)
|
|||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
"SELECT pg_catalog.pg_size_pretty(pg_catalog.sum(pg_catalog.pg_database_size(oid))::bigint) "
|
"SELECT pg_catalog.pg_size_pretty(pg_catalog.sum(pg_catalog.pg_database_size(oid))::bigint) "
|
||||||
" FROM pg_catalog.pg_database ");
|
" FROM pg_catalog.pg_database ");
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_cluster_size():\n%s", query.data);
|
log_verbose(LOG_DEBUG, "get_cluster_size():\n%s", query.data);
|
||||||
|
|
||||||
@@ -1230,13 +1228,13 @@ _get_primary_connection(PGconn *conn,
|
|||||||
log_verbose(LOG_INFO, _("searching for primary node"));
|
log_verbose(LOG_INFO, _("searching for primary node"));
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT node_id, conninfo, "
|
" SELECT node_id, conninfo, "
|
||||||
" CASE WHEN type = 'primary' THEN 1 ELSE 2 END AS type_priority"
|
" CASE WHEN type = 'primary' THEN 1 ELSE 2 END AS type_priority"
|
||||||
" FROM repmgr.nodes "
|
" FROM repmgr.nodes "
|
||||||
" WHERE active IS TRUE "
|
" WHERE active IS TRUE "
|
||||||
" AND type != 'witness' "
|
" AND type != 'witness' "
|
||||||
"ORDER BY active DESC, type_priority, priority, node_id");
|
"ORDER BY active DESC, type_priority, priority, node_id");
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_primary_connection():\n%s", query.data);
|
log_verbose(LOG_DEBUG, "get_primary_connection():\n%s", query.data);
|
||||||
|
|
||||||
@@ -1343,11 +1341,11 @@ get_primary_node_id(PGconn *conn)
|
|||||||
int retval = NODE_NOT_FOUND;
|
int retval = NODE_NOT_FOUND;
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
"SELECT node_id "
|
"SELECT node_id "
|
||||||
" FROM repmgr.nodes "
|
" FROM repmgr.nodes "
|
||||||
" WHERE type = 'primary' "
|
" WHERE type = 'primary' "
|
||||||
" AND active IS TRUE ");
|
" AND active IS TRUE ");
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_primary_node_id():\n%s", query.data);
|
log_verbose(LOG_DEBUG, "get_primary_node_id():\n%s", query.data);
|
||||||
|
|
||||||
@@ -1386,38 +1384,38 @@ get_replication_info(PGconn *conn, ReplInfo *replication_info)
|
|||||||
server_version_num = get_server_version(conn, NULL);
|
server_version_num = get_server_version(conn, NULL);
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT ts, "
|
" SELECT ts, "
|
||||||
" last_wal_receive_lsn, "
|
" last_wal_receive_lsn, "
|
||||||
" last_wal_replay_lsn, "
|
" last_wal_replay_lsn, "
|
||||||
" last_xact_replay_timestamp, "
|
" last_xact_replay_timestamp, "
|
||||||
" CASE WHEN (last_wal_receive_lsn = last_wal_replay_lsn) "
|
" CASE WHEN (last_wal_receive_lsn = last_wal_replay_lsn) "
|
||||||
" THEN 0::INT "
|
" THEN 0::INT "
|
||||||
" ELSE "
|
" ELSE "
|
||||||
" EXTRACT(epoch FROM (pg_catalog.clock_timestamp() - last_xact_replay_timestamp))::INT "
|
" EXTRACT(epoch FROM (pg_catalog.clock_timestamp() - last_xact_replay_timestamp))::INT "
|
||||||
" END AS replication_lag_time, "
|
" END AS replication_lag_time, "
|
||||||
" COALESCE(last_wal_receive_lsn, '0/0') >= last_wal_replay_lsn AS receiving_streamed_wal "
|
" COALESCE(last_wal_receive_lsn, '0/0') >= last_wal_replay_lsn AS receiving_streamed_wal "
|
||||||
" FROM ( ");
|
" FROM ( ");
|
||||||
|
|
||||||
if (server_version_num >= 100000)
|
if (server_version_num >= 100000)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT CURRENT_TIMESTAMP AS ts, "
|
" SELECT CURRENT_TIMESTAMP AS ts, "
|
||||||
" pg_catalog.pg_last_wal_receive_lsn() AS last_wal_receive_lsn, "
|
" pg_catalog.pg_last_wal_receive_lsn() AS last_wal_receive_lsn, "
|
||||||
" pg_catalog.pg_last_wal_replay_lsn() AS last_wal_replay_lsn, "
|
" pg_catalog.pg_last_wal_replay_lsn() AS last_wal_replay_lsn, "
|
||||||
" pg_catalog.pg_last_xact_replay_timestamp() AS last_xact_replay_timestamp ");
|
" pg_catalog.pg_last_xact_replay_timestamp() AS last_xact_replay_timestamp ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT CURRENT_TIMESTAMP AS ts, "
|
" SELECT CURRENT_TIMESTAMP AS ts, "
|
||||||
" pg_catalog.pg_last_xlog_receive_location() AS last_wal_receive_lsn, "
|
" pg_catalog.pg_last_xlog_receive_location() AS last_wal_receive_lsn, "
|
||||||
" pg_catalog.pg_last_xlog_replay_location() AS last_wal_replay_lsn, "
|
" pg_catalog.pg_last_xlog_replay_location() AS last_wal_replay_lsn, "
|
||||||
" pg_catalog.pg_last_xact_replay_timestamp() AS last_xact_replay_timestamp ");
|
" pg_catalog.pg_last_xact_replay_timestamp() AS last_xact_replay_timestamp ");
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" ) q ");
|
" ) q ");
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_replication_info():\n%s", query.data);
|
log_verbose(LOG_DEBUG, "get_replication_info():\n%s", query.data);
|
||||||
|
|
||||||
@@ -1540,21 +1538,21 @@ get_replication_lag_seconds(PGconn *conn)
|
|||||||
|
|
||||||
if (server_version_num >= 100000)
|
if (server_version_num >= 100000)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT CASE WHEN (pg_catalog.pg_last_wal_receive_lsn() = pg_catalog.pg_last_wal_replay_lsn()) ");
|
" SELECT CASE WHEN (pg_catalog.pg_last_wal_receive_lsn() = pg_catalog.pg_last_wal_replay_lsn()) ");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT CASE WHEN (pg_catalog.pg_last_xlog_receive_location() = pg_catalog.pg_last_xlog_replay_location()) ");
|
" SELECT CASE WHEN (pg_catalog.pg_last_xlog_receive_location() = pg_catalog.pg_last_xlog_replay_location()) ");
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" THEN 0 "
|
" THEN 0 "
|
||||||
" ELSE EXTRACT(epoch FROM (pg_catalog.clock_timestamp() - pg_catalog.pg_last_xact_replay_timestamp()))::INT "
|
" ELSE EXTRACT(epoch FROM (pg_catalog.clock_timestamp() - pg_catalog.pg_last_xact_replay_timestamp()))::INT "
|
||||||
" END "
|
" END "
|
||||||
" AS lag_seconds");
|
" AS lag_seconds");
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
log_verbose(LOG_DEBUG, "get_replication_lag_seconds():\n%s", query.data);
|
log_verbose(LOG_DEBUG, "get_replication_lag_seconds():\n%s", query.data);
|
||||||
@@ -1629,6 +1627,7 @@ repmgrd_set_local_node_id(PGconn *conn, int local_node_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
repmgrd_get_local_node_id(PGconn *conn)
|
repmgrd_get_local_node_id(PGconn *conn)
|
||||||
{
|
{
|
||||||
@@ -1687,135 +1686,6 @@ server_in_exclusive_backup_mode(PGconn *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
repmgrd_set_pid(PGconn *conn, pid_t repmgrd_pid, const char *pidfile)
|
|
||||||
{
|
|
||||||
PQExpBufferData query;
|
|
||||||
PGresult *res = NULL;
|
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "repmgrd_set_pid(): pid is %i", (int) repmgrd_pid);
|
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
|
||||||
"SELECT repmgr.set_repmgrd_pid(%i, '%s')",
|
|
||||||
(int) repmgrd_pid, pidfile);
|
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
|
||||||
termPQExpBuffer(&query);
|
|
||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
|
||||||
{
|
|
||||||
log_error(_("unable to execute \"SELECT repmgr.set_repmgrd_pid()\""));
|
|
||||||
log_detail("%s", PQerrorMessage(conn));
|
|
||||||
}
|
|
||||||
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
pid_t
|
|
||||||
repmgrd_get_pid(PGconn *conn)
|
|
||||||
{
|
|
||||||
PGresult *res = NULL;
|
|
||||||
pid_t repmgrd_pid = UNKNOWN_PID;
|
|
||||||
|
|
||||||
res = PQexec(conn, "SELECT repmgr.get_repmgrd_pid()");
|
|
||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
|
||||||
{
|
|
||||||
log_error(_("unable to execute \"SELECT repmgr.get_repmgrd_pid()\""));
|
|
||||||
log_detail("%s", PQerrorMessage(conn));
|
|
||||||
}
|
|
||||||
else if (!PQgetisnull(res, 0, 0))
|
|
||||||
{
|
|
||||||
repmgrd_pid = atoi(PQgetvalue(res, 0, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
return repmgrd_pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
repmgrd_is_running(PGconn *conn)
|
|
||||||
{
|
|
||||||
PGresult *res = NULL;
|
|
||||||
bool is_running = false;
|
|
||||||
|
|
||||||
res = PQexec(conn, "SELECT repmgr.repmgrd_is_running()");
|
|
||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
|
||||||
{
|
|
||||||
log_error(_("unable to execute \"SELECT repmgr.repmgrd_is_running()\""));
|
|
||||||
log_detail("%s", PQerrorMessage(conn));
|
|
||||||
}
|
|
||||||
else if (!PQgetisnull(res, 0, 0))
|
|
||||||
{
|
|
||||||
is_running = atobool(PQgetvalue(res, 0, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
return is_running;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
repmgrd_is_paused(PGconn *conn)
|
|
||||||
{
|
|
||||||
PGresult *res = NULL;
|
|
||||||
bool is_paused = false;
|
|
||||||
|
|
||||||
res = PQexec(conn, "SELECT repmgr.repmgrd_is_paused()");
|
|
||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
|
||||||
{
|
|
||||||
log_error(_("unable to execute \"SELECT repmgr.repmgrd_is_paused()\""));
|
|
||||||
log_detail("%s", PQerrorMessage(conn));
|
|
||||||
}
|
|
||||||
else if (!PQgetisnull(res, 0, 0))
|
|
||||||
{
|
|
||||||
is_paused = atobool(PQgetvalue(res, 0, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
return is_paused;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
repmgrd_pause(PGconn *conn, bool pause)
|
|
||||||
{
|
|
||||||
PQExpBufferData query;
|
|
||||||
PGresult *res = NULL;
|
|
||||||
bool success = true;
|
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
|
||||||
"SELECT repmgr.repmgrd_pause(%s)",
|
|
||||||
pause == true ? "TRUE" : "FALSE");
|
|
||||||
res = PQexec(conn, query.data);
|
|
||||||
termPQExpBuffer(&query);
|
|
||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
|
||||||
{
|
|
||||||
log_error(_("unable to execute \"SELECT repmgr.repmgrd_pause()\""));
|
|
||||||
log_detail("%s", PQerrorMessage(conn));
|
|
||||||
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================ */
|
/* ================ */
|
||||||
/* result functions */
|
/* result functions */
|
||||||
/* ================ */
|
/* ================ */
|
||||||
@@ -1834,7 +1704,7 @@ atobool(const char *value)
|
|||||||
/* =================== */
|
/* =================== */
|
||||||
|
|
||||||
ExtensionStatus
|
ExtensionStatus
|
||||||
get_repmgr_extension_status(PGconn *conn, t_extension_versions *extversions)
|
get_repmgr_extension_status(PGconn *conn)
|
||||||
{
|
{
|
||||||
PQExpBufferData query;
|
PQExpBufferData query;
|
||||||
PGresult *res = NULL;
|
PGresult *res = NULL;
|
||||||
@@ -1844,16 +1714,12 @@ get_repmgr_extension_status(PGconn *conn, t_extension_versions *extversions)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT ae.name, e.extname, "
|
" SELECT ae.name, e.extname "
|
||||||
" ae.default_version, "
|
" FROM pg_catalog.pg_available_extensions ae "
|
||||||
" (ae.default_version::numeric * 10)::INT AS available, "
|
"LEFT JOIN pg_catalog.pg_extension e "
|
||||||
" ae.installed_version, "
|
" ON e.extname=ae.name "
|
||||||
" (ae.installed_version::numeric * 10)::INT AS installed "
|
" WHERE ae.name='repmgr' ");
|
||||||
" FROM pg_catalog.pg_available_extensions ae "
|
|
||||||
"LEFT JOIN pg_catalog.pg_extension e "
|
|
||||||
" ON e.extname=ae.name "
|
|
||||||
" WHERE ae.name='repmgr' ");
|
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
|
|
||||||
@@ -1872,24 +1738,7 @@ get_repmgr_extension_status(PGconn *conn, t_extension_versions *extversions)
|
|||||||
/* 2. Check if extension installed */
|
/* 2. Check if extension installed */
|
||||||
else if (PQgetisnull(res, 0, 1) == 0)
|
else if (PQgetisnull(res, 0, 1) == 0)
|
||||||
{
|
{
|
||||||
int available_version = atoi(PQgetvalue(res, 0, 3));
|
status = REPMGR_INSTALLED;
|
||||||
int installed_version = atoi(PQgetvalue(res, 0, 5));
|
|
||||||
|
|
||||||
/* caller wants to know which versions are installed/available */
|
|
||||||
if (extversions != NULL)
|
|
||||||
{
|
|
||||||
strncpy(extversions->default_version, PQgetvalue(res, 0, 2), 7);
|
|
||||||
strncpy(extversions->installed_version, PQgetvalue(res, 0, 4), 7);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (available_version > installed_version)
|
|
||||||
{
|
|
||||||
status = REPMGR_OLD_VERSION_INSTALLED;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
status = REPMGR_INSTALLED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2249,38 +2098,37 @@ _populate_node_records(PGresult *res, NodeInfoList *node_list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
void
|
||||||
get_all_node_records(PGconn *conn, NodeInfoList *node_list)
|
get_all_node_records(PGconn *conn, NodeInfoList *node_list)
|
||||||
{
|
{
|
||||||
PQExpBufferData query;
|
PQExpBufferData query;
|
||||||
PGresult *res = NULL;
|
PGresult *res = NULL;
|
||||||
bool success = true;
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT " REPMGR_NODES_COLUMNS
|
" SELECT " REPMGR_NODES_COLUMNS
|
||||||
" FROM repmgr.nodes n "
|
" FROM repmgr.nodes n "
|
||||||
"ORDER BY n.node_id ");
|
"ORDER BY n.node_id ");
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_all_node_records():\n%s", query.data);
|
log_verbose(LOG_DEBUG, "get_all_node_records():\n%s", query.data);
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
|
|
||||||
/* this will return an empty list if there was an error executing the query */
|
|
||||||
_populate_node_records(res, node_list);
|
|
||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
log_db_error(conn, query.data, _("get_all_node_records(): unable to execute query"));
|
log_db_error(conn, query.data, _("get_all_node_records(): unable to execute query"));
|
||||||
success = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(res);
|
|
||||||
termPQExpBuffer(&query);
|
termPQExpBuffer(&query);
|
||||||
|
|
||||||
return success;
|
/* this will return an empty list if there was an error executing the query */
|
||||||
}
|
_populate_node_records(res, node_list);
|
||||||
|
|
||||||
|
PQclear(res);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
get_downstream_node_records(PGconn *conn, int node_id, NodeInfoList *node_list)
|
get_downstream_node_records(PGconn *conn, int node_id, NodeInfoList *node_list)
|
||||||
@@ -2363,10 +2211,10 @@ get_node_records_by_priority(PGconn *conn, NodeInfoList *node_list)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT " REPMGR_NODES_COLUMNS
|
" SELECT " REPMGR_NODES_COLUMNS
|
||||||
" FROM repmgr.nodes n "
|
" FROM repmgr.nodes n "
|
||||||
"ORDER BY n.priority DESC, n.node_name ");
|
"ORDER BY n.priority DESC, n.node_name ");
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_node_records_by_priority():\n%s", query.data);
|
log_verbose(LOG_DEBUG, "get_node_records_by_priority():\n%s", query.data);
|
||||||
|
|
||||||
@@ -2400,13 +2248,13 @@ get_all_node_records_with_upstream(PGconn *conn, NodeInfoList *node_list)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT n.node_id, n.type, n.upstream_node_id, n.node_name, n.conninfo, n.repluser, "
|
" SELECT n.node_id, n.type, n.upstream_node_id, n.node_name, n.conninfo, n.repluser, "
|
||||||
" n.slot_name, n.location, n.priority, n.active, n.config_file, un.node_name AS upstream_node_name "
|
" n.slot_name, n.location, n.priority, n.active, n.config_file, un.node_name AS upstream_node_name "
|
||||||
" FROM repmgr.nodes n "
|
" FROM repmgr.nodes n "
|
||||||
" LEFT JOIN repmgr.nodes un "
|
" LEFT JOIN repmgr.nodes un "
|
||||||
" ON un.node_id = n.upstream_node_id"
|
" ON un.node_id = n.upstream_node_id"
|
||||||
" ORDER BY n.node_id ");
|
" ORDER BY n.node_id ");
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_all_node_records_with_upstream():\n%s", query.data);
|
log_verbose(LOG_DEBUG, "get_all_node_records_with_upstream():\n%s", query.data);
|
||||||
|
|
||||||
@@ -2501,8 +2349,8 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info)
|
|||||||
|
|
||||||
char *slot_name_ptr = NULL;
|
char *slot_name_ptr = NULL;
|
||||||
|
|
||||||
int param_count = NODE_RECORD_PARAM_COUNT;
|
int param_count = 11;
|
||||||
const char *param_values[NODE_RECORD_PARAM_COUNT];
|
const char *param_values[param_count];
|
||||||
|
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
bool success = true;
|
bool success = true;
|
||||||
@@ -2549,30 +2397,31 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info)
|
|||||||
|
|
||||||
if (strcmp(action, "create") == 0)
|
if (strcmp(action, "create") == 0)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
"INSERT INTO repmgr.nodes "
|
"INSERT INTO repmgr.nodes "
|
||||||
" (node_id, type, upstream_node_id, "
|
" (node_id, type, upstream_node_id, "
|
||||||
" node_name, conninfo, repluser, slot_name, "
|
" node_name, conninfo, repluser, slot_name, "
|
||||||
" location, priority, active, config_file) "
|
" location, priority, active, config_file) "
|
||||||
"VALUES ($11, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10) ");
|
"VALUES ($11, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10) ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
"UPDATE repmgr.nodes SET "
|
"UPDATE repmgr.nodes SET "
|
||||||
" type = $1, "
|
" type = $1, "
|
||||||
" upstream_node_id = $2, "
|
" upstream_node_id = $2, "
|
||||||
" node_name = $3, "
|
" node_name = $3, "
|
||||||
" conninfo = $4, "
|
" conninfo = $4, "
|
||||||
" repluser = $5, "
|
" repluser = $5, "
|
||||||
" slot_name = $6, "
|
" slot_name = $6, "
|
||||||
" location = $7, "
|
" location = $7, "
|
||||||
" priority = $8, "
|
" priority = $8, "
|
||||||
" active = $9, "
|
" active = $9, "
|
||||||
" config_file = $10 "
|
" config_file = $10 "
|
||||||
" WHERE node_id = $11 ");
|
" WHERE node_id = $11 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
res = PQexecParams(conn,
|
res = PQexecParams(conn,
|
||||||
query.data,
|
query.data,
|
||||||
param_count,
|
param_count,
|
||||||
@@ -3009,31 +2858,31 @@ get_node_replication_stats(PGconn *conn, int server_version_num, t_node_info *no
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT pg_catalog.current_setting('max_wal_senders')::INT AS max_wal_senders, "
|
" SELECT pg_catalog.current_setting('max_wal_senders')::INT AS max_wal_senders, "
|
||||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_stat_replication) AS attached_wal_receivers, ");
|
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_stat_replication) AS attached_wal_receivers, ");
|
||||||
|
|
||||||
/* no replication slots in PostgreSQL 9.3 */
|
/* no replication slots in PostgreSQL 9.3 */
|
||||||
if (server_version_num < 90400)
|
if (server_version_num < 90400)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" 0 AS max_replication_slots, "
|
" 0 AS max_replication_slots, "
|
||||||
" 0 AS total_replication_slots, "
|
" 0 AS total_replication_slots, "
|
||||||
" 0 AS active_replication_slots, "
|
" 0 AS active_replication_slots, "
|
||||||
" 0 AS inactive_replication_slots, ");
|
" 0 AS inactive_replication_slots, ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" current_setting('max_replication_slots')::INT AS max_replication_slots, "
|
" current_setting('max_replication_slots')::INT AS max_replication_slots, "
|
||||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots) AS total_replication_slots, "
|
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots) AS total_replication_slots, "
|
||||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots WHERE active IS TRUE) AS active_replication_slots, "
|
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots WHERE active IS TRUE) AS active_replication_slots, "
|
||||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots WHERE active IS FALSE) AS inactive_replication_slots, ");
|
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots WHERE active IS FALSE) AS inactive_replication_slots, ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" pg_catalog.pg_is_in_recovery() AS in_recovery");
|
" pg_catalog.pg_is_in_recovery() AS in_recovery");
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_node_replication_stats():\n%s", query.data);
|
log_verbose(LOG_DEBUG, "get_node_replication_stats():\n%s", query.data);
|
||||||
|
|
||||||
@@ -3174,26 +3023,26 @@ get_datadir_configuration_files(PGconn *conn, KeyValueList *list)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
"WITH files AS ( "
|
"WITH files AS ( "
|
||||||
" WITH dd AS ( "
|
" WITH dd AS ( "
|
||||||
" SELECT setting "
|
" SELECT setting "
|
||||||
" FROM pg_catalog.pg_settings "
|
" FROM pg_catalog.pg_settings "
|
||||||
" WHERE name = 'data_directory') "
|
" WHERE name = 'data_directory') "
|
||||||
" SELECT distinct(sourcefile) AS config_file"
|
" SELECT distinct(sourcefile) AS config_file"
|
||||||
" FROM dd, pg_catalog.pg_settings ps "
|
" FROM dd, pg_catalog.pg_settings ps "
|
||||||
" WHERE ps.sourcefile IS NOT NULL "
|
" WHERE ps.sourcefile IS NOT NULL "
|
||||||
" AND ps.sourcefile ~ ('^' || dd.setting) "
|
" AND ps.sourcefile ~ ('^' || dd.setting) "
|
||||||
" UNION "
|
" UNION "
|
||||||
" SELECT ps.setting AS config_file"
|
" SELECT ps.setting AS config_file"
|
||||||
" FROM dd, pg_catalog.pg_settings ps "
|
" FROM dd, pg_catalog.pg_settings ps "
|
||||||
" WHERE ps.name IN ('config_file', 'hba_file', 'ident_file') "
|
" WHERE ps.name IN ('config_file', 'hba_file', 'ident_file') "
|
||||||
" AND ps.setting ~ ('^' || dd.setting) "
|
" AND ps.setting ~ ('^' || dd.setting) "
|
||||||
") "
|
") "
|
||||||
" SELECT config_file, "
|
" SELECT config_file, "
|
||||||
" pg_catalog.regexp_replace(config_file, '^.*\\/','') AS filename "
|
" pg_catalog.regexp_replace(config_file, '^.*\\/','') AS filename "
|
||||||
" FROM files "
|
" FROM files "
|
||||||
"ORDER BY config_file");
|
"ORDER BY config_file");
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
|
|
||||||
@@ -3230,18 +3079,18 @@ get_configuration_file_locations(PGconn *conn, t_configfile_list *list)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" WITH dd AS ( "
|
" WITH dd AS ( "
|
||||||
" SELECT setting AS data_directory"
|
" SELECT setting AS data_directory"
|
||||||
" FROM pg_catalog.pg_settings "
|
" FROM pg_catalog.pg_settings "
|
||||||
" WHERE name = 'data_directory' "
|
" WHERE name = 'data_directory' "
|
||||||
" ) "
|
" ) "
|
||||||
" SELECT DISTINCT(sourcefile), "
|
" SELECT DISTINCT(sourcefile), "
|
||||||
" pg_catalog.regexp_replace(sourcefile, '^.*\\/', '') AS filename, "
|
" pg_catalog.regexp_replace(sourcefile, '^.*\\/', '') AS filename, "
|
||||||
" sourcefile ~ ('^' || dd.data_directory) AS in_data_dir "
|
" sourcefile ~ ('^' || dd.data_directory) AS in_data_dir "
|
||||||
" FROM dd, pg_catalog.pg_settings ps "
|
" FROM dd, pg_catalog.pg_settings ps "
|
||||||
" WHERE sourcefile IS NOT NULL "
|
" WHERE sourcefile IS NOT NULL "
|
||||||
" ORDER BY 1 ");
|
" ORDER BY 1 ");
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_configuration_file_locations():\n %s",
|
log_verbose(LOG_DEBUG, "get_configuration_file_locations():\n %s",
|
||||||
query.data);
|
query.data);
|
||||||
@@ -3280,18 +3129,19 @@ get_configuration_file_locations(PGconn *conn, t_configfile_list *list)
|
|||||||
/* Fetch locations of pg_hba.conf and pg_ident.conf */
|
/* Fetch locations of pg_hba.conf and pg_ident.conf */
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" WITH dd AS ( "
|
" WITH dd AS ( "
|
||||||
" SELECT setting AS data_directory"
|
" SELECT setting AS data_directory"
|
||||||
" FROM pg_catalog.pg_settings "
|
" FROM pg_catalog.pg_settings "
|
||||||
" WHERE name = 'data_directory' "
|
" WHERE name = 'data_directory' "
|
||||||
" ) "
|
" ) "
|
||||||
" SELECT ps.setting, "
|
" SELECT ps.setting, "
|
||||||
" pg_catalog.regexp_replace(setting, '^.*\\/', '') AS filename, "
|
" pg_catalog.regexp_replace(setting, '^.*\\/', '') AS filename, "
|
||||||
" ps.setting ~ ('^' || dd.data_directory) AS in_data_dir "
|
" ps.setting ~ ('^' || dd.data_directory) AS in_data_dir "
|
||||||
" FROM dd, pg_catalog.pg_settings ps "
|
" FROM dd, pg_catalog.pg_settings ps "
|
||||||
" WHERE ps.name IN ('hba_file', 'ident_file') "
|
" WHERE ps.name IN ('hba_file', 'ident_file') "
|
||||||
" ORDER BY 1 ");
|
" ORDER BY 1 ");
|
||||||
|
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_configuration_file_locations():\n %s",
|
log_verbose(LOG_DEBUG, "get_configuration_file_locations():\n %s",
|
||||||
query.data);
|
query.data);
|
||||||
@@ -3465,15 +3315,15 @@ _create_event(PGconn *conn, t_configuration_options *options, int node_id, char
|
|||||||
int binary[4] = {1, 0, 0, 0};
|
int binary[4] = {1, 0, 0, 0};
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" INSERT INTO repmgr.events ( "
|
" INSERT INTO repmgr.events ( "
|
||||||
" node_id, "
|
" node_id, "
|
||||||
" event, "
|
" event, "
|
||||||
" successful, "
|
" successful, "
|
||||||
" details "
|
" details "
|
||||||
" ) "
|
" ) "
|
||||||
" VALUES ($1, $2, $3, $4) "
|
" VALUES ($1, $2, $3, $4) "
|
||||||
" RETURNING event_timestamp ");
|
" RETURNING event_timestamp ");
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "_create_event():\n %s", query.data);
|
log_verbose(LOG_DEBUG, "_create_event():\n %s", query.data);
|
||||||
|
|
||||||
@@ -3704,12 +3554,12 @@ get_event_records(PGconn *conn, int node_id, const char *node_name, const char *
|
|||||||
initPQExpBuffer(&where_clause);
|
initPQExpBuffer(&where_clause);
|
||||||
|
|
||||||
/* LEFT JOIN used here as a node record may have been removed */
|
/* LEFT JOIN used here as a node record may have been removed */
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT e.node_id, n.node_name, e.event, e.successful, "
|
" SELECT e.node_id, n.node_name, e.event, e.successful, "
|
||||||
" pg_catalog.to_char(e.event_timestamp, 'YYYY-MM-DD HH24:MI:SS') AS timestamp, "
|
" pg_catalog.to_char(e.event_timestamp, 'YYYY-MM-DD HH24:MI:SS') AS timestamp, "
|
||||||
" e.details "
|
" e.details "
|
||||||
" FROM repmgr.events e "
|
" FROM repmgr.events e "
|
||||||
"LEFT JOIN repmgr.nodes n ON e.node_id = n.node_id ");
|
"LEFT JOIN repmgr.nodes n ON e.node_id = n.node_id ");
|
||||||
|
|
||||||
if (node_id != UNKNOWN_NODE_ID)
|
if (node_id != UNKNOWN_NODE_ID)
|
||||||
{
|
{
|
||||||
@@ -3755,8 +3605,8 @@ get_event_records(PGconn *conn, int node_id, const char *node_name, const char *
|
|||||||
appendPQExpBuffer(&query, "\n%s\n",
|
appendPQExpBuffer(&query, "\n%s\n",
|
||||||
where_clause.data);
|
where_clause.data);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" ORDER BY e.event_timestamp DESC");
|
" ORDER BY e.event_timestamp DESC");
|
||||||
|
|
||||||
if (all == false && limit > 0)
|
if (all == false && limit > 0)
|
||||||
{
|
{
|
||||||
@@ -3958,10 +3808,10 @@ get_free_replication_slot_count(PGconn *conn)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT pg_catalog.current_setting('max_replication_slots')::INT - "
|
" SELECT pg_catalog.current_setting('max_replication_slots')::INT - "
|
||||||
" pg_catalog.count(*) AS free_slots"
|
" pg_catalog.count(*) AS free_slots"
|
||||||
" FROM pg_catalog.pg_replication_slots");
|
" FROM pg_catalog.pg_replication_slots");
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
|
|
||||||
@@ -3997,11 +3847,11 @@ get_inactive_replication_slots(PGconn *conn, KeyValueList *list)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT slot_name, slot_type "
|
" SELECT slot_name, slot_type "
|
||||||
" FROM pg_catalog.pg_replication_slots "
|
" FROM pg_catalog.pg_replication_slots "
|
||||||
" WHERE active IS FALSE "
|
" WHERE active IS FALSE "
|
||||||
" ORDER BY slot_name ");
|
" ORDER BY slot_name ");
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
|
|
||||||
@@ -4316,7 +4166,7 @@ add_monitoring_record(PGconn *primary_conn,
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
get_number_of_monitoring_records_to_delete(PGconn *primary_conn, int keep_history, int node_id)
|
get_number_of_monitoring_records_to_delete(PGconn *primary_conn, int keep_history)
|
||||||
{
|
{
|
||||||
PQExpBufferData query;
|
PQExpBufferData query;
|
||||||
int record_count = -1;
|
int record_count = -1;
|
||||||
@@ -4330,16 +4180,9 @@ get_number_of_monitoring_records_to_delete(PGconn *primary_conn, int keep_histor
|
|||||||
" WHERE pg_catalog.age(pg_catalog.now(), last_monitor_time) >= '%d days'::interval",
|
" WHERE pg_catalog.age(pg_catalog.now(), last_monitor_time) >= '%d days'::interval",
|
||||||
keep_history);
|
keep_history);
|
||||||
|
|
||||||
if (node_id != UNKNOWN_NODE_ID)
|
|
||||||
{
|
|
||||||
appendPQExpBuffer(&query,
|
|
||||||
" AND standby_node_id = %i", node_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_number_of_monitoring_records_to_delete():\n %s", query.data);
|
|
||||||
|
|
||||||
res = PQexec(primary_conn, query.data);
|
res = PQexec(primary_conn, query.data);
|
||||||
|
|
||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
log_db_error(primary_conn, query.data,
|
log_db_error(primary_conn, query.data,
|
||||||
@@ -4358,7 +4201,7 @@ get_number_of_monitoring_records_to_delete(PGconn *primary_conn, int keep_histor
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
delete_monitoring_records(PGconn *primary_conn, int keep_history, int node_id)
|
delete_monitoring_records(PGconn *primary_conn, int keep_history)
|
||||||
{
|
{
|
||||||
PQExpBufferData query;
|
PQExpBufferData query;
|
||||||
bool success = true;
|
bool success = true;
|
||||||
@@ -4366,23 +4209,17 @@ delete_monitoring_records(PGconn *primary_conn, int keep_history, int node_id)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
if (keep_history > 0 || node_id != UNKNOWN_NODE_ID)
|
if (keep_history > 0)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBuffer(&query,
|
||||||
"DELETE FROM repmgr.monitoring_history "
|
"DELETE FROM repmgr.monitoring_history "
|
||||||
" WHERE pg_catalog.age(pg_catalog.now(), last_monitor_time) >= '%d days'::INTERVAL ",
|
" WHERE pg_catalog.age(pg_catalog.now(), last_monitor_time) >= '%d days'::INTERVAL ",
|
||||||
keep_history);
|
keep_history);
|
||||||
|
|
||||||
if (node_id != UNKNOWN_NODE_ID)
|
|
||||||
{
|
|
||||||
appendPQExpBuffer(&query,
|
|
||||||
" AND standby_node_id = %i", node_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
"TRUNCATE TABLE repmgr.monitoring_history");
|
"TRUNCATE TABLE repmgr.monitoring_history");
|
||||||
}
|
}
|
||||||
|
|
||||||
res = PQexec(primary_conn, query.data);
|
res = PQexec(primary_conn, query.data);
|
||||||
@@ -4562,13 +4399,6 @@ get_new_primary(PGconn *conn, int *primary_node_id)
|
|||||||
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
/*
|
|
||||||
* repmgr.get_new_primary() will return UNKNOWN_NODE_ID if
|
|
||||||
* "follow_new_primary" is false
|
|
||||||
*/
|
|
||||||
if (new_primary_node_id == UNKNOWN_NODE_ID)
|
|
||||||
success = false;
|
|
||||||
|
|
||||||
*primary_node_id = new_primary_node_id;
|
*primary_node_id = new_primary_node_id;
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
@@ -4664,10 +4494,10 @@ _is_bdr_db(PGconn *conn, PQExpBufferData *output, bool quiet)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT (pg_catalog.regexp_matches(extversion, '^\\d+'))[1] AS major_version "
|
" SELECT (pg_catalog.regexp_matches(extversion, '^\\d+'))[1] AS major_version "
|
||||||
" FROM pg_catalog.pg_extension "
|
" FROM pg_catalog.pg_extension "
|
||||||
" WHERE extname = 'bdr' ");
|
" WHERE extname = 'bdr' ");
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
termPQExpBuffer(&query);
|
termPQExpBuffer(&query);
|
||||||
@@ -4692,7 +4522,7 @@ _is_bdr_db(PGconn *conn, PQExpBufferData *output, bool quiet)
|
|||||||
const char *warning = _("BDR extension is not available for this database");
|
const char *warning = _("BDR extension is not available for this database");
|
||||||
|
|
||||||
if (output != NULL)
|
if (output != NULL)
|
||||||
appendPQExpBufferStr(output, warning);
|
appendPQExpBuffer(output, "%s", warning);
|
||||||
else if (quiet == false)
|
else if (quiet == false)
|
||||||
log_warning("%s", warning);
|
log_warning("%s", warning);
|
||||||
|
|
||||||
@@ -4703,8 +4533,8 @@ _is_bdr_db(PGconn *conn, PQExpBufferData *output, bool quiet)
|
|||||||
{
|
{
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
"SELECT bdr.bdr_is_active_in_db()");
|
"SELECT bdr.bdr_is_active_in_db()");
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
termPQExpBuffer(&query);
|
termPQExpBuffer(&query);
|
||||||
|
|
||||||
@@ -4715,7 +4545,7 @@ _is_bdr_db(PGconn *conn, PQExpBufferData *output, bool quiet)
|
|||||||
const char *warning = _("BDR extension available for this database, but the database is not configured for BDR");
|
const char *warning = _("BDR extension available for this database, but the database is not configured for BDR");
|
||||||
|
|
||||||
if (output != NULL)
|
if (output != NULL)
|
||||||
appendPQExpBufferStr(output, warning);
|
appendPQExpBuffer(output, "%s", warning);
|
||||||
else if (quiet == false)
|
else if (quiet == false)
|
||||||
log_warning("%s", warning);
|
log_warning("%s", warning);
|
||||||
}
|
}
|
||||||
@@ -4810,10 +4640,10 @@ is_bdr_repmgr(PGconn *conn)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
"SELECT pg_catalog.count(*)"
|
"SELECT pg_catalog.count(*)"
|
||||||
" FROM repmgr.nodes n"
|
" FROM repmgr.nodes n"
|
||||||
" WHERE n.type != 'bdr' ");
|
" WHERE n.type != 'bdr' ");
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
termPQExpBuffer(&query);
|
termPQExpBuffer(&query);
|
||||||
@@ -4858,11 +4688,11 @@ get_default_bdr_replication_set(PGconn *conn)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT rs.set_name "
|
" SELECT rs.set_name "
|
||||||
" FROM pglogical.replication_set rs "
|
" FROM pglogical.replication_set rs "
|
||||||
" INNER JOIN bdr.node_group ng "
|
" INNER JOIN bdr.node_group ng "
|
||||||
" ON ng.node_group_default_repset = rs.set_id ");
|
" ON ng.node_group_default_repset = rs.set_id ");
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
termPQExpBuffer(&query);
|
termPQExpBuffer(&query);
|
||||||
@@ -4997,13 +4827,13 @@ bdr_node_name_matches(PGconn *conn, const char *node_name, PQExpBufferData *bdr_
|
|||||||
|
|
||||||
if (bdr_version_num < 3)
|
if (bdr_version_num < 3)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
"SELECT bdr.bdr_get_local_node_name() AS node_name");
|
"SELECT bdr.bdr_get_local_node_name() AS node_name");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
"SELECT node_name FROM bdr.local_node_info()");
|
"SELECT node_name FROM bdr.local_node_info()");
|
||||||
}
|
}
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
@@ -5126,13 +4956,13 @@ add_extension_tables_to_bdr_replication_set(PGconn *conn)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT c.relname "
|
" SELECT c.relname "
|
||||||
" FROM pg_class c "
|
" FROM pg_class c "
|
||||||
"INNER JOIN pg_namespace n "
|
"INNER JOIN pg_namespace n "
|
||||||
" ON c.relnamespace = n.oid "
|
" ON c.relnamespace = n.oid "
|
||||||
" WHERE n.nspname = 'repmgr' "
|
" WHERE n.nspname = 'repmgr' "
|
||||||
" AND c.relkind = 'r' ");
|
" AND c.relkind = 'r' ");
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
termPQExpBuffer(&query);
|
termPQExpBuffer(&query);
|
||||||
@@ -5168,17 +4998,17 @@ get_all_bdr_node_records(PGconn *conn, BdrNodeInfoList *node_list)
|
|||||||
|
|
||||||
if (bdr_version_num < 3)
|
if (bdr_version_num < 3)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT " BDR2_NODES_COLUMNS
|
" SELECT " BDR2_NODES_COLUMNS
|
||||||
" FROM bdr.bdr_nodes "
|
" FROM bdr.bdr_nodes "
|
||||||
"ORDER BY node_seq_id ");
|
"ORDER BY node_seq_id ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT " BDR3_NODES_COLUMNS
|
" SELECT " BDR3_NODES_COLUMNS
|
||||||
" FROM bdr.node_summary ns "
|
" FROM bdr.node_summary ns "
|
||||||
" ORDER BY node_name");
|
" ORDER BY node_name");
|
||||||
}
|
}
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_all_bdr_node_records():\n%s", query.data);
|
log_verbose(LOG_DEBUG, "get_all_bdr_node_records():\n%s", query.data);
|
||||||
|
|||||||
52
dbutils.h
52
dbutils.h
@@ -47,7 +47,6 @@ typedef enum
|
|||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
REPMGR_INSTALLED = 0,
|
REPMGR_INSTALLED = 0,
|
||||||
REPMGR_OLD_VERSION_INSTALLED,
|
|
||||||
REPMGR_AVAILABLE,
|
REPMGR_AVAILABLE,
|
||||||
REPMGR_UNAVAILABLE,
|
REPMGR_UNAVAILABLE,
|
||||||
REPMGR_UNKNOWN
|
REPMGR_UNKNOWN
|
||||||
@@ -105,20 +104,6 @@ typedef enum
|
|||||||
} BackupState;
|
} BackupState;
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Struct to store extension version information
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct s_extension_versions {
|
|
||||||
char default_version[8];
|
|
||||||
char installed_version[8];
|
|
||||||
} t_extension_versions;
|
|
||||||
|
|
||||||
#define T_EXTENSION_VERSIONS_INITIALIZER { \
|
|
||||||
"", \
|
|
||||||
"", \
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Struct to store node information
|
* Struct to store node information
|
||||||
*/
|
*/
|
||||||
@@ -342,21 +327,6 @@ typedef struct
|
|||||||
UNKNOWN_TIMELINE_ID, \
|
UNKNOWN_TIMELINE_ID, \
|
||||||
InvalidXLogRecPtr \
|
InvalidXLogRecPtr \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef struct RepmgrdInfo {
|
|
||||||
int node_id;
|
|
||||||
int pid;
|
|
||||||
char pid_text[MAXLEN];
|
|
||||||
char pid_file[MAXLEN];
|
|
||||||
bool pg_running;
|
|
||||||
char pg_running_text[MAXLEN];
|
|
||||||
bool running;
|
|
||||||
char repmgrd_running[MAXLEN];
|
|
||||||
bool paused;
|
|
||||||
} RepmgrdInfo;
|
|
||||||
|
|
||||||
|
|
||||||
/* global variables */
|
/* global variables */
|
||||||
|
|
||||||
extern int server_version_num;
|
extern int server_version_num;
|
||||||
@@ -376,13 +346,15 @@ __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
|
|||||||
bool atobool(const char *value);
|
bool atobool(const char *value);
|
||||||
|
|
||||||
/* connection functions */
|
/* connection functions */
|
||||||
PGconn *establish_db_connection(const char *conninfo,
|
PGconn *establish_db_connection(const char *conninfo,
|
||||||
const bool exit_on_error);
|
const bool exit_on_error);
|
||||||
PGconn *establish_db_connection_quiet(const char *conninfo);
|
PGconn *establish_db_connection_quiet(const char *conninfo);
|
||||||
PGconn *establish_db_connection_by_params(t_conninfo_param_list *param_list,
|
|
||||||
|
PGconn *establish_db_connection_by_params(t_conninfo_param_list *param_list,
|
||||||
const bool exit_on_error);
|
const bool exit_on_error);
|
||||||
PGconn *establish_primary_db_connection(PGconn *conn,
|
PGconn *establish_primary_db_connection(PGconn *conn,
|
||||||
const bool exit_on_error);
|
const bool exit_on_error);
|
||||||
|
|
||||||
PGconn *get_primary_connection(PGconn *standby_conn, int *primary_id, char *primary_conninfo_out);
|
PGconn *get_primary_connection(PGconn *standby_conn, int *primary_id, char *primary_conninfo_out);
|
||||||
PGconn *get_primary_connection_quiet(PGconn *standby_conn, int *primary_id, char *primary_conninfo_out);
|
PGconn *get_primary_connection_quiet(PGconn *standby_conn, int *primary_id, char *primary_conninfo_out);
|
||||||
|
|
||||||
@@ -408,6 +380,7 @@ bool has_passfile(void);
|
|||||||
bool begin_transaction(PGconn *conn);
|
bool begin_transaction(PGconn *conn);
|
||||||
bool commit_transaction(PGconn *conn);
|
bool commit_transaction(PGconn *conn);
|
||||||
bool rollback_transaction(PGconn *conn);
|
bool rollback_transaction(PGconn *conn);
|
||||||
|
bool check_cluster_schema(PGconn *conn);
|
||||||
|
|
||||||
/* GUC manipulation functions */
|
/* GUC manipulation functions */
|
||||||
bool set_config(PGconn *conn, const char *config_param, const char *config_value);
|
bool set_config(PGconn *conn, const char *config_param, const char *config_value);
|
||||||
@@ -426,14 +399,9 @@ bool identify_system(PGconn *repl_conn, t_system_identification *identification
|
|||||||
bool repmgrd_set_local_node_id(PGconn *conn, int local_node_id);
|
bool repmgrd_set_local_node_id(PGconn *conn, int local_node_id);
|
||||||
int repmgrd_get_local_node_id(PGconn *conn);
|
int repmgrd_get_local_node_id(PGconn *conn);
|
||||||
BackupState server_in_exclusive_backup_mode(PGconn *conn);
|
BackupState server_in_exclusive_backup_mode(PGconn *conn);
|
||||||
void repmgrd_set_pid(PGconn *conn, pid_t repmgrd_pid, const char *pidfile);
|
|
||||||
pid_t repmgrd_get_pid(PGconn *conn);
|
|
||||||
bool repmgrd_is_running(PGconn *conn);
|
|
||||||
bool repmgrd_is_paused(PGconn *conn);
|
|
||||||
bool repmgrd_pause(PGconn *conn, bool pause);
|
|
||||||
|
|
||||||
/* extension functions */
|
/* extension functions */
|
||||||
ExtensionStatus get_repmgr_extension_status(PGconn *conn, t_extension_versions *extversions);
|
ExtensionStatus get_repmgr_extension_status(PGconn *conn);
|
||||||
|
|
||||||
/* node management functions */
|
/* node management functions */
|
||||||
void checkpoint(PGconn *conn);
|
void checkpoint(PGconn *conn);
|
||||||
@@ -453,7 +421,7 @@ t_node_info *get_node_record_pointer(PGconn *conn, int node_id);
|
|||||||
bool get_local_node_record(PGconn *conn, int node_id, t_node_info *node_info);
|
bool get_local_node_record(PGconn *conn, int node_id, t_node_info *node_info);
|
||||||
bool get_primary_node_record(PGconn *conn, t_node_info *node_info);
|
bool get_primary_node_record(PGconn *conn, t_node_info *node_info);
|
||||||
|
|
||||||
bool get_all_node_records(PGconn *conn, NodeInfoList *node_list);
|
void get_all_node_records(PGconn *conn, NodeInfoList *node_list);
|
||||||
void get_downstream_node_records(PGconn *conn, int node_id, NodeInfoList *nodes);
|
void get_downstream_node_records(PGconn *conn, int node_id, NodeInfoList *nodes);
|
||||||
void get_active_sibling_node_records(PGconn *conn, int node_id, int upstream_node_id, NodeInfoList *node_list);
|
void get_active_sibling_node_records(PGconn *conn, int node_id, int upstream_node_id, NodeInfoList *node_list);
|
||||||
void get_node_records_by_priority(PGconn *conn, NodeInfoList *node_list);
|
void get_node_records_by_priority(PGconn *conn, NodeInfoList *node_list);
|
||||||
@@ -523,8 +491,8 @@ add_monitoring_record(PGconn *primary_conn,
|
|||||||
long long unsigned int apply_lag_bytes
|
long long unsigned int apply_lag_bytes
|
||||||
);
|
);
|
||||||
|
|
||||||
int get_number_of_monitoring_records_to_delete(PGconn *primary_conn, int keep_history, int node_id);
|
int get_number_of_monitoring_records_to_delete(PGconn *primary_conn, int keep_history);
|
||||||
bool delete_monitoring_records(PGconn *primary_conn, int keep_history, int node_id);
|
bool delete_monitoring_records(PGconn *primary_conn, int keep_history);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,17 +21,13 @@
|
|||||||
in PostgreSQL 9.3, as well as improved automated failover support
|
in PostgreSQL 9.3, as well as improved automated failover support
|
||||||
via <application>repmgrd</application>, and is not compatible with PostgreSQL 9.2
|
via <application>repmgrd</application>, and is not compatible with PostgreSQL 9.2
|
||||||
and earlier. We recommend upgrading to &repmgr; 4, as the &repmgr; 3.x
|
and earlier. We recommend upgrading to &repmgr; 4, as the &repmgr; 3.x
|
||||||
series is no longer maintained.
|
series will no longer be actively maintained.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
&repmgr; 2.x supports PostgreSQL 9.0 ~ 9.3. While it is compatible
|
&repmgr; 2.x supports PostgreSQL 9.0 ~ 9.3. While it is compatible
|
||||||
with PostgreSQL 9.3, we recommend using repmgr 4.x. &repmgr; 2.x is
|
with PostgreSQL 9.3, we recommend using repmgr 4.x. &repmgr; 2.x is
|
||||||
no longer maintained.
|
no longer maintained.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
|
||||||
See also <link linkend="install-compatibility-matrix">&repmgr; compatibility matrix</link>
|
|
||||||
and <link linkend="faq-upgrade-repmgr">Should I upgrade &repmgr;?</link>.
|
|
||||||
</para>
|
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
<sect2 id="faq-replication-slots-advantage" xreflabel="Advantages of replication slots">
|
<sect2 id="faq-replication-slots-advantage" xreflabel="Advantages of replication slots">
|
||||||
@@ -39,25 +35,15 @@
|
|||||||
<para>
|
<para>
|
||||||
Replication slots, introduced in PostgreSQL 9.4, ensure that the
|
Replication slots, introduced in PostgreSQL 9.4, ensure that the
|
||||||
primary server will retain WAL files until they have been consumed
|
primary server will retain WAL files until they have been consumed
|
||||||
by all standby servers. This means standby servers should never
|
by all standby servers. This makes WAL file management much easier,
|
||||||
fail due to not being able to retrieve required WAL files from the
|
and if used &repmgr; will no longer insist on a fixed minimum number
|
||||||
primary.
|
(default: 5000) of WAL files being retained.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
However this does mean that if a standby is no longer connected to the
|
However this does mean that if a standby is no longer connected to the
|
||||||
primary, the presence of the replication slot will cause WAL files
|
primary, the presence of the replication slot will cause WAL files
|
||||||
to be retained indefinitely, and eventually lead to disk space
|
to be retained indefinitely.
|
||||||
exhaustion.
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<tip>
|
|
||||||
<para>
|
|
||||||
2ndQuadrant's recommended configuration is to configure
|
|
||||||
<ulink url="https://www.pgbarman.org/">Barman</ulink> as a fallback
|
|
||||||
source of WAL files, rather than maintain replication slots for
|
|
||||||
each standby. See also: <link linkend="cloning-from-barman-restore-command">Using Barman as a WAL file source</link>.
|
|
||||||
</para>
|
|
||||||
</tip>
|
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
<sect2 id="faq-replication-slots-number" xreflabel="Number of replication slots">
|
<sect2 id="faq-replication-slots-number" xreflabel="Number of replication slots">
|
||||||
@@ -130,74 +116,6 @@
|
|||||||
</para>
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
<sect2 id="faq-repmgr-required-for-replication">
|
|
||||||
<title>Is &repmgr; required for streaming replication?</title>
|
|
||||||
<para>
|
|
||||||
No.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
&repmgr; (together with <application>repmgrd</application>) assists with
|
|
||||||
<emphasis>managing</emphasis> replication. It does not actually perform replication, which
|
|
||||||
is part of the core PostgreSQL functionality.
|
|
||||||
</para>
|
|
||||||
</sect2>
|
|
||||||
|
|
||||||
<sect2 id="faq-what-if-repmgr-uninstalled">
|
|
||||||
<title>Will replication stop working if &repmgr; is uninstalled?</title>
|
|
||||||
<para>
|
|
||||||
No. See preceding question.
|
|
||||||
</para>
|
|
||||||
</sect2>
|
|
||||||
|
|
||||||
<sect2 id="faq-version-mix">
|
|
||||||
<title>Does it matter if different &repmgr; versions are present in the replication cluster?</title>
|
|
||||||
<para>
|
|
||||||
Yes. If different "major" &repmgr; versions (e.g. 3.3.x and 4.1.x) are present,
|
|
||||||
&repmgr; (in particular <application>repmgrd</application>)
|
|
||||||
may not run, or run properly, or in the worst case (if different <application>repmgrd</application>
|
|
||||||
versions are running and there are differences in the failover implementation) break
|
|
||||||
your replication cluster.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
If different "minor" &repmgr; versions (e.g. 4.1.1 and 4.1.6) are installed,
|
|
||||||
&repmgr; will function, but we strongly recommend always running the same version
|
|
||||||
to ensure there are no unexpected suprises, e.g. a newer version behaving slightly
|
|
||||||
differently to the older version.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
See also <link linkend="faq-upgrade-repmgr">Should I upgrade &repmgr;?</link>.
|
|
||||||
</para>
|
|
||||||
</sect2>
|
|
||||||
|
|
||||||
<sect2 id="faq-upgrade-repmgr">
|
|
||||||
<title>Should I upgrade &repmgr;?</title>
|
|
||||||
<para>
|
|
||||||
Yes.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
We don't release new versions for fun, you know. Upgrading may require a little effort,
|
|
||||||
but running an older &repmgr; version with bugs which have since been fixed may end up
|
|
||||||
costing you more effort. The same applies to PostgreSQL itself.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
</sect2>
|
|
||||||
|
|
||||||
<sect2 id="faq-repmgr-conf-data-directory">
|
|
||||||
<title>Why do I need to specify the data directory location in repmgr.conf?</title>
|
|
||||||
<para>
|
|
||||||
In some circumstances &repmgr; may need to access a PostgreSQL data
|
|
||||||
directory while the PostgreSQL server is not running, e.g. to confirm
|
|
||||||
it shut down cleanly during a <link linkend="performing-switchover">switchover</link>.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
Additionally, this provides support when using &repmgr; on PostgreSQL 9.6 and
|
|
||||||
earlier, where the <literal>repmgr</literal> user is not a superuser; in that
|
|
||||||
case the <literal>repmgr</literal> user will not be able to access the
|
|
||||||
<literal>data_directory</literal> configuration setting, access to which is restricted
|
|
||||||
to superusers. (In PostgreSQL 10 and later, non-superusers can be added to the
|
|
||||||
group <option>pg_read_all_settings</option> which will enable them to read this setting).
|
|
||||||
</para>
|
|
||||||
</sect2>
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
<sect1 id="faq-repmgr" xreflabel="repmgr">
|
<sect1 id="faq-repmgr" xreflabel="repmgr">
|
||||||
|
|||||||
@@ -12,17 +12,10 @@
|
|||||||
|
|
||||||
<sect1 id="packages-centos" xreflabel="CentOS packages">
|
<sect1 id="packages-centos" xreflabel="CentOS packages">
|
||||||
<title>CentOS Packages</title>
|
<title>CentOS Packages</title>
|
||||||
|
|
||||||
<indexterm>
|
<indexterm>
|
||||||
<primary>packages</primary>
|
<primary>packages</primary>
|
||||||
<secondary>CentOS packages</secondary>
|
<secondary>CentOS packages</secondary>
|
||||||
</indexterm>
|
</indexterm>
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>CentOS</primary>
|
|
||||||
<secondary>package information</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Currently, &repmgr; RPM packages are provided for versions 6.x and 7.x of CentOS. These should also
|
Currently, &repmgr; RPM packages are provided for versions 6.x and 7.x of CentOS. These should also
|
||||||
work on matching versions of Red Hat Enterprise Linux, Scientific Linux and Oracle Enterprise Linux;
|
work on matching versions of Red Hat Enterprise Linux, Scientific Linux and Oracle Enterprise Linux;
|
||||||
@@ -64,7 +57,7 @@
|
|||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry>Repository documentation:</entry>
|
<entry>Repository documentation:</entry>
|
||||||
<entry><ulink url="https://repmgr.org/docs/current/installation-packages.html#INSTALLATION-PACKAGES-REDHAT-2NDQ">https://repmgr.org/docs/current/installation-packages.html#INSTALLATION-PACKAGES-REDHAT-2NDQ</ulink></entry>
|
<entry><ulink url="https://repmgr.org/docs/4.1/installation-packages.html#INSTALLATION-PACKAGES-REDHAT-2NDQ">https://repmgr.org/docs/4.1/installation-packages.html#INSTALLATION-PACKAGES-REDHAT-2NDQ</ulink></entry>
|
||||||
</row>
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
@@ -244,12 +237,6 @@
|
|||||||
<primary>packages</primary>
|
<primary>packages</primary>
|
||||||
<secondary>Debian/Ubuntu packages</secondary>
|
<secondary>Debian/Ubuntu packages</secondary>
|
||||||
</indexterm>
|
</indexterm>
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>Debian/Ubuntu</primary>
|
|
||||||
<secondary>package information</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
&repmgr; <literal>.deb</literal> packages are provided via the
|
&repmgr; <literal>.deb</literal> packages are provided via the
|
||||||
PostgreSQL Community APT repository, and are available for each community-supported
|
PostgreSQL Community APT repository, and are available for each community-supported
|
||||||
@@ -276,7 +263,7 @@
|
|||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry>Repository documentation:</entry>
|
<entry>Repository documentation:</entry>
|
||||||
<entry><ulink url="https://repmgr.org/docs/current/installation-packages.html#INSTALLATION-PACKAGES-DEBIAN">https://repmgr.org/docs/current/installation-packages.html#INSTALLATION-PACKAGES-DEBIAN</ulink></entry>
|
<entry><ulink url="https://repmgr.org/docs/4.1/installation-packages.html#INSTALLATION-PACKAGES-DEBIAN">https://repmgr.org/docs/4.1/installation-packages.html#INSTALLATION-PACKAGES-DEBIAN</ulink></entry>
|
||||||
</row>
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
|
|||||||
@@ -15,146 +15,6 @@
|
|||||||
See also: <xref linkend="upgrading-repmgr">
|
See also: <xref linkend="upgrading-repmgr">
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<sect1 id="release-4.2">
|
|
||||||
<title>Release 4.2</title>
|
|
||||||
<para><emphasis>Wed October 24, 2018</emphasis></para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
&repmgr; 4.2 is a major release, with the main new feature being the
|
|
||||||
ability to <link linkend="repmgrd-pausing">pause repmgrd</link>, e.g. during planned maintenance
|
|
||||||
operations. Various other usability enhancements and a couple of bug fixes are also included;
|
|
||||||
see notes below for details.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
A restart of the PostgreSQL server <emphasis>is</emphasis> required
|
|
||||||
for this release. For detailed upgrade instructions, see
|
|
||||||
<link linkend="upgrading-major-version">Upgrading a major version release</link>.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<sect2>
|
|
||||||
<title>Configuration file changes</title>
|
|
||||||
<para>
|
|
||||||
<itemizedlist>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
New parameter <varname>shutdown_check_timeout</varname> (default: 60 seconds) added;
|
|
||||||
this provides an explicit timeout for
|
|
||||||
<command><link linkend="repmgr-standby-switchover">repmgr standby switchover</link></command>
|
|
||||||
to check that the demotion candidate (current primary) has shut down. Previously, the parameters
|
|
||||||
<literal>reconnect_attempts</literal> and <literal>reconnect_interval</literal>
|
|
||||||
were used to calculate a timeout, but these are actually
|
|
||||||
intended for primary failure detection. (GitHub #504).
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
|
|
||||||
<itemizedlist>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
New parameter <varname>repmgr_bindir</varname> added, to facilitate remote invocation of repmgr
|
|
||||||
when the repmgr binary is located somewhere other than the PostgreSQL binary directory, as it
|
|
||||||
cannot be assumed all package maintainers will install &repmgr; there.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
This parameter is optional; if not set (the default), &repmgr; will fall back
|
|
||||||
to <option>pg_bindir</option> (if set).
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
(GitHub #246).
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
</sect2>
|
|
||||||
|
|
||||||
<sect2>
|
|
||||||
<title>repmgr enhancements</title>
|
|
||||||
<para>
|
|
||||||
<itemizedlist>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
<command><link linkend="repmgr-cluster-cleanup">repmgr cluster cleanup</link></command>
|
|
||||||
now accepts the <option>--node-id</option> option to delete records for only one
|
|
||||||
node. (GitHub #493).
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
When running
|
|
||||||
<command><link linkend="repmgr-cluster-matrix">repmgr cluster matrix</link></command> and
|
|
||||||
<command><link linkend="repmgr-cluster-crosscheck">repmgr cluster crosscheck</link></command>,
|
|
||||||
&repmgr; will report nodes unreachable via SSH, and emit return code <literal>ERR_BAD_SSH</literal>.
|
|
||||||
(GitHub #246).
|
|
||||||
</para>
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
Users relying on
|
|
||||||
<command><link linkend="repmgr-cluster-crosscheck">repmgr cluster crosscheck</link></command>
|
|
||||||
to return a non-zero return code as a way of detecting connectivity errors should be aware
|
|
||||||
that <literal>ERR_BAD_SSH</literal> will be returned if there is an SSH connection error
|
|
||||||
from the node where the command is executed, even if the command is able to establish
|
|
||||||
that PostgreSQL connectivity is fine. Therefore the exact return code should be checked
|
|
||||||
to determine what kind of connectivity error has been detected.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
</sect2>
|
|
||||||
|
|
||||||
|
|
||||||
<sect2>
|
|
||||||
<title>repmgrd enhancements</title>
|
|
||||||
<para>
|
|
||||||
<itemizedlist>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
<application>repmgrd</application> can now be "paused", i.e. instructed
|
|
||||||
not to take any action such as a failover, even if the prerequisites for such an
|
|
||||||
action are detected.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
This removes the need to stop <application>repmgrd</application> on all nodes when
|
|
||||||
performing a planned operation such as a switchover.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
For further details, see <link linkend="repmgrd-pausing">Pausing repmgrd</link>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
</sect2>
|
|
||||||
|
|
||||||
<sect2>
|
|
||||||
<title>Bug fixes</title>
|
|
||||||
<para>
|
|
||||||
<itemizedlist>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
&repmgr;: fix "Missing replication slots" label in
|
|
||||||
<command><link linkend="repmgr-node-check">repmgr node check</link></command>. (GitHub #507)
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
<application>repmgrd</application>: fix parsing of <option>-d/--daemonize</option> option.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
</sect2>
|
|
||||||
</sect1>
|
|
||||||
|
|
||||||
<sect1 id="release-4.1.1">
|
<sect1 id="release-4.1.1">
|
||||||
<title>Release 4.1.1</title>
|
<title>Release 4.1.1</title>
|
||||||
<para><emphasis>Wed September 5, 2018</emphasis></para>
|
<para><emphasis>Wed September 5, 2018</emphasis></para>
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ BDR failover with repmgrd
|
|||||||
This document has been integrated into the main `repmgr` documentation
|
This document has been integrated into the main `repmgr` documentation
|
||||||
and is now located here:
|
and is now located here:
|
||||||
|
|
||||||
> [BDR failover with repmgrd](https://repmgr.org/docs/current/repmgrd-bdr.html)
|
> [BDR failover with repmgrd](https://repmgr.org/docs/4.0/repmgrd-bdr.html)
|
||||||
|
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ Changes in repmgr 4
|
|||||||
This document has been integrated into the main `repmgr` documentation
|
This document has been integrated into the main `repmgr` documentation
|
||||||
and is now located here:
|
and is now located here:
|
||||||
|
|
||||||
> [Release notes](https://repmgr.org/docs/current/release-4.0.html)
|
> [Release notes](https://repmgr.org/docs/4.0/release-4.0.html)
|
||||||
|
|||||||
@@ -243,8 +243,8 @@
|
|||||||
</simpara>
|
</simpara>
|
||||||
<simpara>
|
<simpara>
|
||||||
As an alternative we recommend using 2ndQuadrant's <ulink url="https://www.pgbarman.org/">Barman</ulink>,
|
As an alternative we recommend using 2ndQuadrant's <ulink url="https://www.pgbarman.org/">Barman</ulink>,
|
||||||
which offloads WAL management to a separate server, removing the requirement to use a replication
|
which offloads WAL management to a separate server, negating the need to use replication
|
||||||
slot for each individual standby to reserve WAL. See section <xref linkend="cloning-from-barman">
|
slots to reserve WAL. See section <xref linkend="cloning-from-barman">
|
||||||
for more details on using &repmgr; together with Barman.
|
for more details on using &repmgr; together with Barman.
|
||||||
</simpara>
|
</simpara>
|
||||||
</tip>
|
</tip>
|
||||||
@@ -352,12 +352,10 @@
|
|||||||
provide additional parameters for <command>pg_basebackup</command> to customise the
|
provide additional parameters for <command>pg_basebackup</command> to customise the
|
||||||
cloning process.
|
cloning process.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
By default, <command>pg_basebackup</command> performs a checkpoint before beginning the backup
|
By default, <command>pg_basebackup</command> performs a checkpoint before beginning the backup
|
||||||
process. However, a normal checkpoint may take some time to complete;
|
process. However, a normal checkpoint may take some time to complete;
|
||||||
a fast checkpoint can be forced with <command><link linkend="repmgr-standby-clone">repmgr standby clone</link></command>'s
|
a fast checkpoint can be forced with the <literal>-c/--fast-checkpoint</literal> option.
|
||||||
<literal>-c/--fast-checkpoint</literal> option.
|
|
||||||
Note that this may impact performance of the server being cloned from (typically the primary)
|
Note that this may impact performance of the server being cloned from (typically the primary)
|
||||||
so should be used with care.
|
so should be used with care.
|
||||||
</para>
|
</para>
|
||||||
@@ -372,18 +370,6 @@
|
|||||||
Other options can be passed to <command>pg_basebackup</command> by including them
|
Other options can be passed to <command>pg_basebackup</command> by including them
|
||||||
in the <filename>repmgr.conf</filename> setting <varname>pg_basebackup_options</varname>.
|
in the <filename>repmgr.conf</filename> setting <varname>pg_basebackup_options</varname>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
|
||||||
Not that by default, &repmgr; executes <command>pg_basebackup</command> with <option>-X/--wal-method</option>
|
|
||||||
(PostgreSQL 9.6 and earlier: <option>-X/--xlog-method</option>) set to <literal>stream</literal>.
|
|
||||||
From PostgreSQL 9.6, if replication slots are in use, it will also create a replication slot before
|
|
||||||
running the base backup, and execute <command>pg_basebackup</command> with the
|
|
||||||
<option>-S/--slot</option> option set to the name of the previously created replication slot.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
These parameters can set by the user in <varname>pg_basebackup_options</varname>, in which case they
|
|
||||||
will override the &repmgr; default values. However normally there's no reason to do this.
|
|
||||||
</para>
|
|
||||||
<para>
|
<para>
|
||||||
If using a separate directory to store WAL files, provide the option <literal>--waldir</literal>
|
If using a separate directory to store WAL files, provide the option <literal>--waldir</literal>
|
||||||
(<literal>--xlogdir</literal> in PostgreSQL 9.6 and earlier) with the absolute path to the
|
(<literal>--xlogdir</literal> in PostgreSQL 9.6 and earlier) with the absolute path to the
|
||||||
|
|||||||
@@ -74,12 +74,12 @@
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
To confirm which command &repmgr; will execute for each action, use
|
To confirm which command &repmgr; will execute for each action, use
|
||||||
<command><link linkend="repmgr-node-service">repmgr node service --list-actions --action=...</link></command>, e.g.:
|
<command>repmgr node service --list --action=...</command>, e.g.:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
repmgr -f /etc/repmgr.conf node service --list-actions --action=stop
|
repmgr -f /etc/repmgr.conf node service --list --action=stop
|
||||||
repmgr -f /etc/repmgr.conf node service --list-actions --action=start
|
repmgr -f /etc/repmgr.conf node service --list --action=start
|
||||||
repmgr -f /etc/repmgr.conf node service --list-actions --action=restart
|
repmgr -f /etc/repmgr.conf node service --list --action=restart
|
||||||
repmgr -f /etc/repmgr.conf node service --list-actions --action=reload</programlisting>
|
repmgr -f /etc/repmgr.conf node service --list --action=reload</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<sect1 id="configuration-file" xreflabel="configuration file">
|
<sect1 id="configuration-file" xreflabel="configuration file location">
|
||||||
<indexterm>
|
<indexterm>
|
||||||
<primary>repmgr.conf</primary>
|
<primary>repmgr.conf</primary>
|
||||||
|
<secondary>location</secondary>
|
||||||
</indexterm>
|
</indexterm>
|
||||||
|
|
||||||
<indexterm>
|
<indexterm>
|
||||||
<primary>configuration</primary>
|
<primary>configuration</primary>
|
||||||
<secondary>repmgr.conf</secondary>
|
<secondary>repmgr.conf location</secondary>
|
||||||
</indexterm>
|
</indexterm>
|
||||||
|
|
||||||
<title>Configuration file</title>
|
<title>Configuration file location</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
<application>repmgr</application> and <application>repmgrd</application>
|
<application>repmgr</application> and <application>repmgrd</application>
|
||||||
use a common configuration file, by default called
|
use a common configuration file, by default called
|
||||||
@@ -21,55 +21,6 @@
|
|||||||
for more details.
|
for more details.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<sect2 id="configuration-file-format" xreflabel="configuration file format">
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>repmgr.conf</primary>
|
|
||||||
<secondary>format</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<title>Configuration file format</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
<filename>repmgr.conf</filename> is a plain text file with one parameter/value
|
|
||||||
combination per line.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
Whitespace is insignificant (except within a quoted parameter value) and blank lines are ignored.
|
|
||||||
Hash marks (#) designate the remainder of the line as a comment. Parameter values that are not simple
|
|
||||||
identifiers or numbers should be single-quoted. Note that single quote can not be embedded
|
|
||||||
in a parameter value.
|
|
||||||
</para>
|
|
||||||
<important>
|
|
||||||
<para>
|
|
||||||
&repmgr; will interpret double-quotes as being part of a string value; only use single quotes
|
|
||||||
to quote parameter values.
|
|
||||||
</para>
|
|
||||||
</important>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Example of a valid <filename>repmgr.conf</filename> file:
|
|
||||||
<programlisting>
|
|
||||||
# repmgr.conf
|
|
||||||
|
|
||||||
node_id=1
|
|
||||||
node_name= node1
|
|
||||||
conninfo ='host=node1 dbname=repmgr user=repmgr connect_timeout=2'
|
|
||||||
data_directory = /var/lib/pgsql/11/data</programlisting>
|
|
||||||
|
|
||||||
</para>
|
|
||||||
</sect2>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sect2 id="configuration-file-location" xreflabel="configuration file location">
|
|
||||||
<indexterm>
|
|
||||||
<primary>repmgr.conf</primary>
|
|
||||||
<secondary>location</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<title>Configuration file location</title>
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The configuration file will be searched for in the following locations:
|
The configuration file will be searched for in the following locations:
|
||||||
<itemizedlist spacing="compact" mark="bullet">
|
<itemizedlist spacing="compact" mark="bullet">
|
||||||
@@ -99,7 +50,7 @@ data_directory = /var/lib/pgsql/11/data</programlisting>
|
|||||||
Note that if a file is explicitly specified with <literal>-f/--config-file</literal>,
|
Note that if a file is explicitly specified with <literal>-f/--config-file</literal>,
|
||||||
an error will be raised if it is not found or not readable, and no attempt will be made to
|
an error will be raised if it is not found or not readable, and no attempt will be made to
|
||||||
check default locations; this is to prevent <application>repmgr</application> unexpectedly
|
check default locations; this is to prevent <application>repmgr</application> unexpectedly
|
||||||
reading the wrong configuration file.
|
reading the wrong configuraton file.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
@@ -114,7 +65,5 @@ data_directory = /var/lib/pgsql/11/data</programlisting>
|
|||||||
to <filename>/path/to/./repmgr.conf</filename>, whereas you'd normally write
|
to <filename>/path/to/./repmgr.conf</filename>, whereas you'd normally write
|
||||||
<filename>/path/to/repmgr.conf</filename>).
|
<filename>/path/to/repmgr.conf</filename>).
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
|
</sect1>
|
||||||
</sect2>
|
|
||||||
</sect1>
|
|
||||||
|
|||||||
@@ -1,292 +1,6 @@
|
|||||||
<chapter id="configuration" xreflabel="Configuration">
|
<chapter id="configuration" xreflabel="Configuration">
|
||||||
<title>repmgr configuration</title>
|
<title>repmgr configuration</title>
|
||||||
|
|
||||||
<sect1 id="configuration-prerequisites" xreflabel="Prerequisites for configuration">
|
|
||||||
<indexterm>
|
|
||||||
<primary>configuration</primary>
|
|
||||||
<secondary>prerequisites</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>configuration</primary>
|
|
||||||
<secondary>ssh</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<title>Prerequisites for configuration</title>
|
|
||||||
<para>
|
|
||||||
Following software must be installed on both servers:
|
|
||||||
<itemizedlist spacing="compact" mark="bullet">
|
|
||||||
<listitem>
|
|
||||||
<simpara><application>PostgreSQL</application></simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
<application>repmgr</application>
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
At network level, connections between the PostgreSQL port (default: <literal>5432</literal>)
|
|
||||||
must be possible between all nodes.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Passwordless <command>SSH</command> connectivity between all servers in the replication cluster
|
|
||||||
is not required, but is necessary in the following cases:
|
|
||||||
<itemizedlist>
|
|
||||||
<listitem>
|
|
||||||
<simpara>if you need &repmgr; to copy configuration files from outside the PostgreSQL
|
|
||||||
data directory (as is the case with e.g. <link linkend="packages-debian-ubuntu">Debian packages</link>);
|
|
||||||
in this case <command>rsync</command> must also be installed on all servers.
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara>to perform <link linkend="performing-switchover">switchover operations</link></simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
when executing <command><link linkend="repmgr-cluster-matrix">repmgr cluster matrix</link></command>
|
|
||||||
and <command><link linkend="repmgr-cluster-crosscheck">repmgr cluster crosscheck</link></command>
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<tip>
|
|
||||||
<simpara>
|
|
||||||
Consider setting <varname>ConnectTimeout</varname> to a low value in your SSH configuration.
|
|
||||||
This will make it faster to detect any SSH connection errors.
|
|
||||||
</simpara>
|
|
||||||
</tip>
|
|
||||||
|
|
||||||
<sect2 id="configuration-postgresql" xreflabel="PostgreSQL configuration">
|
|
||||||
<indexterm>
|
|
||||||
<primary>configuration</primary>
|
|
||||||
<secondary>PostgreSQL</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>PostgreSQL configuration</primary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<title>PostgreSQL configuration for &repmgr;</title>
|
|
||||||
<para>
|
|
||||||
The following PostgreSQL configuration parameters may need to be changed in order
|
|
||||||
for &repmgr; (and replication itself) to function correctly.
|
|
||||||
</para>
|
|
||||||
<variablelist>
|
|
||||||
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>hot_standby</primary>
|
|
||||||
<secondary>PostgreSQL configuration</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<term><option>hot_standby</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
<option>hot_standby</option> must always be set to <literal>on</literal>, as &repmgr; needs
|
|
||||||
to be able to connect to each server it manages.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
Note that <option>hot_standby</option> defaults to <literal>on</literal> from PostgreSQL 10
|
|
||||||
and later; in PostgreSQL 9.6 and earlier, the default was <literal>off</literal>.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
PostgreSQL documentation: <ulink url="https://www.postgresql.org/docs/current/runtime-config-replication.html#GUC-HOT-STANDBY">hot_standby</ulink>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>wal_level</primary>
|
|
||||||
<secondary>PostgreSQL configuration</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<term><option>wal_level</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
<option>wal_level</option> must be one of <option>replica</option> or <option>logical</option>
|
|
||||||
(PostgreSQL 9.5 and earlier: one of <option>hot_standby</option> or <option>logical</option>).
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
PostgreSQL documentation: <ulink url="https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-WAL-LEVEL">wal_level</ulink>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>max_wal_senders</primary>
|
|
||||||
<secondary>PostgreSQL configuration</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<term><option>max_wal_senders</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
<option>max_wal_senders</option> must be set to a value of <literal>2</literal> or greater.
|
|
||||||
In general you will need one WAL sender for each standby which will attach to the PostgreSQL
|
|
||||||
instance; additionally &repmgr; will require two free WAL senders in order to clone further
|
|
||||||
standbys.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
<option>max_wal_senders</option> should be set to an appropriate value on all PostgreSQL
|
|
||||||
instances in the replication cluster which may potentially become a primary server or
|
|
||||||
(in cascading replication) the upstream server of a standby.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
PostgreSQL documentation: <ulink url="https://www.postgresql.org/docs/current/runtime-config-replication.html#GUC-MAX-WAL-SENDERS">max_wal_senders</ulink>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>max_replication_slots</primary>
|
|
||||||
<secondary>PostgreSQL configuration</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<term><option>max_replication_slots</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
If you are intending to use replication slots, <option>max_replication_slots</option>
|
|
||||||
must be set to a non-zero value.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
<option>max_replication_slots</option> should be set to an appropriate value on all PostgreSQL
|
|
||||||
instances in the replication cluster which may potentially become a primary server or
|
|
||||||
(in cascading replication) the upstream server of a standby.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
PostgreSQL documentation: <ulink url="https://www.postgresql.org/docs/current/runtime-config-replication.html#GUC-MAX-REPLICATION-SLOTS">max_replication_slots</ulink>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>wal_log_hints</primary>
|
|
||||||
<secondary>PostgreSQL configuration</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<term><option>wal_log_hints</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>If you are intending to use <application>pg_rewind</application>,
|
|
||||||
and the cluster was not initialised using data checksums, you may want to consider enabling
|
|
||||||
<option>wal_log_hints</option>.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
For more details see <xref linkend="repmgr-node-rejoin-pg-rewind">.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
PostgreSQL documentation: <ulink url="https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-WAL-LOG-HINTS">wal_log_hints</ulink>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>archive_mode</primary>
|
|
||||||
<secondary>PostgreSQL configuration</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<term><option>archive_mode</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
We suggest setting <option>archive_mode</option> to <literal>on</literal> (and
|
|
||||||
<option>archive_command</option> to <literal>/bin/true</literal>; see below)
|
|
||||||
even if you are currently not planning to use WAL file archiving.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
This will make it simpler to set up WAL file archiving if it is ever required,
|
|
||||||
as changes to <option>archive_mode</option> require a full PostgreSQL server
|
|
||||||
restart, while <option>archive_command</option> changes can be applied via a normal
|
|
||||||
configuration reload.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
However, &repmgr; itself does not require WAL file archiving.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
PostgreSQL documentation: <ulink url="https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-ARCHIVE-MODE">archive_mode</ulink>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>archive_command</primary>
|
|
||||||
<secondary>PostgreSQL configuration</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<term><option>archive_command</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
If you have set <option>archive_mode</option> to <literal>on</literal> but are not currently planning
|
|
||||||
to use WAL file archiving, set <option>archive_command</option> to a command which does nothing but returns
|
|
||||||
<literal>true</literal>, such as <command>/bin/true</command>. See above for details.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
PostgreSQL documentation: <ulink url="https://www.postgresql.org/docs/current/runtime-config-wal.html#GUC-ARCHIVE-COMMAND">archive_command</ulink>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>wal_keep_segments</primary>
|
|
||||||
<secondary>PostgreSQL configuration</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<term><option>wal_keep_segments</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Normally there is no need to set <option>wal_keep_segments</option> (default: <literal>0</literal>), as it
|
|
||||||
is <emphasis>not</emphasis> a reliable way of ensuring that all required WAL segments are available to standbys.
|
|
||||||
Replication slots and/or an archiving solution such as Barman are recommended to ensure standbys have a reliable
|
|
||||||
source of WAL segments at all times.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
The only reason ever to set <option>wal_keep_segments</option> is you have
|
|
||||||
you have configured <option>pg_basebackup_options</option>
|
|
||||||
in <filename>repmgr.conf</filename> to include the setting <literal>--wal-method=fetch</literal>
|
|
||||||
(PostgreSQL 9.6 and earlier: <literal>--xlog-method=fetch</literal>)
|
|
||||||
<emphasis>and</emphasis> you have <emphasis>not</emphasis> set <option>restore_command</option>
|
|
||||||
in <filename>repmgr.conf</filename> to fetch WAL files from a reliable source such as Barman,
|
|
||||||
in which case you'll need to set <option>wal_keep_segments</option>
|
|
||||||
to a sufficiently high number to ensure that all WAL files required by the standby
|
|
||||||
are retained. However we do not recommend managing replication in this way.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
PostgreSQL documentation: <ulink url="https://www.postgresql.org/docs/current/runtime-config-replication.html#GUC-WAL-KEEP-SEGMENTS">wal_keep_segments</ulink>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
</variablelist>
|
|
||||||
<para>
|
|
||||||
See also the <link linkend="quickstart-postgresql-configuration">PostgreSQL configuration</link> section in the
|
|
||||||
<link linkend="quickstart">Quick-start guide</link>.
|
|
||||||
</para>
|
|
||||||
</sect2>
|
|
||||||
|
|
||||||
|
|
||||||
</sect1>
|
|
||||||
|
|
||||||
|
|
||||||
&configuration-file;
|
&configuration-file;
|
||||||
&configuration-file-required-settings;
|
&configuration-file-required-settings;
|
||||||
&configuration-file-log-settings;
|
&configuration-file-log-settings;
|
||||||
|
|||||||
@@ -58,7 +58,6 @@
|
|||||||
<!ENTITY repmgrd-cascading-replication SYSTEM "repmgrd-cascading-replication.sgml">
|
<!ENTITY repmgrd-cascading-replication SYSTEM "repmgrd-cascading-replication.sgml">
|
||||||
<!ENTITY repmgrd-network-split SYSTEM "repmgrd-network-split.sgml">
|
<!ENTITY repmgrd-network-split SYSTEM "repmgrd-network-split.sgml">
|
||||||
<!ENTITY repmgrd-witness-server SYSTEM "repmgrd-witness-server.sgml">
|
<!ENTITY repmgrd-witness-server SYSTEM "repmgrd-witness-server.sgml">
|
||||||
<!ENTITY repmgrd-pausing SYSTEM "repmgrd-pausing.sgml">
|
|
||||||
<!ENTITY repmgrd-bdr SYSTEM "repmgrd-bdr.sgml">
|
<!ENTITY repmgrd-bdr SYSTEM "repmgrd-bdr.sgml">
|
||||||
|
|
||||||
<!ENTITY repmgr-primary-register SYSTEM "repmgr-primary-register.sgml">
|
<!ENTITY repmgr-primary-register SYSTEM "repmgr-primary-register.sgml">
|
||||||
@@ -74,15 +73,11 @@
|
|||||||
<!ENTITY repmgr-node-status SYSTEM "repmgr-node-status.sgml">
|
<!ENTITY repmgr-node-status SYSTEM "repmgr-node-status.sgml">
|
||||||
<!ENTITY repmgr-node-check SYSTEM "repmgr-node-check.sgml">
|
<!ENTITY repmgr-node-check SYSTEM "repmgr-node-check.sgml">
|
||||||
<!ENTITY repmgr-node-rejoin SYSTEM "repmgr-node-rejoin.sgml">
|
<!ENTITY repmgr-node-rejoin SYSTEM "repmgr-node-rejoin.sgml">
|
||||||
<!ENTITY repmgr-node-service SYSTEM "repmgr-node-service.sgml">
|
|
||||||
<!ENTITY repmgr-cluster-show SYSTEM "repmgr-cluster-show.sgml">
|
<!ENTITY repmgr-cluster-show SYSTEM "repmgr-cluster-show.sgml">
|
||||||
<!ENTITY repmgr-cluster-matrix SYSTEM "repmgr-cluster-matrix.sgml">
|
<!ENTITY repmgr-cluster-matrix SYSTEM "repmgr-cluster-matrix.sgml">
|
||||||
<!ENTITY repmgr-cluster-crosscheck SYSTEM "repmgr-cluster-crosscheck.sgml">
|
<!ENTITY repmgr-cluster-crosscheck SYSTEM "repmgr-cluster-crosscheck.sgml">
|
||||||
<!ENTITY repmgr-cluster-event SYSTEM "repmgr-cluster-event.sgml">
|
<!ENTITY repmgr-cluster-event SYSTEM "repmgr-cluster-event.sgml">
|
||||||
<!ENTITY repmgr-cluster-cleanup SYSTEM "repmgr-cluster-cleanup.sgml">
|
<!ENTITY repmgr-cluster-cleanup SYSTEM "repmgr-cluster-cleanup.sgml">
|
||||||
<!ENTITY repmgr-daemon-status SYSTEM "repmgr-daemon-status.sgml">
|
|
||||||
<!ENTITY repmgr-daemon-pause SYSTEM "repmgr-daemon-pause.sgml">
|
|
||||||
<!ENTITY repmgr-daemon-unpause SYSTEM "repmgr-daemon-unpause.sgml">
|
|
||||||
|
|
||||||
<!ENTITY appendix-release-notes SYSTEM "appendix-release-notes.sgml">
|
<!ENTITY appendix-release-notes SYSTEM "appendix-release-notes.sgml">
|
||||||
<!ENTITY appendix-faq SYSTEM "appendix-faq.sgml">
|
<!ENTITY appendix-faq SYSTEM "appendix-faq.sgml">
|
||||||
|
|||||||
@@ -29,10 +29,9 @@
|
|||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
&repmgr; RPM packages are designed to be compatible with the community-provided PostgreSQL packages
|
&repmgr; packages are designed to be compatible with the community-provided PostgreSQL packages.
|
||||||
and 2ndQuadrant's <ulink url="https://www.2ndquadrant.com/en/resources/2ndqpostgres/">2ndQPostgres</ulink>.
|
|
||||||
They may not work with vendor-specific packages such as those provided by RedHat for RHEL
|
They may not work with vendor-specific packages such as those provided by RedHat for RHEL
|
||||||
customers, as the PostgreSQL filesystem layout may be different to the community RPMs.
|
customers, as the filesystem layout may be different to the community RPMs.
|
||||||
Please contact your support vendor for assistance.
|
Please contact your support vendor for assistance.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
@@ -48,76 +47,54 @@
|
|||||||
<title>2ndQuadrant public RPM yum repository</title>
|
<title>2ndQuadrant public RPM yum repository</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
Beginning with <ulink url="https://repmgr.org/docs/4.1/release-4.0.5.html">repmgr 4.0.5</ulink>,
|
||||||
<ulink url="https://2ndquadrant.com/">2ndQuadrant</ulink> provides a dedicated <literal>yum</literal>
|
<ulink url="https://2ndquadrant.com/">2ndQuadrant</ulink> provides a dedicated <literal>yum</literal>
|
||||||
<ulink url="https://dl.2ndquadrant.com/">public repository</ulink> for 2ndQuadrant software,
|
<ulink url="https://dl.2ndquadrant.com/">public repository</ulink> for 2ndQuadrant software,
|
||||||
including &repmgr;. We recommend using this for all future &repmgr; releases.
|
including &repmgr;. We recommend using this for all future &repmgr; releases.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
General instructions for using this repository can be found on its
|
General instructions for using this repository can be found on its
|
||||||
<ulink url="https://dl.2ndquadrant.com/">homepage</ulink>. Specific instructions
|
<ulink url="https://dl.2ndquadrant.com/">homepage</ulink>. Specific instructions
|
||||||
for installing &repmgr; follow below.
|
for installing &repmgr; follow below.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
<emphasis>Installation</emphasis>
|
<emphasis>Installation</emphasis>
|
||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Locate the repository RPM for your PostgreSQL version from the list at:
|
Locate the repository RPM for your PostgreSQL version from the list at:
|
||||||
<ulink url="https://dl.2ndquadrant.com/">https://dl.2ndquadrant.com/</ulink>
|
<ulink url="https://dl.2ndquadrant.com/">https://dl.2ndquadrant.com/</ulink>
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Install the repository definition for your distribution and PostgreSQL version
|
Install the repository definition for your distribution and PostgreSQL version
|
||||||
(this enables the 2ndQuadrant repository as a source of &repmgr; packages).
|
(this enables the 2ndQuadrant repository as a source of &repmgr; packages).
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
For example, for PostgreSQL 10 on CentOS, execute:
|
For example, for PostgreSQL 10 on CentOS, execute:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
curl https://dl.2ndquadrant.com/default/release/get/10/rpm | sudo bash</programlisting>
|
curl https://dl.2ndquadrant.com/default/release/get/10/rpm | sudo bash</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
<para>
|
||||||
<para>
|
Verify that the repository is installed with:
|
||||||
For PostgreSQL 9.6 on CentOS, execute:
|
<programlisting>
|
||||||
<programlisting>
|
|
||||||
curl https://dl.2ndquadrant.com/default/release/get/9.6/rpm | sudo bash</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Verify that the repository is installed with:
|
|
||||||
<programlisting>
|
|
||||||
sudo yum repolist</programlisting>
|
sudo yum repolist</programlisting>
|
||||||
The output should contain two entries like this:
|
The output should contain two entries like this:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
2ndquadrant-dl-default-release-pg10/7/x86_64 2ndQuadrant packages (PG10) for 7 - x86_64 4
|
2ndquadrant-dl-default-release-pg10/7/x86_64 2ndQuadrant packages (PG10) for 7 - x86_64 4
|
||||||
2ndquadrant-dl-default-release-pg10-debug/7/x86_64 2ndQuadrant packages (PG10) for 7 - x86_64 - Debug 3</programlisting>
|
2ndquadrant-dl-default-release-pg10-debug/7/x86_64 2ndQuadrant packages (PG10) for 7 - x86_64 - Debug 3</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Install the &repmgr version appropriate for your PostgreSQL version (e.g. <literal>repmgr10</literal>):
|
Install the &repmgr version appropriate for your PostgreSQL version (e.g. <literal>repmgr10</literal>):
|
||||||
<programlisting>
|
<programlisting>
|
||||||
sudo yum install repmgr10</programlisting>
|
$ yum install repmgr10</programlisting>
|
||||||
</para>
|
</para>
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
For packages for PostgreSQL 9.6 and earlier, the package name does not contain
|
|
||||||
a period between major and minor version numbers, e.g.
|
|
||||||
<literal>repmgr96</literal>.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
<tip>
|
|
||||||
<para>
|
|
||||||
To determine the names of available packages, execute:
|
|
||||||
<programlisting>
|
|
||||||
yum search repmgr</programlisting>
|
|
||||||
</para>
|
|
||||||
</tip>
|
|
||||||
|
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</para>
|
</para>
|
||||||
@@ -186,15 +163,16 @@ yum search repmgr</programlisting>
|
|||||||
<title>2ndQuadrant public apt repository for Debian/Ubuntu</title>
|
<title>2ndQuadrant public apt repository for Debian/Ubuntu</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
Beginning with <ulink url="https://repmgr.org/docs/4.0/release-4.0.5.html">repmgr 4.0.5</ulink>,
|
||||||
<ulink url="https://2ndquadrant.com/">2ndQuadrant</ulink> provides a
|
<ulink url="https://2ndquadrant.com/">2ndQuadrant</ulink> provides a
|
||||||
<ulink url="https://dl.2ndquadrant.com/">public apt repository</ulink> for 2ndQuadrant software,
|
<ulink url="https://dl.2ndquadrant.com/">public apt repository</ulink> for 2ndQuadrant software,
|
||||||
including &repmgr;.
|
including &repmgr;.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
General instructions for using this repository can be found on its
|
General instructions for using this repository can be found on its
|
||||||
<ulink url="https://dl.2ndquadrant.com/">homepage</ulink>. Specific instructions
|
<ulink url="https://dl.2ndquadrant.com/">homepage</ulink>. Specific instructions
|
||||||
for installing &repmgr; follow below.
|
for installing &repmgr; follow below.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
@@ -202,13 +180,13 @@ yum search repmgr</programlisting>
|
|||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Install the repository definition for your distribution and PostgreSQL version
|
Install the repository definition for your distribution and PostgreSQL version
|
||||||
(this enables the 2ndQuadrant repository as a source of &repmgr; packages) by executing:
|
(this enables the 2ndQuadrant repository as a source of &repmgr; packages) by executing:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
curl https://dl.2ndquadrant.com/default/release/get/deb | sudo bash</programlisting>
|
curl https://dl.2ndquadrant.com/default/release/get/deb | sudo bash</programlisting>
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
This will automatically install the following additional packages, if not already present:
|
This will automatically install the following additional packages, if not already present:
|
||||||
@@ -225,12 +203,12 @@ curl https://dl.2ndquadrant.com/default/release/get/deb | sudo bash</programlist
|
|||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Install the &repmgr version appropriate for your PostgreSQL version (e.g. <literal>repmgr10</literal>):
|
Install the &repmgr version appropriate for your PostgreSQL version (e.g. <literal>repmgr10</literal>):
|
||||||
<programlisting>
|
<programlisting>
|
||||||
sudo apt-get install postgresql-10-repmgr</programlisting>
|
$ apt-get install postgresql-10-repmgr</programlisting>
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
For packages for PostgreSQL 9.6 and earlier, the package name includes
|
For packages for PostgreSQL 9.6 and earlier, the package name includes
|
||||||
@@ -238,11 +216,11 @@ sudo apt-get install postgresql-10-repmgr</programlisting>
|
|||||||
<literal>postgresql-9.6-repmgr</literal>.
|
<literal>postgresql-9.6-repmgr</literal>.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
</sect3>
|
</sect3>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|||||||
@@ -13,9 +13,8 @@
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
&repmgr; 4.x is compatible with all PostgreSQL versions from 9.3. See
|
From version 4.0, repmgr is compatible with all PostgreSQL versions from 9.3, including PostgreSQL 10.
|
||||||
section <link linkend="install-compatibility-matrix">&repmgr; compatibility matrix</link>
|
Note that some &repmgr; functionality is not available in PostgreSQL 9.3 and PostgreSQL 9.4.
|
||||||
for an overview of version compatibility.
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
@@ -32,33 +31,34 @@
|
|||||||
<para>
|
<para>
|
||||||
&repmgr; must be installed on each server in the replication cluster.
|
&repmgr; must be installed on each server in the replication cluster.
|
||||||
If installing repmgr from packages, the package version must match the PostgreSQL
|
If installing repmgr from packages, the package version must match the PostgreSQL
|
||||||
version. If installing from source, &repmgr; must be compiled against the same
|
version. If installing from source, repmgr must be compiled against the same
|
||||||
major version.
|
major version.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<note>
|
|
||||||
<simpara>
|
|
||||||
The same "major" &repmgr; version (e.g. <literal>4.2.x</literal>) <emphasis>must</emphasis>
|
|
||||||
be installed on all node in the replication cluster. We strongly recommend keeping all
|
|
||||||
nodes on the same (preferably latest) "minor" &repmgr; version to minimize the risk
|
|
||||||
of incompatibilities.
|
|
||||||
</simpara>
|
|
||||||
<simpara>
|
|
||||||
If different "major" &repmgr; versions (e.g. 3.3.x and 4.1.x)
|
|
||||||
are installed on different nodes, in the best case &repmgr; (in particular <application>repmgrd</application>)
|
|
||||||
will not run. In the worst case, you will end up with a broken cluster.
|
|
||||||
</simpara>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
A dedicated system user for &repmgr; is <emphasis>not</emphasis> required; as many &repmgr; and
|
A dedicated system user for &repmgr; is *not* required; as many &repmgr; and
|
||||||
<application>repmgrd</application> actions require direct access to the PostgreSQL data directory,
|
<application>repmgrd</application> actions require direct access to the PostgreSQL data directory,
|
||||||
these commands should be executed by the <literal>postgres</literal> user.
|
these commands should be executed by the <literal>postgres</literal> user.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
See also <link linkend="configuration-prerequisites">Prerequisites for configuration</link>
|
Passwordless <command>ssh</command> connectivity between all servers in the replication cluster
|
||||||
for information on networking requirements.
|
is not required, but is necessary in the following cases:
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<simpara>if you need &repmgr; to copy configuration files from outside the PostgreSQL
|
||||||
|
data directory (in which case <command>rsync</command> is also required)</simpara>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<simpara>to perform <link linkend="performing-switchover">switchover operations</link></simpara>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<simpara>
|
||||||
|
when executing <command><link linkend="repmgr-cluster-matrix">repmgr cluster matrix</link></command>
|
||||||
|
and <command><link linkend="repmgr-cluster-crosscheck">repmgr cluster crosscheck</link></command>
|
||||||
|
</simpara>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<tip>
|
<tip>
|
||||||
@@ -69,111 +69,4 @@
|
|||||||
terminated if your <command>ssh</command> session to the server is interrupted or closed.
|
terminated if your <command>ssh</command> session to the server is interrupted or closed.
|
||||||
</simpara>
|
</simpara>
|
||||||
</tip>
|
</tip>
|
||||||
|
|
||||||
<sect2 id="install-compatibility-matrix">
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>repmgr</primary>
|
|
||||||
<secondary>compatibility matrix</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>compatibility matrix</primary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<title>&repmgr; compatibility matrix</title>
|
|
||||||
<para>
|
|
||||||
The following table provides an overview of which &repmgr; version supports
|
|
||||||
which PostgreSQL version.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
|
|
||||||
<table id="repmgr-compatibility-matrix">
|
|
||||||
<title>&repmgr; compatibility matrix</title>
|
|
||||||
|
|
||||||
<tgroup cols="2">
|
|
||||||
<thead>
|
|
||||||
<row>
|
|
||||||
<entry>
|
|
||||||
&repmgr; version
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
Latest release
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
Supported PostgreSQL versions
|
|
||||||
</entry>
|
|
||||||
</row>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
<row>
|
|
||||||
<entry>
|
|
||||||
&repmgr; 4.x
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<link linkend="release-4.2">4.2</link> (2018-10-24)
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
9.3, 9.4, 9.5, 9.6, 10, 11
|
|
||||||
</entry>
|
|
||||||
</row>
|
|
||||||
|
|
||||||
<row>
|
|
||||||
<entry>
|
|
||||||
&repmgr; 3.x
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<ulink url="https://repmgr.org/release-notes-3.3.2.html">3.3.2</ulink> (2017-05-30)
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
9.3, 9.4, 9.5, 9.6
|
|
||||||
</entry>
|
|
||||||
</row>
|
|
||||||
|
|
||||||
<row>
|
|
||||||
<entry>
|
|
||||||
&repmgr; 2.x
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
<ulink url="https://repmgr.org/release-notes-2.0.3.html">2.0.3</ulink> (2015-04-16)
|
|
||||||
</entry>
|
|
||||||
<entry>
|
|
||||||
9.0, 9.1, 9.2, 9.3, 9.4
|
|
||||||
</entry>
|
|
||||||
</row>
|
|
||||||
</tbody>
|
|
||||||
|
|
||||||
</tgroup>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<important>
|
|
||||||
<para>
|
|
||||||
The &repmgr; 2.x and 3.x series are no longer maintained or supported.
|
|
||||||
We strongly recommend upgrading to the latest &repmgr; version.
|
|
||||||
</para>
|
|
||||||
</important>
|
|
||||||
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Note that some &repmgr; functionality is not available in PostgreSQL 9.3 and PostgreSQL 9.4.
|
|
||||||
</para>
|
|
||||||
<itemizedlist spacing="compact" mark="bullet">
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
PostgreSQL 9.3 does not support replication slots, so corresponding &repmgr; functionality
|
|
||||||
is not available.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
In PostgreSQL 9.3 and PostgreSQL 9.4, <command>pg_rewind</command> is not part of the core
|
|
||||||
distribution. <command>pg_rewind</command> will need to be compiled separately to be able
|
|
||||||
to use any &repmgr; functionality which takes advantage of it.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
|
|
||||||
</sect2>
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|||||||
@@ -26,68 +26,12 @@
|
|||||||
add the <ulink
|
add the <ulink
|
||||||
url="http://apt.postgresql.org/">apt.postgresql.org</ulink>
|
url="http://apt.postgresql.org/">apt.postgresql.org</ulink>
|
||||||
repository to your <filename>sources.list</filename> if you
|
repository to your <filename>sources.list</filename> if you
|
||||||
have not already done so, and ensure the source repository is enabled.
|
have not already done so. Then install the pre-requisites for
|
||||||
</para>
|
building PostgreSQL with:
|
||||||
<tip>
|
|
||||||
<para>
|
|
||||||
If not configured, the source repository can be added by including
|
|
||||||
a <literal>deb-src</literal> line as a copy of the existing <literal>deb</literal>
|
|
||||||
line in the repository file, which is usually
|
|
||||||
<filename>/etc/apt/sources.list.d/pgdg.list</filename>, e.g.:
|
|
||||||
<programlisting>
|
|
||||||
deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main
|
|
||||||
deb-src http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main</programlisting>
|
|
||||||
</para>
|
|
||||||
</tip>
|
|
||||||
<para>
|
|
||||||
Then install the prerequisites for
|
|
||||||
building PostgreSQL with e.g.:
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get build-dep postgresql-9.6</programlisting>
|
sudo apt-get build-dep postgresql-9.6</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<important>
|
|
||||||
<simpara>
|
|
||||||
Select the appropriate PostgreSQL version for your target repmgr version.
|
|
||||||
</simpara>
|
|
||||||
</important>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
If using <command>apt-get build-dep</command> is not possible, the
|
|
||||||
following packages may need to be installed manually:
|
|
||||||
|
|
||||||
<itemizedlist spacing="compact" mark="bullet">
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara><literal>llibedit-dev</literal></simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara><literal>llibkrb5-dev</literal></simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara><literal>llibpam0g-dev</literal></simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara><literal>llibreadline-dev</literal></simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara><literal>llibselinux1-dev</literal></simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara><literal>llibssl-dev</literal></simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara><literal>llibxml2-dev</literal></simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara><literal>llibxslt1-dev</literal></simpara>
|
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
@@ -101,45 +45,15 @@ deb-src http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main</programlisti
|
|||||||
sudo yum install yum-utils openjade docbook-dtds docbook-style-dsssl docbook-style-xsl
|
sudo yum install yum-utils openjade docbook-dtds docbook-style-dsssl docbook-style-xsl
|
||||||
sudo yum-builddep postgresql96</programlisting>
|
sudo yum-builddep postgresql96</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<important>
|
|
||||||
<simpara>
|
|
||||||
Select the appropriate PostgreSQL version for your target repmgr version.
|
|
||||||
</simpara>
|
|
||||||
</important>
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
If using <command>yum-builddep</command> is not possible, the
|
|
||||||
following packages may need to be installed manually:
|
|
||||||
|
|
||||||
<itemizedlist spacing="compact" mark="bullet">
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara><literal>libselinux-devel</literal></simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara><literal>libxml2-devel</literal></simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara><literal>libxslt-devel</literal></simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara><literal>openssl-devel</literal></simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara><literal>pam-devel</literal></simpara>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<simpara><literal>readline-devel</literal></simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<note>
|
||||||
|
<simpara>
|
||||||
|
Select the appropriate PostgreSQL versions for your target repmgr version.
|
||||||
|
</simpara>
|
||||||
|
</note>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
|
|
||||||
@@ -166,7 +80,7 @@ deb-src http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main</programlisti
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
There are also tags for each &repmgr; release, e.g. <literal>v4.2.0</literal>.
|
There are also tags for each &repmgr; release, e.g. <filename>4.0.5</filename>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@@ -251,7 +165,7 @@ deb-src http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main</programlisti
|
|||||||
<note>
|
<note>
|
||||||
<simpara>
|
<simpara>
|
||||||
Due to changes in PostgreSQL's documentation build system from PostgreSQL 10,
|
Due to changes in PostgreSQL's documentation build system from PostgreSQL 10,
|
||||||
the documentation can currently only be built against PostgreSQL 9.6 or earlier.
|
the documentation can currently only be built agains PostgreSQL 9.6 or earlier.
|
||||||
This limitation will be fixed when time and resources permit.
|
This limitation will be fixed when time and resources permit.
|
||||||
</simpara>
|
</simpara>
|
||||||
</note>
|
</note>
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
<chapter id="quickstart" xreflabel="Quick-start guide">
|
<chapter id="quickstart" xreflabel="Quick-start guide">
|
||||||
<title>Quick-start guide</title>
|
<title>Quick-start guide</title>
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>quickstart</primary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
This section gives a quick introduction to &repmgr;, including setting up a
|
This section gives a quick introduction to &repmgr;, including setting up a
|
||||||
sample &repmgr; installation and a basic replication cluster.
|
sample &repmgr; installation and a basic replication cluster.
|
||||||
@@ -54,8 +50,7 @@
|
|||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
If you want <application>repmgr</application> to copy configuration files which are
|
If you want <application>repmgr</application> to copy configuration files which are
|
||||||
located outside the PostgreSQL data directory, and/or to test
|
located outside the PostgreSQL data directory, and/or to test <command>switchover</command>
|
||||||
<command><link linkend="repmgr-standby-switchover">switchover</link></command>
|
|
||||||
functionality, you will also need passwordless SSH connections between both servers, and
|
functionality, you will also need passwordless SSH connections between both servers, and
|
||||||
<application>rsync</application> should be installed.
|
<application>rsync</application> should be installed.
|
||||||
</para>
|
</para>
|
||||||
@@ -68,7 +63,7 @@
|
|||||||
</tip>
|
</tip>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
<sect1 id="quickstart-postgresql-configuration" xreflabel="PostgreSQL configuration">
|
<sect1 id="quickstart-postgresql-configuration">
|
||||||
<title>PostgreSQL configuration</title>
|
<title>PostgreSQL configuration</title>
|
||||||
<para>
|
<para>
|
||||||
On the primary server, a PostgreSQL instance must be initialised and running.
|
On the primary server, a PostgreSQL instance must be initialised and running.
|
||||||
@@ -83,13 +78,6 @@
|
|||||||
|
|
||||||
max_wal_senders = 10
|
max_wal_senders = 10
|
||||||
|
|
||||||
# Enable replication slots; set this figure to at least one more
|
|
||||||
# than the number of standbys which will connect to this server.
|
|
||||||
# Note that repmgr will only make use of replication slots if
|
|
||||||
# "use_replication_slots" is set to "true" in repmgr.conf
|
|
||||||
|
|
||||||
max_replication_slots = 0
|
|
||||||
|
|
||||||
# Ensure WAL files contain enough information to enable read-only queries
|
# Ensure WAL files contain enough information to enable read-only queries
|
||||||
# on the standby.
|
# on the standby.
|
||||||
#
|
#
|
||||||
@@ -114,6 +102,16 @@
|
|||||||
# you WALs in a secure place. /bin/true is an example of a command that
|
# you WALs in a secure place. /bin/true is an example of a command that
|
||||||
# ignores archiving. Use something more sensible.
|
# ignores archiving. Use something more sensible.
|
||||||
archive_command = '/bin/true'
|
archive_command = '/bin/true'
|
||||||
|
|
||||||
|
# If you have configured "pg_basebackup_options"
|
||||||
|
# in "repmgr.conf" to include the setting "--xlog-method=fetch" (from
|
||||||
|
# PostgreSQL 10 "--wal-method=fetch"), *and* you have not set
|
||||||
|
# "restore_command" in "repmgr.conf"to fetch WAL files from another
|
||||||
|
# source such as Barman, you'll need to set "wal_keep_segments" to a
|
||||||
|
# high enough value to ensure that all WAL files generated while
|
||||||
|
# the standby is being cloned are retained until the standby starts up.
|
||||||
|
#
|
||||||
|
# wal_keep_segments = 5000
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<tip>
|
<tip>
|
||||||
<simpara>
|
<simpara>
|
||||||
@@ -128,9 +126,6 @@
|
|||||||
and the cluster was not initialised using data checksums, you may want to consider enabling
|
and the cluster was not initialised using data checksums, you may want to consider enabling
|
||||||
<varname>wal_log_hints</varname>; for more details see <xref linkend="repmgr-node-rejoin-pg-rewind">.
|
<varname>wal_log_hints</varname>; for more details see <xref linkend="repmgr-node-rejoin-pg-rewind">.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
|
||||||
See also the <link linkend="configuration-postgresql">PostgreSQL configuration</link> section in the <link linkend="configuration">repmgr configuaration guide</link>.
|
|
||||||
</para>
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
<sect1 id="quickstart-repmgr-user-database">
|
<sect1 id="quickstart-repmgr-user-database">
|
||||||
@@ -201,20 +196,11 @@
|
|||||||
<sect1 id="quickstart-standby-preparation">
|
<sect1 id="quickstart-standby-preparation">
|
||||||
<title>Preparing the standby</title>
|
<title>Preparing the standby</title>
|
||||||
<para>
|
<para>
|
||||||
On the standby, do <emphasis>not</emphasis> create a PostgreSQL instance (i.e.
|
On the standby, do not create a PostgreSQL instance, but do ensure the destination
|
||||||
do not execute <application>initdb</application> or any database creation
|
|
||||||
scripts provided by packages), but do ensure the destination
|
|
||||||
data directory (and any other directories which you want PostgreSQL to use)
|
data directory (and any other directories which you want PostgreSQL to use)
|
||||||
exist and are owned by the <literal>postgres</literal> system user. Permissions
|
exist and are owned by the <literal>postgres</literal> system user. Permissions
|
||||||
must be set to <literal>0700</literal> (<literal>drwx------</literal>).
|
must be set to <literal>0700</literal> (<literal>drwx------</literal>).
|
||||||
</para>
|
</para>
|
||||||
<tip>
|
|
||||||
<simpara>
|
|
||||||
&repmgr; will place a copy of the primary's database files in this directory.
|
|
||||||
It will however refuse to run if a PostgreSQL instance has already been
|
|
||||||
created there.
|
|
||||||
</simpara>
|
|
||||||
</tip>
|
|
||||||
<para>
|
<para>
|
||||||
Check the primary database is reachable from the standby using <application>psql</application>:
|
Check the primary database is reachable from the standby using <application>psql</application>:
|
||||||
</para>
|
</para>
|
||||||
@@ -251,6 +237,13 @@
|
|||||||
server. See sections <xref linkend="configuration"> and <xref linkend="configuration-file">
|
server. See sections <xref linkend="configuration"> and <xref linkend="configuration-file">
|
||||||
for further details about <filename>repmgr.conf</filename>.
|
for further details about <filename>repmgr.conf</filename>.
|
||||||
</para>
|
</para>
|
||||||
|
<tip>
|
||||||
|
<simpara>
|
||||||
|
For Debian-based distributions we recommend explictly setting
|
||||||
|
<option>pg_bindir</option> to the directory where <command>pg_ctl</command> and other binaries
|
||||||
|
not in the standard path are located. For PostgreSQL 9.6 this would be <filename>/usr/lib/postgresql/9.6/bin/</filename>.
|
||||||
|
</simpara>
|
||||||
|
</tip>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
@@ -269,24 +262,6 @@
|
|||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
<tip>
|
|
||||||
<simpara>
|
|
||||||
For Debian-based distributions we recommend explictly setting
|
|
||||||
<option>pg_bindir</option> to the directory where <command>pg_ctl</command> and other binaries
|
|
||||||
not in the standard path are located. For PostgreSQL 9.6 this would be <filename>/usr/lib/postgresql/9.6/bin/</filename>.
|
|
||||||
</simpara>
|
|
||||||
</tip>
|
|
||||||
|
|
||||||
<tip>
|
|
||||||
<simpara>
|
|
||||||
If your distribution places the &repmgr; binaries in a location other than the
|
|
||||||
PostgreSQL installation directory, specify this with <option>repmgr_bindir</option>
|
|
||||||
to enable &repmgr; to perform operations (e.g.
|
|
||||||
<command><link linkend="repmgr-cluster-crosscheck">repmgr cluster crosscheck</link></command>)
|
|
||||||
on other nodes.
|
|
||||||
</simpara>
|
|
||||||
</tip>
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
See the file
|
See the file
|
||||||
<ulink url="https://raw.githubusercontent.com/2ndQuadrant/repmgr/master/repmgr.conf.sample">repmgr.conf.sample</>
|
<ulink url="https://raw.githubusercontent.com/2ndQuadrant/repmgr/master/repmgr.conf.sample">repmgr.conf.sample</>
|
||||||
|
|||||||
@@ -51,20 +51,6 @@
|
|||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Options</title>
|
|
||||||
<variablelist>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--node-id</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Only delete monitoring records for the specified node.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title>See also</title>
|
<title>See also</title>
|
||||||
|
|||||||
@@ -55,37 +55,12 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>ERR_BAD_SSH (12)</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
One or more nodes could not be accessed via SSH.
|
|
||||||
</para>
|
|
||||||
<note>
|
|
||||||
<simpara>
|
|
||||||
This only applies to nodes unreachable from the node where
|
|
||||||
this command is executed.
|
|
||||||
</simpara>
|
|
||||||
<simpara>
|
|
||||||
It's also possible that the crosscheck establishes that
|
|
||||||
connections between PostgreSQL on all nodes are functioning,
|
|
||||||
even if SSH access between some nodes is not possible.
|
|
||||||
</simpara>
|
|
||||||
</note>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>ERR_NODE_STATUS (25)</option></term>
|
<term><option>ERR_NODE_STATUS (25)</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
PostgreSQL on one or more nodes could not be reached.
|
One or more nodes could not be reached.
|
||||||
</para>
|
</para>
|
||||||
<note>
|
|
||||||
<simpara>
|
|
||||||
This error code overrides <option>ERR_BAD_SSH</option>.
|
|
||||||
</simpara>
|
|
||||||
</note>
|
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|||||||
@@ -115,26 +115,12 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>ERR_BAD_SSH (12)</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
One or more nodes could not be accessed via SSH.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>ERR_NODE_STATUS (25)</option></term>
|
<term><option>ERR_NODE_STATUS (25)</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
PostgreSQL on one or more nodes could not be reached.
|
One or more nodes could not be reached.
|
||||||
</para>
|
</para>
|
||||||
<note>
|
|
||||||
<simpara>
|
|
||||||
This error code overrides <option>ERR_BAD_SSH</option>.
|
|
||||||
</simpara>
|
|
||||||
</note>
|
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@
|
|||||||
<para>
|
<para>
|
||||||
<command>repmgr cluster show</command> accepts an optional parameter <literal>--csv</literal>, which
|
<command>repmgr cluster show</command> accepts an optional parameter <literal>--csv</literal>, which
|
||||||
outputs the replication cluster's status in a simple CSV format, suitable for
|
outputs the replication cluster's status in a simple CSV format, suitable for
|
||||||
parsing by scripts, e.g.:
|
parsing by scripts:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
$ repmgr -f /etc/repmgr.conf cluster show --csv
|
$ repmgr -f /etc/repmgr.conf cluster show --csv
|
||||||
1,-1,-1
|
1,-1,-1
|
||||||
@@ -150,31 +150,11 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>ERR_BAD_CONFIG (1)</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
An issue was encountered while attempting to retrieve
|
|
||||||
&repmgr; metadata.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>ERR_DB_CONN (6)</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
&repmgr; was unable to connect to the local PostgreSQL instance.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>ERR_NODE_STATUS (25)</option></term>
|
<term><option>ERR_NODE_STATUS (25)</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
One or more issues were detected with the replication configuration,
|
One or more issues were detected.
|
||||||
e.g. a node was not in its expected state.
|
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@@ -185,7 +165,7 @@
|
|||||||
<refsect1>
|
<refsect1>
|
||||||
<title>See also</title>
|
<title>See also</title>
|
||||||
<para>
|
<para>
|
||||||
<xref linkend="repmgr-node-status">, <xref linkend="repmgr-node-check">, <xref linkend="repmgr-daemon-status">
|
<xref linkend="repmgr-node-status">, <xref linkend="repmgr-node-check">
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
<refentry id="repmgr-daemon-pause">
|
|
||||||
<indexterm>
|
|
||||||
<primary>repmgr daemon pause</primary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<refmeta>
|
|
||||||
<refentrytitle>repmgr daemon pause</refentrytitle>
|
|
||||||
</refmeta>
|
|
||||||
|
|
||||||
<refnamediv>
|
|
||||||
<refname>repmgr daemon pause</refname>
|
|
||||||
<refpurpose>Instruct all <application>repmgrd</application> instances in the replication cluster to pause failover operations</refpurpose>
|
|
||||||
</refnamediv>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Description</title>
|
|
||||||
<para>
|
|
||||||
This command can be run on any active node in the replication cluster to instruct all
|
|
||||||
running <application>repmgrd</application> instances to "pause" themselves, i.e. take no
|
|
||||||
action (such as promoting themselves or following a new primary) if a failover event is detected.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
This functionality is useful for performing maintenance operations, such as switchovers
|
|
||||||
or upgrades, which might otherwise trigger a failover if <application>repmgrd</application>
|
|
||||||
is running normally.
|
|
||||||
</para>
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
It's important to wait a few seconds after restarting PostgreSQL on any node before running
|
|
||||||
<command>repmgr daemon pause</command>, as the <application>repmgrd</application> instance
|
|
||||||
on the restarted node will take a second or two before it has updated its status.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
<para>
|
|
||||||
<xref linkend="repmgr-daemon-unpause"> will instruct all previously paused <application>repmgrd</application>
|
|
||||||
instances to resume normal failover operation.
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Execution</title>
|
|
||||||
<para>
|
|
||||||
<command>repmgr daemon pause</command> can be executed on any active node in the
|
|
||||||
replication cluster. A valid <filename>repmgr.conf</filename> file is required.
|
|
||||||
It will have no effect on previously paused nodes.
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Example</title>
|
|
||||||
<para>
|
|
||||||
<programlisting>
|
|
||||||
$ repmgr -f /etc/repmgr.conf daemon pause
|
|
||||||
NOTICE: node 1 (node1) paused
|
|
||||||
NOTICE: node 2 (node2) paused
|
|
||||||
NOTICE: node 3 (node3) paused</programlisting>
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Options</title>
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--dry-run</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Check if nodes are reachable but don't pause <application>repmgrd</application>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Exit codes</title>
|
|
||||||
<para>
|
|
||||||
Following exit codes can be emitted by <command>repmgr daemon unpause</command>:
|
|
||||||
</para>
|
|
||||||
<variablelist>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>SUCCESS (0)</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
<application>repmgrd</application> could be paused on all nodes.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>ERR_REPMGRD_PAUSE (26)</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
<application>repmgrd</application> could not be paused on one or mode nodes.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
</variablelist>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>See also</title>
|
|
||||||
<para>
|
|
||||||
<xref linkend="repmgr-daemon-unpause">, <xref linkend="repmgr-daemon-status">
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
</refentry>
|
|
||||||
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
<refentry id="repmgr-daemon-status">
|
|
||||||
<indexterm>
|
|
||||||
<primary>repmgr daemon status</primary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<refmeta>
|
|
||||||
<refentrytitle>repmgr daemon status</refentrytitle>
|
|
||||||
</refmeta>
|
|
||||||
|
|
||||||
<refnamediv>
|
|
||||||
<refname>repmgr daemon status</refname>
|
|
||||||
<refpurpose>display information about the status of <application>repmgrd</application> on each node in the cluster</refpurpose>
|
|
||||||
</refnamediv>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Description</title>
|
|
||||||
<para>
|
|
||||||
This command provides an overview over all active nodes in the cluster and the state
|
|
||||||
of each node's <application>repmgrd</application> instance. It can be used to check
|
|
||||||
the result of <xref linkend="repmgr-daemon-pause"> and <xref linkend="repmgr-daemon-unpause">
|
|
||||||
operations.
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Execution</title>
|
|
||||||
<para>
|
|
||||||
<command>repmgr daemon status</command> can be executed on any active node in the
|
|
||||||
replication cluster. A valid <filename>repmgr.conf</filename> file is required.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
After restarting PostgreSQL on any node, the <application>repmgrd</application> instance
|
|
||||||
will take a second or two before it is able to update its status. Until then,
|
|
||||||
<application>repmgrd</application> will be shown as not running.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Examples</title>
|
|
||||||
<para>
|
|
||||||
<application>repmgrd</application> running normally on all nodes:
|
|
||||||
<programlisting>$ repmgr -f /etc/repmgr.conf daemon status
|
|
||||||
ID | Name | Role | Status | repmgrd | PID | Paused?
|
|
||||||
----+-------+---------+---------+---------+------+---------
|
|
||||||
1 | node1 | primary | running | running | 7851 | no
|
|
||||||
2 | node2 | standby | running | running | 7889 | no
|
|
||||||
3 | node3 | standby | running | running | 7918 | no</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
<application>repmgrd</application> paused on all nodes (using <xref linkend="repmgr-daemon-pause">):
|
|
||||||
<programlisting>$ repmgr -f /etc/repmgr.conf daemon status
|
|
||||||
ID | Name | Role | Status | repmgrd | PID | Paused?
|
|
||||||
----+-------+---------+---------+---------+------+---------
|
|
||||||
1 | node1 | primary | running | running | 7851 | yes
|
|
||||||
2 | node2 | standby | running | running | 7889 | yes
|
|
||||||
3 | node3 | standby | running | running | 7918 | yes</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
<application>repmgrd</application> not running on one node:
|
|
||||||
<programlisting>$ repmgr -f /etc/repmgr.conf daemon status
|
|
||||||
ID | Name | Role | Status | repmgrd | PID | Paused?
|
|
||||||
----+-------+---------+---------+-------------+------+---------
|
|
||||||
1 | node1 | primary | running | running | 7851 | yes
|
|
||||||
2 | node2 | standby | running | not running | n/a | n/a
|
|
||||||
3 | node3 | standby | running | running | 7918 | yes</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Options</title>
|
|
||||||
|
|
||||||
<variablelist>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--csv</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
<command>repmgr daemon status</command> accepts an optional parameter <literal>--csv</literal>, which
|
|
||||||
outputs the replication cluster's status in a simple CSV format, suitable for
|
|
||||||
parsing by scripts, e.g.:
|
|
||||||
<programlisting>
|
|
||||||
$ repmgr -f /etc/repmgr.conf daemon status --csv
|
|
||||||
1,node1,primary,1,1,10204,1
|
|
||||||
2,node2,standby,1,0,-1,1
|
|
||||||
3,node3,standby,1,1,10225,1</programlisting>
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
The columns have following meanings:
|
|
||||||
<itemizedlist spacing="compact" mark="bullet">
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
node ID
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
node name
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
node type (primary or standby)
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
PostgreSQL server running
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
<application>repmgrd</application> running (1 = running, 0 = not running)
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
<application>repmgrd</application> PID (-1 if not running)
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
<application>repmgrd</application> paused (1 = paused, 0 = not paused)
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--verbose</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Display the full text of any database connection error messages
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
</variablelist>
|
|
||||||
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>See also</title>
|
|
||||||
<para>
|
|
||||||
<xref linkend="repmgr-daemon-pause">, <xref linkend="repmgr-daemon-unpause">, <xref linkend="repmgr-cluster-show">
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
</refentry>
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
<refentry id="repmgr-daemon-unpause">
|
|
||||||
<indexterm>
|
|
||||||
<primary>repmgr daemon unpause</primary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<refmeta>
|
|
||||||
<refentrytitle>repmgr daemon unpause</refentrytitle>
|
|
||||||
</refmeta>
|
|
||||||
|
|
||||||
<refnamediv>
|
|
||||||
<refname>repmgr daemon unpause</refname>
|
|
||||||
<refpurpose>Instruct all <application>repmgrd</application> instances in the replication cluster to resume failover operations</refpurpose>
|
|
||||||
</refnamediv>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Description</title>
|
|
||||||
<para>
|
|
||||||
This command can be run on any active node in the replication cluster to instruct all
|
|
||||||
running <application>repmgrd</application> instances to "unpause"
|
|
||||||
(following a previous execution of <xref linkend="repmgr-daemon-pause">)
|
|
||||||
and resume normal failover/monitoring operation.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
It's important to wait a few seconds after restarting PostgreSQL on any node before running
|
|
||||||
<command>repmgr daemon pause</command>, as the <application>repmgrd</application> instance
|
|
||||||
on the restarted node will take a second or two before it has updated its status.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Execution</title>
|
|
||||||
<para>
|
|
||||||
<command>repmgr daemon unpause</command> can be executed on any active node in the
|
|
||||||
replication cluster. A valid <filename>repmgr.conf</filename> file is required.
|
|
||||||
It will have no effect on nodes which are not already paused.
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Example</title>
|
|
||||||
<para>
|
|
||||||
<programlisting>
|
|
||||||
$ repmgr -f /etc/repmgr.conf daemon unpause
|
|
||||||
NOTICE: node 1 (node1) unpaused
|
|
||||||
NOTICE: node 2 (node2) unpaused
|
|
||||||
NOTICE: node 3 (node3) unpaused</programlisting>
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Options</title>
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--dry-run</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Check if nodes are reachable but don't unpause <application>repmgrd</application>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Exit codes</title>
|
|
||||||
<para>
|
|
||||||
Following exit codes can be emitted by <command>repmgr daemon unpause</command>:
|
|
||||||
</para>
|
|
||||||
<variablelist>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>SUCCESS (0)</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
<application>repmgrd</application> could be unpaused on all nodes.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>ERR_REPMGRD_PAUSE (26)</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
<application>repmgrd</application> could not be unpaused on one or mode nodes.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
</variablelist>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>See also</title>
|
|
||||||
<para>
|
|
||||||
<xref linkend="repmgr-daemon-pause">, <xref linkend="repmgr-daemon-status">
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
</refentry>
|
|
||||||
|
|
||||||
@@ -30,8 +30,7 @@
|
|||||||
Replication lag: OK (N/A - node is primary)
|
Replication lag: OK (N/A - node is primary)
|
||||||
WAL archiving: OK (0 pending files)
|
WAL archiving: OK (0 pending files)
|
||||||
Downstream servers: OK (2 of 2 downstream nodes attached)
|
Downstream servers: OK (2 of 2 downstream nodes attached)
|
||||||
Replication slots: OK (node has no replication slots)
|
Replication slots: OK (node has no replication slots)</programlisting>
|
||||||
Missing replication slots: OK (node has no missing replication slots)</programlisting>
|
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
|
|||||||
@@ -1,151 +0,0 @@
|
|||||||
<refentry id="repmgr-node-service">
|
|
||||||
<indexterm>
|
|
||||||
<primary>repmgr node service</primary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<refmeta>
|
|
||||||
<refentrytitle>repmgr node service</refentrytitle>
|
|
||||||
</refmeta>
|
|
||||||
|
|
||||||
<refnamediv>
|
|
||||||
<refname>repmgr node service</refname>
|
|
||||||
<refpurpose>show or execute the system service command to stop/start/restart/reload/promote a node</refpurpose>
|
|
||||||
</refnamediv>
|
|
||||||
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Description</title>
|
|
||||||
<para>
|
|
||||||
Shows or executes the system service command to stop/start/restart/reload a node.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
This command is mainly meant for internal &repmgr; usage, but is useful for
|
|
||||||
confirming the command configuration.
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
|
|
||||||
<title>Options</title>
|
|
||||||
|
|
||||||
<variablelist>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--dry-run</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Log the steps which would be taken, including displaying the command which would be executed.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--action</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
The action to perform. One of <literal>start</literal>, <literal>stop</literal>,
|
|
||||||
<literal>restart</literal>, <literal>reload</literal> or <literal>promote</literal>.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
If the parameter <option>--list-actions</option> is provided together with
|
|
||||||
<option>--action</option>, the command which would be executed will be printed.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--list-actions</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
List all configured commands.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
If the parameter <option>--action</option> is provided together with
|
|
||||||
<option>--list-actions</option>, the command which would be executed for that
|
|
||||||
particular action will be printed.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--checkpoint</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Issue a <command>CHECKPOINT</command> before stopping or restarting the node.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
|
||||||
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Exit codes</title>
|
|
||||||
<para>
|
|
||||||
Following exit codes can be emitted by <command>repmgr node service</command>:
|
|
||||||
</para>
|
|
||||||
<variablelist>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>SUCCESS (0)</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
No issues were detected.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>ERR_LOCAL_COMMAND (5)</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Execution of the system service command failed.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
</variablelist>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1>
|
|
||||||
<title>Examples</title>
|
|
||||||
<para>
|
|
||||||
See what action would be taken for a restart:
|
|
||||||
<programlisting>
|
|
||||||
[postgres@node1 ~]$ repmgr -f /etc/repmgr/11/repmgr.conf node service --action=restart --checkpoint --dry-run
|
|
||||||
INFO: a CHECKPOINT would be issued here
|
|
||||||
INFO: would execute server command "sudo service postgresql-11 restart"</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Restart the PostgreSQL instance:
|
|
||||||
<programlisting>
|
|
||||||
[postgres@node1 ~]$ repmgr -f /etc/repmgr/11/repmgr.conf node service --action=restart --checkpoint
|
|
||||||
NOTICE: issuing CHECKPOINT
|
|
||||||
DETAIL: executing server command "sudo service postgresql-11 restart"
|
|
||||||
Redirecting to /bin/systemctl restart postgresql-11.service</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
List all commands:
|
|
||||||
<programlisting>
|
|
||||||
[postgres@node1 ~]$ repmgr -f /etc/repmgr/11/repmgr.conf node service --list-actions
|
|
||||||
Following commands would be executed for each action:
|
|
||||||
|
|
||||||
start: "sudo service postgresql-11 start"
|
|
||||||
stop: "sudo service postgresql-11 stop"
|
|
||||||
restart: "sudo service postgresql-11 restart"
|
|
||||||
reload: "sudo service postgresql-11 reload"
|
|
||||||
promote: "/usr/pgsql-11/bin/pg_ctl -w -D '/var/lib/pgsql/11/data' promote"</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
List a single command:
|
|
||||||
<programlisting>
|
|
||||||
[postgres@node1 ~]$ repmgr -f /etc/repmgr/11/repmgr.conf node service --list-actions --action=promote
|
|
||||||
/usr/pgsql-11/bin/pg_ctl -w -D '/var/lib/pgsql/11/data' promote </programlisting>
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
</refentry>
|
|
||||||
@@ -35,10 +35,6 @@
|
|||||||
&repmgr; will attempt to check for potential issues but cannot guarantee
|
&repmgr; will attempt to check for potential issues but cannot guarantee
|
||||||
a successful switchover.
|
a successful switchover.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
|
||||||
&repmgr; will refuse to perform the switchover if an exclusive backup is running on
|
|
||||||
the current primary.
|
|
||||||
</para>
|
|
||||||
</note>
|
</note>
|
||||||
<para>
|
<para>
|
||||||
For more details on performing a switchover, including preparation and configuration,
|
For more details on performing a switchover, including preparation and configuration,
|
||||||
@@ -47,14 +43,11 @@
|
|||||||
|
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
From <link linkend="release-4.2">repmgr 4.2</link>, &repmgr; will instruct any running
|
<application>repmgrd</application> should not be active on any nodes while a switchover is being
|
||||||
<application>repmgrd</application> instances to pause operations while the switchover
|
executed. This restriction may be lifted in a later version.
|
||||||
is being carried out, to prevent <application>repmgrd</application> from
|
|
||||||
unintentionally promoting a node. For more details, see <xref linkend="repmgrd-pausing">.
|
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Users of &repmgr; versions prior to 4.2 should ensure that <application>repmgrd</application>
|
&repmgr; will not perform the switchover if an exclusive backup is running on the current primary.
|
||||||
is not running on any nodes while a switchover is being executed.
|
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
@@ -68,9 +61,8 @@
|
|||||||
<term><option>--always-promote</option></term>
|
<term><option>--always-promote</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Promote standby to primary, even if it is behind or has diverged
|
Promote standby to primary, even if it is behind original primary
|
||||||
from the original primary. The original primary will be shut down in any case,
|
(original primary will be shut down in any case).
|
||||||
and will need to be manually reintegrated into the replication cluster.
|
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@@ -130,21 +122,6 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--repmgrd-no-pause</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Don't pause <application>repmgrd</application> while executing a switchover.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
This option should not be used unless you take steps by other means
|
|
||||||
to ensure <application>repmgrd</application> is paused or not
|
|
||||||
running on all nodes.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>--siblings-follow</option></term>
|
<term><option>--siblings-follow</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
@@ -164,7 +141,19 @@
|
|||||||
Note that following parameters in <filename>repmgr.conf</filename> are relevant to the
|
Note that following parameters in <filename>repmgr.conf</filename> are relevant to the
|
||||||
switchover operation:
|
switchover operation:
|
||||||
<itemizedlist spacing="compact" mark="bullet">
|
<itemizedlist spacing="compact" mark="bullet">
|
||||||
|
<listitem>
|
||||||
|
<simpara>
|
||||||
|
<literal>reconnect_attempts</literal>: number of times to check the original primary
|
||||||
|
for a clean shutdown after executing the shutdown command, before aborting
|
||||||
|
</simpara>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<simpara>
|
||||||
|
<literal>reconnect_interval</literal>: interval (in seconds) to check the original
|
||||||
|
primary for a clean shutdown after executing the shutdown command (up to a maximum
|
||||||
|
of <literal>reconnect_attempts</literal> tries)
|
||||||
|
</simpara>
|
||||||
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<simpara>
|
<simpara>
|
||||||
<literal>replication_lag_critical</literal>:
|
<literal>replication_lag_critical</literal>:
|
||||||
@@ -174,29 +163,10 @@
|
|||||||
</simpara>
|
</simpara>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
<literal>shutdown_check_timeout</literal>: maximum number of seconds to wait for the
|
|
||||||
demotion candidate (current primary) to shut down, before aborting the switchover.
|
|
||||||
</simpara>
|
|
||||||
<simpara>
|
|
||||||
Note that this parameter is set on the node where <command>repmgr standby switchover</command>
|
|
||||||
is executed (promotion candidate); setting it on the demotion candidate (former primary) will
|
|
||||||
have no effect.
|
|
||||||
</simpara>
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
In versions prior to <link linkend="release-4.2">&repmgr; 4.2</link>, <command>repmgr standby switchover</command> would
|
|
||||||
use the values defined in <literal>reconnect_attempts</literal> and <literal>reconnect_interval</literal>
|
|
||||||
to determine the timeout for demotion candidate shutdown.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<simpara>
|
<simpara>
|
||||||
<literal>standby_reconnect_timeout</literal>:
|
<literal>standby_reconnect_timeout</literal>:
|
||||||
maximum number of seconds to attempt to wait for the demotion candidate (former primary)
|
number of seconds to attempt to wait for the demoted primary
|
||||||
to reconnect to the promoted primary (default: 60 seconds)
|
to reconnect to the promoted primary (default: 60 seconds)
|
||||||
</simpara>
|
</simpara>
|
||||||
</listitem>
|
</listitem>
|
||||||
@@ -213,7 +183,12 @@
|
|||||||
Execute with the <literal>--dry-run</literal> option to test the switchover as far as
|
Execute with the <literal>--dry-run</literal> option to test the switchover as far as
|
||||||
possible without actually changing the status of either node.
|
possible without actually changing the status of either node.
|
||||||
</para>
|
</para>
|
||||||
|
<important>
|
||||||
|
<para>
|
||||||
|
<application>repmgrd</application> must be shut down on all nodes while a switchover is being
|
||||||
|
executed. This restriction will be removed in a future &repmgr; version.
|
||||||
|
</para>
|
||||||
|
</important>
|
||||||
<para>
|
<para>
|
||||||
External database connections, e.g. from an application, should not be permitted while
|
External database connections, e.g. from an application, should not be permitted while
|
||||||
the switchover is taking place. In particular, active transactions on the primary
|
the switchover is taking place. In particular, active transactions on the primary
|
||||||
|
|||||||
@@ -23,19 +23,14 @@
|
|||||||
use of the witness server with <application>repmgrd</application>.
|
use of the witness server with <application>repmgrd</application>.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
When executing <command>repmgr witness register</command>, database connection
|
When executing <command>repmgr witness register</command>, connection information
|
||||||
information for the cluster primary server must also be provided.
|
for the cluster primary server must also be provided. &repmgr; will automatically
|
||||||
|
use the <varname>user</varname> and <varname>dbname</varname> values defined
|
||||||
|
in the <varname>conninfo</varname> string defined in the witness node's
|
||||||
|
<filename>repmgr.conf</filename>, if these are not explicitly provided.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
In most cases it's only necessary to provide the primary's hostname with
|
Execute with the <literal>--dry-run</literal> option to check what would happen
|
||||||
the <option>-h</option>/<option>--host</option> option; &repmgr; will
|
|
||||||
automatically use the <varname>user</varname> and <varname>dbname</varname>
|
|
||||||
values defined in the <varname>conninfo</varname> string defined in the
|
|
||||||
witness node's <filename>repmgr.conf</filename>, unless these are explicitly
|
|
||||||
provided as command line options.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
Execute with the <option>--dry-run</option> option to check what would happen
|
|
||||||
without actually registering the witness server.
|
without actually registering the witness server.
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<abstract>
|
<abstract>
|
||||||
<para>
|
<para>
|
||||||
This is the official documentation of &repmgr; &repmgrversion; for
|
This is the official documentation of &repmgr; &repmgrversion; for
|
||||||
use with PostgreSQL 9.3 - PostgreSQL 11.
|
use with PostgreSQL 9.3 - PostgreSQL 10.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
&repmgr; is being continually developed and we strongly recommend using the
|
&repmgr; is being continually developed and we strongly recommend using the
|
||||||
@@ -92,7 +92,6 @@
|
|||||||
&repmgrd-cascading-replication;
|
&repmgrd-cascading-replication;
|
||||||
&repmgrd-network-split;
|
&repmgrd-network-split;
|
||||||
&repmgrd-witness-server;
|
&repmgrd-witness-server;
|
||||||
&repmgrd-pausing;
|
|
||||||
&repmgrd-degraded-monitoring;
|
&repmgrd-degraded-monitoring;
|
||||||
&repmgrd-monitoring;
|
&repmgrd-monitoring;
|
||||||
&repmgrd-bdr;
|
&repmgrd-bdr;
|
||||||
@@ -114,15 +113,11 @@
|
|||||||
&repmgr-node-status;
|
&repmgr-node-status;
|
||||||
&repmgr-node-check;
|
&repmgr-node-check;
|
||||||
&repmgr-node-rejoin;
|
&repmgr-node-rejoin;
|
||||||
&repmgr-node-service;
|
|
||||||
&repmgr-cluster-show;
|
&repmgr-cluster-show;
|
||||||
&repmgr-cluster-matrix;
|
&repmgr-cluster-matrix;
|
||||||
&repmgr-cluster-crosscheck;
|
&repmgr-cluster-crosscheck;
|
||||||
&repmgr-cluster-event;
|
&repmgr-cluster-event;
|
||||||
&repmgr-cluster-cleanup;
|
&repmgr-cluster-cleanup;
|
||||||
&repmgr-daemon-status;
|
|
||||||
&repmgr-daemon-pause;
|
|
||||||
&repmgr-daemon-unpause;
|
|
||||||
</part>
|
</part>
|
||||||
|
|
||||||
&appendix-release-notes;
|
&appendix-release-notes;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<title>BDR failover with repmgrd</title>
|
<title>BDR failover with repmgrd</title>
|
||||||
<para>
|
<para>
|
||||||
&repmgr; 4.x provides support for monitoring a pair of BDR 2.x nodes and taking action in
|
&repmgr; 4.x provides support for monitoring BDR nodes and taking action in
|
||||||
case one of the nodes fails.
|
case one of the nodes fails.
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
@@ -31,21 +31,8 @@
|
|||||||
reconfigure a proxy server/connection pooler such as <application>PgBouncer</application>.
|
reconfigure a proxy server/connection pooler such as <application>PgBouncer</application>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<note>
|
|
||||||
<simpara>
|
|
||||||
This &repmgr; functionality is for BDR 2.x only running on PostgreSQL 9.4/9.6.
|
|
||||||
It is <emphasis>not</emphasis> required for later BDR versions.
|
|
||||||
</simpara>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
<sect1 id="bdr-prerequisites" xreflabel="BDR prequisites">
|
<sect1 id="bdr-prerequisites" xreflabel="BDR prequisites">
|
||||||
<title>Prerequisites</title>
|
<title>Prerequisites</title>
|
||||||
<important>
|
|
||||||
<para>
|
|
||||||
This &repmgr; functionality is for BDR 2.x only running on PostgreSQL 9.4/9.6.
|
|
||||||
It is <emphasis>not</emphasis> required for later BDR versions.
|
|
||||||
</para>
|
|
||||||
</important>
|
|
||||||
<para>
|
<para>
|
||||||
&repmgr; 4 requires PostgreSQL 9.4 or 9.6 with the BDR 2 extension
|
&repmgr; 4 requires PostgreSQL 9.4 or 9.6 with the BDR 2 extension
|
||||||
enabled and configured for a two-node BDR network. &repmgr; 4 packages
|
enabled and configured for a two-node BDR network. &repmgr; 4 packages
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ REPMGRD_ENABLED=no
|
|||||||
#REPMGRD_CONF="/path/to/repmgr.conf"
|
#REPMGRD_CONF="/path/to/repmgr.conf"
|
||||||
|
|
||||||
# additional options
|
# additional options
|
||||||
REPMGRD_OPTS="--daemonize=false"
|
#REPMGRD_OPTS=""
|
||||||
|
|
||||||
# user to run repmgrd as
|
# user to run repmgrd as
|
||||||
#REPMGRD_USER=postgres
|
#REPMGRD_USER=postgres
|
||||||
@@ -469,16 +469,6 @@ REPMGRD_OPTS="--daemonize=false"
|
|||||||
Set <varname>REPMGRD_ENABLED</varname> to <literal>yes</literal>, and <varname>REPMGRD_CONF</varname>
|
Set <varname>REPMGRD_ENABLED</varname> to <literal>yes</literal>, and <varname>REPMGRD_CONF</varname>
|
||||||
to the <filename>repmgr.conf</filename> file you are using.
|
to the <filename>repmgr.conf</filename> file you are using.
|
||||||
</para>
|
</para>
|
||||||
<tip>
|
|
||||||
<para>
|
|
||||||
See <xref linkend="packages-debian-ubuntu"> for details of the Debian/Ubuntu packages and
|
|
||||||
typical file locations (including <filename>repmgr.conf</filename>).
|
|
||||||
</para>
|
|
||||||
</tip>
|
|
||||||
<para>
|
|
||||||
From <application>repmgrd</application> 4.1, ensure <varname>REPMGRD_OPTS</varname> includes
|
|
||||||
<option>--daemonize=false</option>, as daemonization is handled by the service command.
|
|
||||||
</para>
|
|
||||||
<para>
|
<para>
|
||||||
If using <application>systemd</application>, you may need to execute <command>systemctl daemon-reload</command>.
|
If using <application>systemd</application>, you may need to execute <command>systemctl daemon-reload</command>.
|
||||||
Also, if you attempted to start <application>repmgrd</application> using <command>systemctl start repmgrd</command>,
|
Also, if you attempted to start <application>repmgrd</application> using <command>systemctl start repmgrd</command>,
|
||||||
|
|||||||
@@ -1,178 +0,0 @@
|
|||||||
<chapter id="repmgrd-pausing" xreflabel="Pausing repmgrd">
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>repmgrd</primary>
|
|
||||||
<secondary>pausing</secondary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<indexterm>
|
|
||||||
<primary>pausing repmgrd</primary>
|
|
||||||
</indexterm>
|
|
||||||
|
|
||||||
<title>Pausing repmgrd</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
In normal operation, <application>repmgrd</application> monitors the state of the
|
|
||||||
PostgreSQL node it is running on, and will take appropriate action if problems
|
|
||||||
are detected, e.g. (if so configured) promote the node to primary, if the existing
|
|
||||||
primary has been determined as failed.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
However, <application>repmgrd</application> is unable to distinguish between
|
|
||||||
planned outages (such as performing a <link linkend="performing-switchover">switchover</link>
|
|
||||||
or installing PostgreSQL maintenance released), and an actual server outage. In versions prior to
|
|
||||||
&repmgr; 4.2 it was necessary to stop <application>repmgrd</application> on all nodes (or at least
|
|
||||||
on all nodes where <application>repmgrd</application> is
|
|
||||||
<link linkend="repmgrd-automatic-failover">configured for automatic failover</link>)
|
|
||||||
to prevent <application>repmgrd</application> from making unintentional changes to the
|
|
||||||
replication cluster.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
From <link linkend="release-4.2">&repmgr; 4.2</link>, <application>repmgrd</application>
|
|
||||||
can now be "paused", i.e. instructed not to take any action such as performing a failover.
|
|
||||||
This can be done from any node in the cluster, removing the need to stop/restart
|
|
||||||
each <application>repmgrd</application> individually.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
For major PostgreSQL upgrades, e.g. from PostgreSQL 10 to PostgreSQL 11,
|
|
||||||
<application>repmgrd</application> should be shut down completely and only started up
|
|
||||||
once the &repmgr; packages for the new PostgreSQL major version have been installed.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
<sect1 id="repmgrd-pausing-prerequisites">
|
|
||||||
<title>Prerequisites for pausing <application>repmgrd</application></title>
|
|
||||||
<para>
|
|
||||||
In order to be able to pause/unpause <application>repmgrd</application>, following
|
|
||||||
prerequisites must be met:
|
|
||||||
<itemizedlist spacing="compact" mark="bullet">
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara><link linkend="release-4.2">&repmgr; 4.2</link> or later must be installed on all nodes.</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>The same major &repmgr; version (e.g. 4.2) must be installed on all nodes (and preferably the same minor version).</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
PostgreSQL on all nodes must be accessible from the node where the
|
|
||||||
<literal>pause</literal>/<literal>unpause</literal> operation is executed, using the
|
|
||||||
<varname>conninfo</varname> string shown by <link linkend="repmgr-cluster-show"><command>repmgr cluster show</command></link>.
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
These conditions are required for normal &repmgr; operation in any case.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
</sect1>
|
|
||||||
|
|
||||||
<sect1 id="repmgrd-pausing-execution">
|
|
||||||
<title>Pausing/unpausing <application>repmgrd</application></title>
|
|
||||||
<para>
|
|
||||||
To pause <application>repmgrd</application>, execute <link linkend="repmgr-daemon-pause"><command>repmgr daemon pause</command></link>, e.g.:
|
|
||||||
<programlisting>
|
|
||||||
$ repmgr -f /etc/repmgr.conf daemon pause
|
|
||||||
NOTICE: node 1 (node1) paused
|
|
||||||
NOTICE: node 2 (node2) paused
|
|
||||||
NOTICE: node 3 (node3) paused</programlisting>
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
The state of <application>repmgrd</application> on each node can be checked with
|
|
||||||
<link linkend="repmgr-daemon-status"><command>repmgr daemon status</command></link>, e.g.:
|
|
||||||
<programlisting>$ repmgr -f /etc/repmgr.conf daemon status
|
|
||||||
ID | Name | Role | Status | repmgrd | PID | Paused?
|
|
||||||
----+-------+---------+---------+---------+------+---------
|
|
||||||
1 | node1 | primary | running | running | 7851 | yes
|
|
||||||
2 | node2 | standby | running | running | 7889 | yes
|
|
||||||
3 | node3 | standby | running | running | 7918 | yes</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
If executing a switchover with <link linkend="repmgr-standby-switchover"><command>repmgr standby switchover</command></link>,
|
|
||||||
&repmgr; will automatically pause/unpause <application>repmgrd</application> as part of the switchover process.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
If the primary (in this example, <literal>node1</literal>) is stopped, <application>repmgrd</application>
|
|
||||||
running on one of the standbys (here: <literal>node2</literal>) will react like this:
|
|
||||||
<programlisting>
|
|
||||||
[2018-09-20 12:22:21] [WARNING] unable to connect to upstream node "node1" (node ID: 1)
|
|
||||||
[2018-09-20 12:22:21] [INFO] checking state of node 1, 1 of 5 attempts
|
|
||||||
[2018-09-20 12:22:21] [INFO] sleeping 1 seconds until next reconnection attempt
|
|
||||||
...
|
|
||||||
[2018-09-20 12:22:24] [INFO] sleeping 1 seconds until next reconnection attempt
|
|
||||||
[2018-09-20 12:22:25] [INFO] checking state of node 1, 5 of 5 attempts
|
|
||||||
[2018-09-20 12:22:25] [WARNING] unable to reconnect to node 1 after 5 attempts
|
|
||||||
[2018-09-20 12:22:25] [NOTICE] node is paused
|
|
||||||
[2018-09-20 12:22:33] [INFO] node "node2" (node ID: 2) monitoring upstream node "node1" (node ID: 1) in degraded state
|
|
||||||
[2018-09-20 12:22:33] [DETAIL] repmgrd paused by administrator
|
|
||||||
[2018-09-20 12:22:33] [HINT] execute "repmgr daemon unpause" to resume normal failover mode</programlisting>
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
If the primary becomes available again (e.g. following a software upgrade), <application>repmgrd</application>
|
|
||||||
will automatically reconnect, e.g.:
|
|
||||||
<programlisting>
|
|
||||||
[2018-09-20 13:12:41] [NOTICE] reconnected to upstream node 1 after 8 seconds, resuming monitoring</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
To unpause <application>repmgrd</application>, execute <link linkend="repmgr-daemon-unpause"><command>repmgr daemon unpause</command></link>, e.g.:
|
|
||||||
<programlisting>
|
|
||||||
$ repmgr -f /etc/repmgr.conf daemon unpause
|
|
||||||
NOTICE: node 1 (node1) unpaused
|
|
||||||
NOTICE: node 2 (node2) unpaused
|
|
||||||
NOTICE: node 3 (node3) unpaused</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
If the previous primary is no longer accessible when <application>repmgrd</application>
|
|
||||||
is unpaused, no failover action will be taken. Instead, a new primary must be manually promoted using
|
|
||||||
<link linkend="repmgr-standby-promote"><command>repmgr standby promote</command></link>,
|
|
||||||
and any standbys attached to the new primary with
|
|
||||||
<link linkend="repmgr-standby-follow"><command>repmgr standby follow</command></link>.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
This is to prevent <link linkend="repmgr-daemon-unpause"><command>repmgr daemon unpause</command></link>
|
|
||||||
resulting in the automatic promotion of a new primary, which may be a problem particularly
|
|
||||||
in larger clusters, where <application>repmgrd</application> could select a different promotion
|
|
||||||
candidate to the one intended by the administrator.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
<sect2 id="repmgrd-pausing-details">
|
|
||||||
<title>Details on the <application>repmgrd</application> pausing mechanism</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The pause state of each node will be stored over a PostgreSQL restart.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
<link linkend="repmgr-daemon-pause"><command>repmgr daemon pause</command></link> and
|
|
||||||
<link linkend="repmgr-daemon-unpause"><command>repmgr daemon unpause</command></link> can be
|
|
||||||
executed even if <application>repmgrd</application> is not running; in this case,
|
|
||||||
<application>repmgrd</application> will start up in whichever pause state has been set.
|
|
||||||
</para>
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
<link linkend="repmgr-daemon-pause"><command>repmgr daemon pause</command></link> and
|
|
||||||
<link linkend="repmgr-daemon-unpause"><command>repmgr daemon unpause</command></link>
|
|
||||||
<emphasis>do not</emphasis> stop/start <application>repmgrd</application>.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
</sect2>
|
|
||||||
</sect1>
|
|
||||||
</chapter>
|
|
||||||
|
|
||||||
@@ -19,10 +19,9 @@
|
|||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
<command>repmgr standby switchover</command> differs from other &repmgr;
|
<command>repmgr standby switchover</command> differs from other &repmgr;
|
||||||
actions in that it also performs actions on other servers (the demotion
|
actions in that it also performs actions on another server (the demotion
|
||||||
candidate, and optionally any other servers which are to follow the new primary),
|
candidate), which means passwordless SSH access is required to that server
|
||||||
which means passwordless SSH access is required to those servers from the one where
|
from the one where <command>repmgr standby switchover</command> is executed.
|
||||||
<command>repmgr standby switchover</command> is executed.
|
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<simpara>
|
<simpara>
|
||||||
@@ -84,12 +83,11 @@
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
Double-check which commands will be used to stop/start/restart the current
|
Double-check which commands will be used to stop/start/restart the current
|
||||||
primary; this can be done by e.g. executing <command><link linkend="repmgr-node-service">repmgr node service</link></command>
|
primary; on the current primary execute:
|
||||||
on the current primary:
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
repmgr -f /etc/repmgr.conf node service --list-actions --action=stop
|
repmgr -f /etc/repmgr.conf node service --list --action=stop
|
||||||
repmgr -f /etc/repmgr.conf node service --list-actions --action=start
|
repmgr -f /etc/repmgr.conf node service --list --action=start
|
||||||
repmgr -f /etc/repmgr.conf node service --list-actions --action=restart</programlisting>
|
repmgr -f /etc/repmgr.conf node service --list --action=restart</programlisting>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@@ -155,18 +153,12 @@
|
|||||||
manually with <command>repmgr node check --archive-ready</command>.
|
manually with <command>repmgr node check --archive-ready</command>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
From <link linkend="release-4.2">repmgr 4.2</link>, &repmgr; will instruct any running
|
Ensure that <application>repmgrd</application> is *not* running anywhere to prevent it unintentionally
|
||||||
<application>repmgrd</application> instances to pause operations while the switchover
|
promoting a node. This restriction will be removed in a future &repmgr; version.
|
||||||
is being carried out, to prevent <application>repmgrd</application> from
|
</para>
|
||||||
unintentionally promoting a node. For more details, see <xref linkend="repmgrd-pausing">.
|
</note>
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
Users of &repmgr; versions prior to 4.2 should ensure that <application>repmgrd</application>
|
|
||||||
is not running on any nodes while a switchover is being executed.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@@ -311,21 +303,7 @@
|
|||||||
2 | node2 | primary | * running | | default | host=node2 dbname=repmgr user=repmgr
|
2 | node2 | primary | * running | | default | host=node2 dbname=repmgr user=repmgr
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
<para>
|
|
||||||
If <application>repmgrd</application> is in use, it's worth double-checking that
|
|
||||||
all nodes are unpaused by executing <command><link linkend="repmgr-daemon-status">repmgr-daemon-status</link></command>.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
Users of &repmgr; versions prior to 4.2 will need to manually restart <application>repmgrd</application>
|
|
||||||
on all nodes after the switchover is completed.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
|
|
||||||
<sect1 id="switchover-caveats" xreflabel="Caveats">
|
<sect1 id="switchover-caveats" xreflabel="Caveats">
|
||||||
<indexterm>
|
<indexterm>
|
||||||
<primary>switchover</primary>
|
<primary>switchover</primary>
|
||||||
@@ -351,76 +329,17 @@
|
|||||||
for details.
|
for details.
|
||||||
</simpara>
|
</simpara>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<simpara>
|
||||||
|
<application>repmgrd</application> should not be running with setting <varname>failover=automatic</varname>
|
||||||
|
in <filename>repmgr.conf</filename> when a switchover is carried out, otherwise the
|
||||||
|
<application>repmgrd</application> daemon may try and promote a standby by itself.
|
||||||
|
</simpara>
|
||||||
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</para>
|
</para>
|
||||||
|
<para>
|
||||||
|
We hope to remove some of these restrictions in future versions of &repmgr;.
|
||||||
|
</para>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
<sect1 id="switchover-troubleshooting" xreflabel="Troubleshooting">
|
|
||||||
<indexterm>
|
|
||||||
<primary>switchover</primary>
|
|
||||||
<secondary>troubleshooting</secondary>
|
|
||||||
</indexterm>
|
|
||||||
<title>Troubleshooting switchover issues</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
As <link linkend="performing-switchover">emphasised previously</link>, performing a switchover
|
|
||||||
is a non-trivial operation and there are a number of potential issues which can occur.
|
|
||||||
While &repmgr; attempts to perform sanity checks, there's no guaranteed way of determining the success of
|
|
||||||
a switchover without actually carrying it out.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<sect2 id="switchover-troubleshooting-primary-shutdown">
|
|
||||||
<title>Demotion candidate (old primary) does not shut down</title>
|
|
||||||
<para>
|
|
||||||
&repmgr; may abort a switchover with a message like:
|
|
||||||
<programlisting>
|
|
||||||
ERROR: shutdown of the primary server could not be confirmed
|
|
||||||
HINT: check the primary server status before performing any further actions</programlisting>
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
This means the shutdown of the old primary has taken longer than &repmgr; expected,
|
|
||||||
and it has given up waiting.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
In this case, check the PostgreSQL log on the primary server to see what is going
|
|
||||||
on. It's entirely possible the shutdown process is just taking longer than the
|
|
||||||
timeout set by the configuration parameter <varname>shutdown_check_timeout</varname>
|
|
||||||
(default: 60 seconds), in which case you may need to adjust this parameter.
|
|
||||||
</para>
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
Note that <varname>shutdown_check_timeout</varname> is set on the node where
|
|
||||||
<command>repmgr standby switchover</command> is executed (promotion candidate); setting it on the
|
|
||||||
demotion candidate (former primary) will have no effect.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
<para>
|
|
||||||
If the primary server has shut down cleanly, and no other node has been promoted,
|
|
||||||
it is safe to restart it, in which case the replication cluster will be restored
|
|
||||||
to its original configuration.
|
|
||||||
</para>
|
|
||||||
</sect2>
|
|
||||||
|
|
||||||
<sect2 id="switchover-troubleshooting-exclusive-backup">
|
|
||||||
<title>Switchover aborts with an "exclusive backup" error</title>
|
|
||||||
<para>
|
|
||||||
&repmgr; may abort a switchover with a message like:
|
|
||||||
<programlisting>
|
|
||||||
ERROR: unable to perform a switchover while primary server is in exclusive backup mode
|
|
||||||
HINT: stop backup before attempting the switchover</programlisting>
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
This means an exclusive backup is running on the current primary; interrupting this
|
|
||||||
will not only abort the backup, but potentially leave the primary with an ambiguous
|
|
||||||
backup state.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
To proceed, either wait until the backup has finished, or cancel it with the command
|
|
||||||
<command>SELECT pg_stop_backup()</command>. For more details see the PostgreSQL
|
|
||||||
documentation section
|
|
||||||
<ulink url="https://www.postgresql.org/docs/current/static/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP-EXCLUSIVE">Making an exclusive low level backup</ulink>.
|
|
||||||
</para>
|
|
||||||
</sect2>
|
|
||||||
</sect1>
|
|
||||||
|
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ Upgrading from repmgr 3
|
|||||||
This document has been integrated into the main `repmgr` documentation
|
This document has been integrated into the main `repmgr` documentation
|
||||||
and is now located here:
|
and is now located here:
|
||||||
|
|
||||||
> [Upgrading from repmgr 3.x](https://repmgr.org/docs/current/upgrading-from-repmgr-3.html)
|
> [Upgrading from repmgr 3.x](https://repmgr.org/docs/4.0/upgrading-from-repmgr-3.html)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
<title>Upgrading repmgr</title>
|
<title>Upgrading repmgr</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
&repmgr; is updated regularly with minor releases (e.g. 4.0.1 to 4.0.2)
|
&repmgr; is updated regularly with point releases (e.g. 4.0.1 to 4.0.2)
|
||||||
containing bugfixes and other minor improvements. Any substantial new
|
containing bugfixes and other minor improvements. Any substantial new
|
||||||
functionality will be included in a major release (e.g. 4.0 to 4.1).
|
functionality will be included in a feature release (e.g. 4.0.x to 4.1.x).
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<sect1 id="upgrading-repmgr-extension" xreflabel="Upgrading repmgr 4.x and later">
|
<sect1 id="upgrading-repmgr-extension" xreflabel="Upgrading repmgr 4.x and later">
|
||||||
@@ -19,202 +19,43 @@
|
|||||||
</indexterm>
|
</indexterm>
|
||||||
<title>Upgrading repmgr 4.x and later</title>
|
<title>Upgrading repmgr 4.x and later</title>
|
||||||
<para>
|
<para>
|
||||||
From version 4, &repmgr; consists of three elements:
|
&repmgr; 4.x is implemented as a PostgreSQL extension; normally the upgrade consists
|
||||||
<itemizedlist spacing="compact" mark="bullet">
|
of the two following steps:
|
||||||
|
<orderedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<simpara>
|
<simpara>
|
||||||
the <application>repmgr</application> and <application>repmgrd</application> executables
|
Install the updated package (or compile the updated source)
|
||||||
</simpara>
|
</simpara>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
<listitem>
|
<simpara>
|
||||||
<simpara>
|
<application>repmgrd</application> (if running) must be restarted.
|
||||||
the objects for the &repmgr; PostgreSQL extension (SQL files for creating/updating
|
</simpara>
|
||||||
repmgr metadata, and the extension control file)
|
</listitem>
|
||||||
</simpara>
|
<listitem>
|
||||||
</listitem>
|
<simpara>
|
||||||
|
For major releases, e.g. from <literal>4.0.x</literal> to <literal>4.1</literal>,
|
||||||
<listitem>
|
execute <command>ALTER EXTENSION repmgr UPDATE</command>
|
||||||
<simpara>
|
on the primary node in the database where the &repmgr; extension is installed.
|
||||||
the shared library module used by <application>repmgrd</application> which
|
</simpara>
|
||||||
is resident in the PostgreSQL backend
|
<simpara>
|
||||||
</simpara>
|
This will update the extension metadata and, if necessary, apply
|
||||||
</listitem>
|
changes to the &repmgr; extension objects.
|
||||||
</itemizedlist>
|
</simpara>
|
||||||
</para>
|
</listitem>
|
||||||
<para>
|
</orderedlist>
|
||||||
With <emphasis>minor releases</emphasis>, usually changes are only made to the <application>repmgr</application>
|
|
||||||
and <application>repmgrd</application> executables. In this case, the upgrade is quite straightforward,
|
|
||||||
and is simply a case of installing the new version, and restarting <application>repmgrd</application>
|
|
||||||
(if running).
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
For <emphasis>major releases</emphasis>, the &repmgr; PostgreSQL extension will need to be updated
|
Always check the <link linkend="appendix-release-notes">release notes</link> for every
|
||||||
to the latest version. Additionally, if the shared library module has been updated (this is sometimes,
|
release as they may contain upgrade instructions particular to individual versions.
|
||||||
but not always the case), PostgreSQL itself will need to be restarted on each node.
|
|
||||||
</para>
|
</para>
|
||||||
<important>
|
|
||||||
<para>
|
|
||||||
Always check the <link linkend="appendix-release-notes">release notes</link> for every
|
|
||||||
release as they may contain upgrade instructions particular to individual versions.
|
|
||||||
</para>
|
|
||||||
</important>
|
|
||||||
|
|
||||||
<sect2 id="upgrading-minor-version" xreflabel="Upgrading a minor version release">
|
<para>
|
||||||
<indexterm>
|
Note that it may be necessary to restart the PostgreSQL server if the upgrade contains
|
||||||
<primary>upgrading</primary>
|
changes to the shared object file used by <application>repmgrd</application>; check the
|
||||||
<secondary>minor release</secondary>
|
release notes for details.
|
||||||
</indexterm>
|
</para>
|
||||||
<title>Upgrading a minor version release</title>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
The process for installing minor version upgrades is quite straightforward:
|
|
||||||
|
|
||||||
<itemizedlist spacing="compact" mark="bullet">
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
install the new &repmgr; version
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
restart <application>repmgrd</application> on all nodes where it is running
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
</itemizedlist>
|
|
||||||
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
Some packaging systems (e.g. <link linkend="packages-debian-ubuntu">Debian/Ubuntu</link>
|
|
||||||
may restart <application>repmgrd</application> as part of the package upgrade process.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
Minor version upgrades can be performed in any order on the nodes in the replication
|
|
||||||
cluster.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
A PostgreSQL restart is <emphasis>not</emphasis> required for minor version upgrades.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<note>
|
|
||||||
<para>
|
|
||||||
The same &repmgr; "major version" (e.g. <literal>4.2</literal>) must be
|
|
||||||
installed on all nodes in the replication cluster. While it's possible to have differing
|
|
||||||
&repmgr; "minor versions" (e.g. <literal>4.2.1</literal>) on different nodes,
|
|
||||||
we strongly recommend updating all nodes to the latest minor version.
|
|
||||||
</para>
|
|
||||||
</note>
|
|
||||||
|
|
||||||
</sect2>
|
|
||||||
|
|
||||||
<sect2 id="upgrading-major-version" xreflabel="Upgrading a major version release">
|
|
||||||
<indexterm>
|
|
||||||
<primary>upgrading</primary>
|
|
||||||
<secondary>major release</secondary>
|
|
||||||
</indexterm>
|
|
||||||
<title>Upgrading a major version release</title>
|
|
||||||
<para>
|
|
||||||
"major version" upgrades need to be planned more carefully, as they may include
|
|
||||||
changes to the &repmgr; metadata (which need to be propagated from the primary to all
|
|
||||||
standbys) and/or changes to the shared object file used by <application>repmgrd</application>
|
|
||||||
(which require a PostgreSQL restart).
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
With this in mind,
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
<orderedlist>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
Stop <application>repmgrd</application> (if in use) on all nodes where it is running.
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
Disable the <application>repmgrd</application> service on all nodes where it is in use;
|
|
||||||
this is to prevent packages from prematurely restarting <application>repmgrd</application>.
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
Install the updated package (or compile the updated source) on all nodes.
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
If running a <literal>systemd</literal>-based Linux distribution, execute (as <literal>root</literal>,
|
|
||||||
or with appropriate <literal>sudo</literal> permissions):
|
|
||||||
<programlisting>
|
|
||||||
systemctl daemon-reload</programlisting>
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
If the &repmgr; shared library module has been updated (check the <link linkend="appendix-release-notes">release notes</link>!),
|
|
||||||
restart PostgreSQL, then <application>repmgrd</application> (if in use) on each node,
|
|
||||||
The order in which this is applied to individual nodes is not critical,
|
|
||||||
and it's also fine to restart PostgreSQL on all nodes first before starting <application>repmgrd</application>.
|
|
||||||
</simpara>
|
|
||||||
<simpara>
|
|
||||||
Note that if the upgrade requires a PostgreSQL restart, <application>repmgrd</application>
|
|
||||||
will only function correctly once all nodes have been restarted.
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
On the primary node, execute
|
|
||||||
<programlisting>
|
|
||||||
ALTER EXTENSION repmgr UPDATE</programlisting>
|
|
||||||
in the database where &repmgr; is installed.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
<simpara>
|
|
||||||
Reenable the <application>repmgrd</application> service on all nodes where it is in use, and
|
|
||||||
ensure it is running.
|
|
||||||
</simpara>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
</orderedlist>
|
|
||||||
</para>
|
|
||||||
<tip>
|
|
||||||
<para>
|
|
||||||
If the &repmgr; upgrade requires a PostgreSQL restart, combine the &repmgr; upgrade
|
|
||||||
with a PostgreSQL minor version upgrade, which will require a restart in any case.
|
|
||||||
New PostgreSQL minor version are usually released every couple of months.
|
|
||||||
</para>
|
|
||||||
</tip>
|
|
||||||
</sect2>
|
|
||||||
|
|
||||||
<sect2 id="upgrading-check-repmgrd" xreflabel="Checking repmgrd status after an upgrade">
|
|
||||||
<indexterm>
|
|
||||||
<primary>upgrading</primary>
|
|
||||||
<secondary>checking repmgrd status</secondary>
|
|
||||||
</indexterm>
|
|
||||||
<title>Checking repmgrd status after an upgrade</title>
|
|
||||||
<para>
|
|
||||||
From <link linkend="release-4.2">repmgr 4.2</link>, once the upgrade is complete, execute the <command><link linkend="repmgr-daemon-status">repmgr daemon status</link></command>
|
|
||||||
command (on any node) to show an overview of the status of <application>repmgrd</application> on all nodes.
|
|
||||||
</para>
|
|
||||||
</sect2>
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
<sect1 id="upgrading-and-pg-upgrade" xreflabel="pg_upgrade and repmgr">
|
<sect1 id="upgrading-and-pg-upgrade" xreflabel="pg_upgrade and repmgr">
|
||||||
@@ -254,13 +95,6 @@ ALTER EXTENSION repmgr UPDATE</programlisting>
|
|||||||
be recreated by <application>pg_upgrade</application>. These will need to
|
be recreated by <application>pg_upgrade</application>. These will need to
|
||||||
be recreated manually.
|
be recreated manually.
|
||||||
</para>
|
</para>
|
||||||
<tip>
|
|
||||||
<para>
|
|
||||||
Use <command><link linkend="repmgr-node-check">repmgr node check</link></command>
|
|
||||||
to determine which replacation slots need to be recreated.
|
|
||||||
</para>
|
|
||||||
</tip>
|
|
||||||
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<!ENTITY repmgrversion "4.2">
|
<!ENTITY repmgrversion "4.1.1">
|
||||||
|
|||||||
@@ -47,6 +47,5 @@
|
|||||||
#define ERR_FOLLOW_FAIL 23
|
#define ERR_FOLLOW_FAIL 23
|
||||||
#define ERR_REJOIN_FAIL 24
|
#define ERR_REJOIN_FAIL 24
|
||||||
#define ERR_NODE_STATUS 25
|
#define ERR_NODE_STATUS 25
|
||||||
#define ERR_REPMGRD_PAUSE 26
|
|
||||||
|
|
||||||
#endif /* _ERRCODE_H_ */
|
#endif /* _ERRCODE_H_ */
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
|
||||||
\echo Use "CREATE EXTENSION repmgr" to load this file. \quit
|
|
||||||
|
|
||||||
CREATE FUNCTION get_repmgrd_pid()
|
|
||||||
RETURNS INT
|
|
||||||
AS 'MODULE_PATHNAME', 'get_repmgrd_pid'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION get_repmgrd_pidfile()
|
|
||||||
RETURNS TEXT
|
|
||||||
AS 'MODULE_PATHNAME', 'get_repmgrd_pidfile'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION set_repmgrd_pid(INT, TEXT)
|
|
||||||
RETURNS VOID
|
|
||||||
AS 'MODULE_PATHNAME', 'set_repmgrd_pid'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION repmgrd_is_running()
|
|
||||||
RETURNS BOOL
|
|
||||||
AS 'MODULE_PATHNAME', 'repmgrd_is_running'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION repmgrd_pause(BOOL)
|
|
||||||
RETURNS VOID
|
|
||||||
AS 'MODULE_PATHNAME', 'repmgrd_pause'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION repmgrd_is_paused()
|
|
||||||
RETURNS BOOL
|
|
||||||
AS 'MODULE_PATHNAME', 'repmgrd_is_paused'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
@@ -145,6 +145,7 @@ CREATE FUNCTION unset_bdr_failover_handler()
|
|||||||
AS 'MODULE_PATHNAME', 'unset_bdr_failover_handler'
|
AS 'MODULE_PATHNAME', 'unset_bdr_failover_handler'
|
||||||
LANGUAGE C STRICT;
|
LANGUAGE C STRICT;
|
||||||
|
|
||||||
|
|
||||||
CREATE VIEW repmgr.replication_status AS
|
CREATE VIEW repmgr.replication_status AS
|
||||||
SELECT m.primary_node_id, m.standby_node_id, n.node_name AS standby_name,
|
SELECT m.primary_node_id, m.standby_node_id, n.node_name AS standby_name,
|
||||||
n.type AS node_type, n.active, last_monitor_time,
|
n.type AS node_type, n.active, last_monitor_time,
|
||||||
|
|||||||
197
repmgr--4.2.sql
197
repmgr--4.2.sql
@@ -1,197 +0,0 @@
|
|||||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
|
||||||
\echo Use "CREATE EXTENSION repmgr" to load this file. \quit
|
|
||||||
|
|
||||||
CREATE TABLE repmgr.nodes (
|
|
||||||
node_id INTEGER PRIMARY KEY,
|
|
||||||
upstream_node_id INTEGER NULL REFERENCES nodes (node_id) DEFERRABLE,
|
|
||||||
active BOOLEAN NOT NULL DEFAULT TRUE,
|
|
||||||
node_name TEXT NOT NULL,
|
|
||||||
type TEXT NOT NULL CHECK (type IN('primary','standby','witness','bdr')),
|
|
||||||
location TEXT NOT NULL DEFAULT 'default',
|
|
||||||
priority INT NOT NULL DEFAULT 100,
|
|
||||||
conninfo TEXT NOT NULL,
|
|
||||||
repluser VARCHAR(63) NOT NULL,
|
|
||||||
slot_name TEXT NULL,
|
|
||||||
config_file TEXT NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE repmgr.events (
|
|
||||||
node_id INTEGER NOT NULL,
|
|
||||||
event TEXT NOT NULL,
|
|
||||||
successful BOOLEAN NOT NULL DEFAULT TRUE,
|
|
||||||
event_timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
details TEXT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
DO $repmgr$
|
|
||||||
DECLARE
|
|
||||||
DECLARE server_version_num INT;
|
|
||||||
BEGIN
|
|
||||||
SELECT setting
|
|
||||||
FROM pg_catalog.pg_settings
|
|
||||||
WHERE name = 'server_version_num'
|
|
||||||
INTO server_version_num;
|
|
||||||
IF server_version_num >= 90400 THEN
|
|
||||||
EXECUTE $repmgr_func$
|
|
||||||
CREATE TABLE repmgr.monitoring_history (
|
|
||||||
primary_node_id INTEGER NOT NULL,
|
|
||||||
standby_node_id INTEGER NOT NULL,
|
|
||||||
last_monitor_time TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
||||||
last_apply_time TIMESTAMP WITH TIME ZONE,
|
|
||||||
last_wal_primary_location PG_LSN NOT NULL,
|
|
||||||
last_wal_standby_location PG_LSN,
|
|
||||||
replication_lag BIGINT NOT NULL,
|
|
||||||
apply_lag BIGINT NOT NULL
|
|
||||||
)
|
|
||||||
$repmgr_func$;
|
|
||||||
ELSE
|
|
||||||
EXECUTE $repmgr_func$
|
|
||||||
CREATE TABLE repmgr.monitoring_history (
|
|
||||||
primary_node_id INTEGER NOT NULL,
|
|
||||||
standby_node_id INTEGER NOT NULL,
|
|
||||||
last_monitor_time TIMESTAMP WITH TIME ZONE NOT NULL,
|
|
||||||
last_apply_time TIMESTAMP WITH TIME ZONE,
|
|
||||||
last_wal_primary_location TEXT NOT NULL,
|
|
||||||
last_wal_standby_location TEXT,
|
|
||||||
replication_lag BIGINT NOT NULL,
|
|
||||||
apply_lag BIGINT NOT NULL
|
|
||||||
)
|
|
||||||
$repmgr_func$;
|
|
||||||
END IF;
|
|
||||||
END$repmgr$;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX idx_monitoring_history_time
|
|
||||||
ON repmgr.monitoring_history (last_monitor_time, standby_node_id);
|
|
||||||
|
|
||||||
CREATE VIEW repmgr.show_nodes AS
|
|
||||||
SELECT n.node_id,
|
|
||||||
n.node_name,
|
|
||||||
n.active,
|
|
||||||
n.upstream_node_id,
|
|
||||||
un.node_name AS upstream_node_name,
|
|
||||||
n.type,
|
|
||||||
n.priority,
|
|
||||||
n.conninfo
|
|
||||||
FROM repmgr.nodes n
|
|
||||||
LEFT JOIN repmgr.nodes un
|
|
||||||
ON un.node_id = n.upstream_node_id;
|
|
||||||
|
|
||||||
|
|
||||||
/* XXX update upgrade scripts! */
|
|
||||||
CREATE TABLE repmgr.voting_term (
|
|
||||||
term INT NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE UNIQUE INDEX voting_term_restrict
|
|
||||||
ON repmgr.voting_term ((TRUE));
|
|
||||||
|
|
||||||
CREATE RULE voting_term_delete AS
|
|
||||||
ON DELETE TO repmgr.voting_term
|
|
||||||
DO INSTEAD NOTHING;
|
|
||||||
|
|
||||||
|
|
||||||
/* ================= */
|
|
||||||
/* repmgrd functions */
|
|
||||||
/* ================= */
|
|
||||||
|
|
||||||
/* monitoring functions */
|
|
||||||
|
|
||||||
CREATE FUNCTION set_local_node_id(INT)
|
|
||||||
RETURNS VOID
|
|
||||||
AS 'MODULE_PATHNAME', 'set_local_node_id'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION get_local_node_id()
|
|
||||||
RETURNS INT
|
|
||||||
AS 'MODULE_PATHNAME', 'get_local_node_id'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION standby_set_last_updated()
|
|
||||||
RETURNS TIMESTAMP WITH TIME ZONE
|
|
||||||
AS 'MODULE_PATHNAME', 'standby_set_last_updated'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION standby_get_last_updated()
|
|
||||||
RETURNS TIMESTAMP WITH TIME ZONE
|
|
||||||
AS 'MODULE_PATHNAME', 'standby_get_last_updated'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
/* failover functions */
|
|
||||||
|
|
||||||
CREATE FUNCTION notify_follow_primary(INT)
|
|
||||||
RETURNS VOID
|
|
||||||
AS 'MODULE_PATHNAME', 'notify_follow_primary'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION get_new_primary()
|
|
||||||
RETURNS INT
|
|
||||||
AS 'MODULE_PATHNAME', 'get_new_primary'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION reset_voting_status()
|
|
||||||
RETURNS VOID
|
|
||||||
AS 'MODULE_PATHNAME', 'reset_voting_status'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION am_bdr_failover_handler(INT)
|
|
||||||
RETURNS BOOL
|
|
||||||
AS 'MODULE_PATHNAME', 'am_bdr_failover_handler'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION unset_bdr_failover_handler()
|
|
||||||
RETURNS VOID
|
|
||||||
AS 'MODULE_PATHNAME', 'unset_bdr_failover_handler'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION get_repmgrd_pid()
|
|
||||||
RETURNS INT
|
|
||||||
AS 'MODULE_PATHNAME', 'get_repmgrd_pid'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION get_repmgrd_pidfile()
|
|
||||||
RETURNS TEXT
|
|
||||||
AS 'MODULE_PATHNAME', 'get_repmgrd_pidfile'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION set_repmgrd_pid(INT, TEXT)
|
|
||||||
RETURNS VOID
|
|
||||||
AS 'MODULE_PATHNAME', 'set_repmgrd_pid'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION repmgrd_is_running()
|
|
||||||
RETURNS BOOL
|
|
||||||
AS 'MODULE_PATHNAME', 'repmgrd_is_running'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION repmgrd_pause(BOOL)
|
|
||||||
RETURNS VOID
|
|
||||||
AS 'MODULE_PATHNAME', 'repmgrd_pause'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION repmgrd_is_paused()
|
|
||||||
RETURNS BOOL
|
|
||||||
AS 'MODULE_PATHNAME', 'repmgrd_is_paused'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
|
|
||||||
CREATE VIEW repmgr.replication_status AS
|
|
||||||
SELECT m.primary_node_id, m.standby_node_id, n.node_name AS standby_name,
|
|
||||||
n.type AS node_type, n.active, last_monitor_time,
|
|
||||||
CASE WHEN n.type='standby' THEN m.last_wal_primary_location ELSE NULL END AS last_wal_primary_location,
|
|
||||||
m.last_wal_standby_location,
|
|
||||||
CASE WHEN n.type='standby' THEN pg_catalog.pg_size_pretty(m.replication_lag) ELSE NULL END AS replication_lag,
|
|
||||||
CASE WHEN n.type='standby' THEN
|
|
||||||
CASE WHEN replication_lag > 0 THEN age(now(), m.last_apply_time) ELSE '0'::INTERVAL END
|
|
||||||
ELSE NULL
|
|
||||||
END AS replication_time_lag,
|
|
||||||
CASE WHEN n.type='standby' THEN pg_catalog.pg_size_pretty(m.apply_lag) ELSE NULL END AS apply_lag,
|
|
||||||
AGE(NOW(), CASE WHEN pg_catalog.pg_is_in_recovery() THEN repmgr.standby_get_last_updated() ELSE m.last_monitor_time END) AS communication_time_lag
|
|
||||||
FROM repmgr.monitoring_history m
|
|
||||||
JOIN repmgr.nodes n ON m.standby_node_id = n.node_id
|
|
||||||
WHERE (m.standby_node_id, m.last_monitor_time) IN (
|
|
||||||
SELECT m1.standby_node_id, MAX(m1.last_monitor_time)
|
|
||||||
FROM repmgr.monitoring_history m1 GROUP BY 1
|
|
||||||
);
|
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ do_bdr_register(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check whether repmgr extension exists, and there are no non-BDR nodes registered */
|
/* check whether repmgr extension exists, and there are no non-BDR nodes registered */
|
||||||
extension_status = get_repmgr_extension_status(conn, NULL);
|
extension_status = get_repmgr_extension_status(conn);
|
||||||
|
|
||||||
if (extension_status == REPMGR_UNKNOWN)
|
if (extension_status == REPMGR_UNKNOWN)
|
||||||
{
|
{
|
||||||
@@ -191,7 +191,7 @@ do_bdr_register(void)
|
|||||||
{
|
{
|
||||||
NodeInfoList local_node_records = T_NODE_INFO_LIST_INITIALIZER;
|
NodeInfoList local_node_records = T_NODE_INFO_LIST_INITIALIZER;
|
||||||
|
|
||||||
(void) get_all_node_records(conn, &local_node_records);
|
get_all_node_records(conn, &local_node_records);
|
||||||
|
|
||||||
if (local_node_records.node_count == 0)
|
if (local_node_records.node_count == 0)
|
||||||
{
|
{
|
||||||
@@ -232,14 +232,14 @@ do_bdr_register(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check repmgr schema exists, skip if not */
|
/* check repmgr schema exists, skip if not */
|
||||||
other_node_extension_status = get_repmgr_extension_status(bdr_node_conn, NULL);
|
other_node_extension_status = get_repmgr_extension_status(bdr_node_conn);
|
||||||
|
|
||||||
if (other_node_extension_status != REPMGR_INSTALLED)
|
if (other_node_extension_status != REPMGR_INSTALLED)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) get_all_node_records(bdr_node_conn, &existing_nodes);
|
get_all_node_records(bdr_node_conn, &existing_nodes);
|
||||||
|
|
||||||
for (cell = existing_nodes.head; cell; cell = cell->next)
|
for (cell = existing_nodes.head; cell; cell = cell->next)
|
||||||
{
|
{
|
||||||
@@ -442,7 +442,7 @@ do_bdr_unregister(void)
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
extension_status = get_repmgr_extension_status(conn, NULL);
|
extension_status = get_repmgr_extension_status(conn);
|
||||||
if (extension_status != REPMGR_INSTALLED)
|
if (extension_status != REPMGR_INSTALLED)
|
||||||
{
|
{
|
||||||
log_error(_("repmgr is not installed on database \"%s\""), dbname);
|
log_error(_("repmgr is not installed on database \"%s\""), dbname);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#define SHOW_HEADER_COUNT 7
|
#define SHOW_HEADER_COUNT 7
|
||||||
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
SHOW_ID = 0,
|
SHOW_ID = 0,
|
||||||
@@ -50,13 +51,21 @@ typedef enum
|
|||||||
} EventHeader;
|
} EventHeader;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct ColHeader
|
||||||
|
{
|
||||||
|
char title[MAXLEN];
|
||||||
|
int max_length;
|
||||||
|
int cur_length;
|
||||||
|
};
|
||||||
|
|
||||||
struct ColHeader headers_show[SHOW_HEADER_COUNT];
|
struct ColHeader headers_show[SHOW_HEADER_COUNT];
|
||||||
struct ColHeader headers_event[EVENT_HEADER_COUNT];
|
struct ColHeader headers_event[EVENT_HEADER_COUNT];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, ItemList *warnings, int *error_code);
|
static int build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length);
|
||||||
static int build_cluster_crosscheck(t_node_status_cube ***cube_dest, int *name_length, ItemList *warnings, int *error_code);
|
static int build_cluster_crosscheck(t_node_status_cube ***cube_dest, int *name_length);
|
||||||
static void cube_set_node_status(t_node_status_cube **cube, int n, int node_id, int matrix_node_id, int connection_node_id, int connection_status);
|
static void cube_set_node_status(t_node_status_cube **cube, int n, int node_id, int matrix_node_id, int connection_node_id, int connection_status);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -150,7 +159,7 @@ do_cluster_show(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"unable to connect to node \"%s\" (ID: %i)",
|
"unable to connect to node \"%s\" (ID: %i)",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,16 +183,16 @@ do_cluster_show(void)
|
|||||||
switch (cell->node_info->recovery_type)
|
switch (cell->node_info->recovery_type)
|
||||||
{
|
{
|
||||||
case RECTYPE_PRIMARY:
|
case RECTYPE_PRIMARY:
|
||||||
appendPQExpBufferStr(&details, "* running");
|
appendPQExpBuffer(&details, "* running");
|
||||||
break;
|
break;
|
||||||
case RECTYPE_STANDBY:
|
case RECTYPE_STANDBY:
|
||||||
appendPQExpBufferStr(&details, "! running as standby");
|
appendPQExpBuffer(&details, "! running as standby");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is registered as primary but running as standby",
|
"node \"%s\" (ID: %i) is registered as primary but running as standby",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
break;
|
break;
|
||||||
case RECTYPE_UNKNOWN:
|
case RECTYPE_UNKNOWN:
|
||||||
appendPQExpBufferStr(&details, "! unknown");
|
appendPQExpBuffer(&details, "! unknown");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) has unknown replication status",
|
"node \"%s\" (ID: %i) has unknown replication status",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
@@ -194,14 +203,14 @@ do_cluster_show(void)
|
|||||||
{
|
{
|
||||||
if (cell->node_info->recovery_type == RECTYPE_PRIMARY)
|
if (cell->node_info->recovery_type == RECTYPE_PRIMARY)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, "! running");
|
appendPQExpBuffer(&details, "! running");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is running but the repmgr node record is inactive",
|
"node \"%s\" (ID: %i) is running but the repmgr node record is inactive",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, "! running as standby");
|
appendPQExpBuffer(&details, "! running as standby");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is registered as an inactive primary but running as standby",
|
"node \"%s\" (ID: %i) is registered as an inactive primary but running as standby",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
@@ -214,7 +223,7 @@ do_cluster_show(void)
|
|||||||
/* node is unreachable but marked active */
|
/* node is unreachable but marked active */
|
||||||
if (cell->node_info->active == true)
|
if (cell->node_info->active == true)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, "? unreachable");
|
appendPQExpBuffer(&details, "? unreachable");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is registered as an active primary but is unreachable",
|
"node \"%s\" (ID: %i) is registered as an active primary but is unreachable",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
@@ -222,7 +231,7 @@ do_cluster_show(void)
|
|||||||
/* node is unreachable and marked as inactive */
|
/* node is unreachable and marked as inactive */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, "- failed");
|
appendPQExpBuffer(&details, "- failed");
|
||||||
error_found = true;
|
error_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,16 +247,16 @@ do_cluster_show(void)
|
|||||||
switch (cell->node_info->recovery_type)
|
switch (cell->node_info->recovery_type)
|
||||||
{
|
{
|
||||||
case RECTYPE_STANDBY:
|
case RECTYPE_STANDBY:
|
||||||
appendPQExpBufferStr(&details, " running");
|
appendPQExpBuffer(&details, " running");
|
||||||
break;
|
break;
|
||||||
case RECTYPE_PRIMARY:
|
case RECTYPE_PRIMARY:
|
||||||
appendPQExpBufferStr(&details, "! running as primary");
|
appendPQExpBuffer(&details, "! running as primary");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is registered as standby but running as primary",
|
"node \"%s\" (ID: %i) is registered as standby but running as primary",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
break;
|
break;
|
||||||
case RECTYPE_UNKNOWN:
|
case RECTYPE_UNKNOWN:
|
||||||
appendPQExpBufferStr(&details, "! unknown");
|
appendPQExpBuffer(&details, "! unknown");
|
||||||
item_list_append_format(
|
item_list_append_format(
|
||||||
&warnings,
|
&warnings,
|
||||||
"node \"%s\" (ID: %i) has unknown replication status",
|
"node \"%s\" (ID: %i) has unknown replication status",
|
||||||
@@ -259,14 +268,14 @@ do_cluster_show(void)
|
|||||||
{
|
{
|
||||||
if (cell->node_info->recovery_type == RECTYPE_STANDBY)
|
if (cell->node_info->recovery_type == RECTYPE_STANDBY)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, "! running");
|
appendPQExpBuffer(&details, "! running");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is running but the repmgr node record is inactive",
|
"node \"%s\" (ID: %i) is running but the repmgr node record is inactive",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, "! running as primary");
|
appendPQExpBuffer(&details, "! running as primary");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is running as primary but the repmgr node record is inactive",
|
"node \"%s\" (ID: %i) is running as primary but the repmgr node record is inactive",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
@@ -279,14 +288,14 @@ do_cluster_show(void)
|
|||||||
/* node is unreachable but marked active */
|
/* node is unreachable but marked active */
|
||||||
if (cell->node_info->active == true)
|
if (cell->node_info->active == true)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, "? unreachable");
|
appendPQExpBuffer(&details, "? unreachable");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is registered as an active standby but is unreachable",
|
"node \"%s\" (ID: %i) is registered as an active standby but is unreachable",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, "- failed");
|
appendPQExpBuffer(&details, "- failed");
|
||||||
error_found = true;
|
error_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,11 +309,11 @@ do_cluster_show(void)
|
|||||||
{
|
{
|
||||||
if (cell->node_info->active == true)
|
if (cell->node_info->active == true)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, "* running");
|
appendPQExpBuffer(&details, "* running");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, "! running");
|
appendPQExpBuffer(&details, "! running");
|
||||||
error_found = true;
|
error_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,11 +322,11 @@ do_cluster_show(void)
|
|||||||
{
|
{
|
||||||
if (cell->node_info->active == true)
|
if (cell->node_info->active == true)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, "? unreachable");
|
appendPQExpBuffer(&details, "? unreachable");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, "- failed");
|
appendPQExpBuffer(&details, "- failed");
|
||||||
error_found = true;
|
error_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,7 +335,7 @@ do_cluster_show(void)
|
|||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
{
|
{
|
||||||
/* this should never happen */
|
/* this should never happen */
|
||||||
appendPQExpBufferStr(&details, "? unknown node type");
|
appendPQExpBuffer(&details, "? unknown node type");
|
||||||
error_found = true;
|
error_found = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -355,10 +364,36 @@ do_cluster_show(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print column header row (text mode only) */
|
|
||||||
if (runtime_options.output_mode == OM_TEXT)
|
if (runtime_options.output_mode == OM_TEXT)
|
||||||
{
|
{
|
||||||
print_status_header(SHOW_HEADER_COUNT, headers_show);
|
for (i = 0; i < SHOW_HEADER_COUNT; i++)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
printf(" ");
|
||||||
|
else
|
||||||
|
printf(" | ");
|
||||||
|
|
||||||
|
printf("%-*s",
|
||||||
|
headers_show[i].max_length,
|
||||||
|
headers_show[i].title);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
printf("-");
|
||||||
|
|
||||||
|
for (i = 0; i < SHOW_HEADER_COUNT; i++)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
|
||||||
|
for (j = 0; j < headers_show[i].max_length; j++)
|
||||||
|
printf("-");
|
||||||
|
|
||||||
|
if (i < (SHOW_HEADER_COUNT - 1))
|
||||||
|
printf("-+-");
|
||||||
|
else
|
||||||
|
printf("-");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (cell = nodes.head; cell; cell = cell->next)
|
for (cell = nodes.head; cell; cell = cell->next)
|
||||||
@@ -602,12 +637,9 @@ do_cluster_crosscheck(void)
|
|||||||
|
|
||||||
t_node_status_cube **cube;
|
t_node_status_cube **cube;
|
||||||
|
|
||||||
bool connection_error_found = false;
|
bool error_found = false;
|
||||||
int error_code = SUCCESS;
|
|
||||||
ItemList warnings = {NULL, NULL};
|
|
||||||
|
|
||||||
n = build_cluster_crosscheck(&cube, &name_length, &warnings, &error_code);
|
|
||||||
|
|
||||||
|
n = build_cluster_crosscheck(&cube, &name_length);
|
||||||
if (runtime_options.output_mode == OM_CSV)
|
if (runtime_options.output_mode == OM_CSV)
|
||||||
{
|
{
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
@@ -629,11 +661,6 @@ do_cluster_crosscheck(void)
|
|||||||
cube[i]->node_id,
|
cube[i]->node_id,
|
||||||
cube[j]->node_id,
|
cube[j]->node_id,
|
||||||
max_node_status);
|
max_node_status);
|
||||||
|
|
||||||
if (max_node_status == -1)
|
|
||||||
{
|
|
||||||
connection_error_found = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -691,16 +718,16 @@ do_cluster_crosscheck(void)
|
|||||||
{
|
{
|
||||||
case -2:
|
case -2:
|
||||||
c = '?';
|
c = '?';
|
||||||
|
error_found = true;
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
c = 'x';
|
c = 'x';
|
||||||
connection_error_found = true;
|
error_found = true;
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
c = '*';
|
c = '*';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_error("unexpected node status value %i", max_node_status);
|
|
||||||
exit(ERR_INTERNAL);
|
exit(ERR_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -709,13 +736,6 @@ do_cluster_crosscheck(void)
|
|||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warnings.head != NULL && runtime_options.terse == false)
|
|
||||||
{
|
|
||||||
log_warning(_("following problems detected:"));
|
|
||||||
print_item_list(&warnings);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clean up allocated cube array */
|
/* clean up allocated cube array */
|
||||||
@@ -742,23 +762,13 @@ do_cluster_crosscheck(void)
|
|||||||
free(cube);
|
free(cube);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* errors detected by build_cluster_crosscheck() have priority */
|
if (error_found == true)
|
||||||
if (connection_error_found == true)
|
|
||||||
{
|
{
|
||||||
error_code = ERR_NODE_STATUS;
|
exit(ERR_NODE_STATUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(error_code);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* CLUSTER MATRIX
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* --csv
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
do_cluster_matrix()
|
do_cluster_matrix()
|
||||||
{
|
{
|
||||||
@@ -771,30 +781,18 @@ do_cluster_matrix()
|
|||||||
|
|
||||||
t_node_matrix_rec **matrix_rec_list;
|
t_node_matrix_rec **matrix_rec_list;
|
||||||
|
|
||||||
bool connection_error_found = false;
|
bool error_found = false;
|
||||||
int error_code = SUCCESS;
|
|
||||||
ItemList warnings = {NULL, NULL};
|
|
||||||
|
|
||||||
n = build_cluster_matrix(&matrix_rec_list, &name_length, &warnings, &error_code);
|
n = build_cluster_matrix(&matrix_rec_list, &name_length);
|
||||||
|
|
||||||
if (runtime_options.output_mode == OM_CSV)
|
if (runtime_options.output_mode == OM_CSV)
|
||||||
{
|
{
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
|
||||||
for (j = 0; j < n; j++)
|
for (j = 0; j < n; j++)
|
||||||
{
|
|
||||||
printf("%d,%d,%d\n",
|
printf("%d,%d,%d\n",
|
||||||
matrix_rec_list[i]->node_id,
|
matrix_rec_list[i]->node_id,
|
||||||
matrix_rec_list[i]->node_status_list[j]->node_id,
|
matrix_rec_list[i]->node_status_list[j]->node_id,
|
||||||
matrix_rec_list[i]->node_status_list[j]->node_status);
|
matrix_rec_list[i]->node_status_list[j]->node_status);
|
||||||
|
|
||||||
if (matrix_rec_list[i]->node_status_list[j]->node_status == -2
|
|
||||||
|| matrix_rec_list[i]->node_status_list[j]->node_status == -1)
|
|
||||||
{
|
|
||||||
connection_error_found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -823,16 +821,16 @@ do_cluster_matrix()
|
|||||||
{
|
{
|
||||||
case -2:
|
case -2:
|
||||||
c = '?';
|
c = '?';
|
||||||
|
error_found = true;
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
c = 'x';
|
c = 'x';
|
||||||
connection_error_found = true;
|
error_found = true;
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
c = '*';
|
c = '*';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_error("unexpected node status value %i", matrix_rec_list[i]->node_status_list[j]->node_status);
|
|
||||||
exit(ERR_INTERNAL);
|
exit(ERR_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -840,13 +838,6 @@ do_cluster_matrix()
|
|||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warnings.head != NULL && runtime_options.terse == false)
|
|
||||||
{
|
|
||||||
log_warning(_("following problems detected:"));
|
|
||||||
print_item_list(&warnings);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
@@ -861,13 +852,10 @@ do_cluster_matrix()
|
|||||||
|
|
||||||
free(matrix_rec_list);
|
free(matrix_rec_list);
|
||||||
|
|
||||||
/* actual database connection errors have priority */
|
if (error_found == true)
|
||||||
if (connection_error_found == true)
|
|
||||||
{
|
{
|
||||||
error_code = ERR_NODE_STATUS;
|
exit(ERR_NODE_STATUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(error_code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -896,7 +884,7 @@ matrix_set_node_status(t_node_matrix_rec **matrix_rec_list, int n, int node_id,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, ItemList *warnings, int *error_code)
|
build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length)
|
||||||
{
|
{
|
||||||
PGconn *conn = NULL;
|
PGconn *conn = NULL;
|
||||||
int i = 0,
|
int i = 0,
|
||||||
@@ -925,12 +913,7 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, Ite
|
|||||||
local_node_id = runtime_options.node_id;
|
local_node_id = runtime_options.node_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_all_node_records(conn, &nodes) == false)
|
get_all_node_records(conn, &nodes);
|
||||||
{
|
|
||||||
/* get_all_node_records() will display the error */
|
|
||||||
PQfinish(conn);
|
|
||||||
exit(ERR_BAD_CONFIG);
|
|
||||||
}
|
|
||||||
|
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
conn = NULL;
|
conn = NULL;
|
||||||
@@ -944,7 +927,7 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, Ite
|
|||||||
/*
|
/*
|
||||||
* Allocate an empty matrix record list
|
* Allocate an empty matrix record list
|
||||||
*
|
*
|
||||||
* -2 == NULL ? -1 == Error x 0 == OK
|
* -2 == NULL ? -1 == Error x 0 == OK *
|
||||||
*/
|
*/
|
||||||
|
|
||||||
matrix_rec_list = (t_node_matrix_rec **) pg_malloc0(sizeof(t_node_matrix_rec) * nodes.node_count);
|
matrix_rec_list = (t_node_matrix_rec **) pg_malloc0(sizeof(t_node_matrix_rec) * nodes.node_count);
|
||||||
@@ -1007,7 +990,7 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, Ite
|
|||||||
|
|
||||||
host = param_get(&remote_conninfo, "host");
|
host = param_get(&remote_conninfo, "host");
|
||||||
|
|
||||||
node_conn = establish_db_connection_quiet(cell->node_info->conninfo);
|
node_conn = establish_db_connection(cell->node_info->conninfo, false);
|
||||||
|
|
||||||
connection_status =
|
connection_status =
|
||||||
(PQstatus(node_conn) == CONNECTION_OK) ? 0 : -1;
|
(PQstatus(node_conn) == CONNECTION_OK) ? 0 : -1;
|
||||||
@@ -1044,12 +1027,24 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, Ite
|
|||||||
* remote repmgr - those are the only values it needs to work, and
|
* remote repmgr - those are the only values it needs to work, and
|
||||||
* saves us making assumptions about the location of repmgr.conf
|
* saves us making assumptions about the location of repmgr.conf
|
||||||
*/
|
*/
|
||||||
appendPQExpBufferChar(&command, '"');
|
appendPQExpBuffer(&command,
|
||||||
|
"\"%s -d '%s' ",
|
||||||
|
make_pg_path(progname()),
|
||||||
|
cell->node_info->conninfo);
|
||||||
|
|
||||||
make_remote_repmgr_path(&command, cell->node_info);
|
|
||||||
|
|
||||||
appendPQExpBufferStr(&command,
|
if (strlen(pg_bindir))
|
||||||
" cluster show --csv -L NOTICE --terse\"");
|
{
|
||||||
|
appendPQExpBuffer(&command,
|
||||||
|
"--pg_bindir=");
|
||||||
|
appendShellString(&command,
|
||||||
|
pg_bindir);
|
||||||
|
appendPQExpBuffer(&command,
|
||||||
|
" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
appendPQExpBuffer(&command,
|
||||||
|
" cluster show --csv\"");
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "build_cluster_matrix(): executing:\n %s", command.data);
|
log_verbose(LOG_DEBUG, "build_cluster_matrix(): executing:\n %s", command.data);
|
||||||
|
|
||||||
@@ -1064,50 +1059,32 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, Ite
|
|||||||
|
|
||||||
termPQExpBuffer(&command);
|
termPQExpBuffer(&command);
|
||||||
|
|
||||||
/* no output returned - probably SSH error */
|
for (j = 0; j < nodes.node_count; j++)
|
||||||
if (p[0] == '\0' || p[0] == '\n')
|
|
||||||
{
|
{
|
||||||
item_list_append_format(warnings,
|
if (sscanf(p, "%d,%d", &x, &y) != 2)
|
||||||
"node %i inaccessible via SSH",
|
|
||||||
connection_node_id);
|
|
||||||
*error_code = ERR_BAD_SSH;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (j = 0; j < nodes.node_count; j++)
|
|
||||||
{
|
{
|
||||||
if (sscanf(p, "%d,%d", &x, &y) != 2)
|
fprintf(stderr, _("cannot parse --csv output: %s\n"), p);
|
||||||
{
|
PQfinish(node_conn);
|
||||||
matrix_set_node_status(matrix_rec_list,
|
exit(ERR_INTERNAL);
|
||||||
nodes.node_count,
|
|
||||||
connection_node_id,
|
|
||||||
x,
|
|
||||||
-2);
|
|
||||||
|
|
||||||
item_list_append_format(warnings,
|
|
||||||
"unable to parse --csv output for node %i; output returned was:\n\"%s\"",
|
|
||||||
connection_node_id, p);
|
|
||||||
*error_code = ERR_INTERNAL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
matrix_set_node_status(matrix_rec_list,
|
|
||||||
nodes.node_count,
|
|
||||||
connection_node_id,
|
|
||||||
x,
|
|
||||||
(y == -1) ? -1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (*p && (*p != '\n'))
|
|
||||||
p++;
|
|
||||||
if (*p == '\n')
|
|
||||||
p++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
matrix_set_node_status(matrix_rec_list,
|
||||||
|
nodes.node_count,
|
||||||
|
connection_node_id,
|
||||||
|
x,
|
||||||
|
(y == -1) ? -1 : 0);
|
||||||
|
|
||||||
|
while (*p && (*p != '\n'))
|
||||||
|
p++;
|
||||||
|
if (*p == '\n')
|
||||||
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
termPQExpBuffer(&command_output);
|
termPQExpBuffer(&command_output);
|
||||||
PQfinish(node_conn);
|
PQfinish(node_conn);
|
||||||
free_conninfo_params(&remote_conninfo);
|
free_conninfo_params(&remote_conninfo);
|
||||||
|
|
||||||
|
node_conn = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*matrix_rec_dest = matrix_rec_list;
|
*matrix_rec_dest = matrix_rec_list;
|
||||||
@@ -1120,7 +1097,7 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, Ite
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length, ItemList *warnings, int *error_code)
|
build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length)
|
||||||
{
|
{
|
||||||
PGconn *conn = NULL;
|
PGconn *conn = NULL;
|
||||||
int h,
|
int h,
|
||||||
@@ -1141,12 +1118,7 @@ build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length, Item
|
|||||||
else
|
else
|
||||||
conn = establish_db_connection_by_params(&source_conninfo, true);
|
conn = establish_db_connection_by_params(&source_conninfo, true);
|
||||||
|
|
||||||
if (get_all_node_records(conn, &nodes) == false)
|
get_all_node_records(conn, &nodes);
|
||||||
{
|
|
||||||
/* get_all_node_records() will display the error */
|
|
||||||
PQfinish(conn);
|
|
||||||
exit(ERR_BAD_CONFIG);
|
|
||||||
}
|
|
||||||
|
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
conn = NULL;
|
conn = NULL;
|
||||||
@@ -1233,13 +1205,28 @@ build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length, Item
|
|||||||
|
|
||||||
initPQExpBuffer(&command);
|
initPQExpBuffer(&command);
|
||||||
|
|
||||||
make_remote_repmgr_path(&command, cell->node_info);
|
appendPQExpBuffer(&command,
|
||||||
|
"%s -d '%s' --node-id=%i ",
|
||||||
|
make_pg_path(progname()),
|
||||||
|
cell->node_info->conninfo,
|
||||||
|
remote_node_id);
|
||||||
|
|
||||||
appendPQExpBufferStr(&command,
|
if (strlen(pg_bindir))
|
||||||
" cluster matrix --csv -L NOTICE --terse");
|
{
|
||||||
|
appendPQExpBuffer(&command,
|
||||||
|
"--pg_bindir=");
|
||||||
|
appendShellString(&command,
|
||||||
|
pg_bindir);
|
||||||
|
appendPQExpBuffer(&command,
|
||||||
|
" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
appendPQExpBuffer(&command,
|
||||||
|
"cluster matrix --csv 2>/dev/null");
|
||||||
|
|
||||||
initPQExpBuffer(&command_output);
|
initPQExpBuffer(&command_output);
|
||||||
|
|
||||||
|
/* fix to work with --node-id */
|
||||||
if (cube[i]->node_id == config_file_options.node_id)
|
if (cube[i]->node_id == config_file_options.node_id)
|
||||||
{
|
{
|
||||||
(void) local_command_simple(command.data,
|
(void) local_command_simple(command.data,
|
||||||
@@ -1280,13 +1267,9 @@ build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length, Item
|
|||||||
|
|
||||||
p = command_output.data;
|
p = command_output.data;
|
||||||
|
|
||||||
if (p[0] == '\0' || p[0] == '\n')
|
if (!strlen(command_output.data))
|
||||||
{
|
{
|
||||||
item_list_append_format(warnings,
|
|
||||||
"node %i inaccessible via SSH",
|
|
||||||
remote_node_id);
|
|
||||||
termPQExpBuffer(&command_output);
|
termPQExpBuffer(&command_output);
|
||||||
*error_code = ERR_BAD_SSH;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1298,24 +1281,17 @@ build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length, Item
|
|||||||
|
|
||||||
if (sscanf(p, "%d,%d,%d", &matrix_rec_node_id, &node_status_node_id, &node_status) != 3)
|
if (sscanf(p, "%d,%d,%d", &matrix_rec_node_id, &node_status_node_id, &node_status) != 3)
|
||||||
{
|
{
|
||||||
cube_set_node_status(cube,
|
fprintf(stderr, _("cannot parse --csv output: %s\n"), p);
|
||||||
nodes.node_count,
|
exit(ERR_INTERNAL);
|
||||||
remote_node_id,
|
|
||||||
matrix_rec_node_id,
|
|
||||||
node_status_node_id,
|
|
||||||
-2);
|
|
||||||
*error_code = ERR_INTERNAL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cube_set_node_status(cube,
|
|
||||||
nodes.node_count,
|
|
||||||
remote_node_id,
|
|
||||||
matrix_rec_node_id,
|
|
||||||
node_status_node_id,
|
|
||||||
node_status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cube_set_node_status(cube,
|
||||||
|
nodes.node_count,
|
||||||
|
remote_node_id,
|
||||||
|
matrix_rec_node_id,
|
||||||
|
node_status_node_id,
|
||||||
|
node_status);
|
||||||
|
|
||||||
while (*p && (*p != '\n'))
|
while (*p && (*p != '\n'))
|
||||||
p++;
|
p++;
|
||||||
if (*p == '\n')
|
if (*p == '\n')
|
||||||
@@ -1386,9 +1362,7 @@ do_cluster_cleanup(void)
|
|||||||
|
|
||||||
log_debug(_("number of days of monitoring history to retain: %i"), runtime_options.keep_history);
|
log_debug(_("number of days of monitoring history to retain: %i"), runtime_options.keep_history);
|
||||||
|
|
||||||
entries_to_delete = get_number_of_monitoring_records_to_delete(primary_conn,
|
entries_to_delete = get_number_of_monitoring_records_to_delete(primary_conn, runtime_options.keep_history);
|
||||||
runtime_options.keep_history,
|
|
||||||
runtime_options.node_id);
|
|
||||||
|
|
||||||
if (entries_to_delete < 0)
|
if (entries_to_delete < 0)
|
||||||
{
|
{
|
||||||
@@ -1408,9 +1382,9 @@ do_cluster_cleanup(void)
|
|||||||
|
|
||||||
initPQExpBuffer(&event_details);
|
initPQExpBuffer(&event_details);
|
||||||
|
|
||||||
if (delete_monitoring_records(primary_conn, runtime_options.keep_history, runtime_options.node_id) == false)
|
if (delete_monitoring_records(primary_conn, runtime_options.keep_history) == false)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&event_details,
|
appendPQExpBuffer(&event_details,
|
||||||
_("unable to delete monitoring records"));
|
_("unable to delete monitoring records"));
|
||||||
|
|
||||||
log_error("%s", event_details.data);
|
log_error("%s", event_details.data);
|
||||||
@@ -1434,21 +1408,8 @@ do_cluster_cleanup(void)
|
|||||||
log_detail("%s", PQerrorMessage(primary_conn));
|
log_detail("%s", PQerrorMessage(primary_conn));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runtime_options.keep_history == 0)
|
appendPQExpBuffer(&event_details,
|
||||||
{
|
_("monitoring records deleted"));
|
||||||
appendPQExpBufferStr(&event_details,
|
|
||||||
_("all monitoring records deleted"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
appendPQExpBufferStr(&event_details,
|
|
||||||
_("monitoring records deleted"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (runtime_options.node_id != UNKNOWN_NODE_ID)
|
|
||||||
appendPQExpBuffer(&event_details,
|
|
||||||
_(" for node %i"),
|
|
||||||
runtime_options.node_id);
|
|
||||||
|
|
||||||
if (runtime_options.keep_history > 0)
|
if (runtime_options.keep_history > 0)
|
||||||
appendPQExpBuffer(&event_details,
|
appendPQExpBuffer(&event_details,
|
||||||
@@ -1462,11 +1423,18 @@ do_cluster_cleanup(void)
|
|||||||
true,
|
true,
|
||||||
event_details.data);
|
event_details.data);
|
||||||
|
|
||||||
log_notice("%s", event_details.data);
|
|
||||||
|
|
||||||
termPQExpBuffer(&event_details);
|
termPQExpBuffer(&event_details);
|
||||||
PQfinish(primary_conn);
|
PQfinish(primary_conn);
|
||||||
|
|
||||||
|
if (runtime_options.keep_history > 0)
|
||||||
|
{
|
||||||
|
log_notice(_("monitoring records older than %i day(s) deleted"),
|
||||||
|
runtime_options.keep_history);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_info(_("all monitoring records deleted"));
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1527,7 +1495,7 @@ do_cluster_help(void)
|
|||||||
|
|
||||||
printf(_("CLUSTER CLEANUP\n"));
|
printf(_("CLUSTER CLEANUP\n"));
|
||||||
puts("");
|
puts("");
|
||||||
printf(_(" \"cluster cleanup\" purges records from the \"repmgr.monitoring_history\" table.\n"));
|
printf(_(" \"cluster cleanup\" purges records from the \"repmgr.monitor\" table.\n"));
|
||||||
puts("");
|
puts("");
|
||||||
printf(_(" -k, --keep-history=VALUE retain indicated number of days of history (default: 0)\n"));
|
printf(_(" -k, --keep-history=VALUE retain indicated number of days of history (default: 0)\n"));
|
||||||
puts("");
|
puts("");
|
||||||
|
|||||||
@@ -1,420 +0,0 @@
|
|||||||
/*
|
|
||||||
* repmgr-action-daemon.c
|
|
||||||
*
|
|
||||||
* Implements repmgrd actions for the repmgr command line utility
|
|
||||||
* Copyright (c) 2ndQuadrant, 2010-2018
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "repmgr.h"
|
|
||||||
|
|
||||||
#include "repmgr-client-global.h"
|
|
||||||
#include "repmgr-action-daemon.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Possibly also show:
|
|
||||||
* - repmgrd start time?
|
|
||||||
* - repmgrd mode
|
|
||||||
* - priority
|
|
||||||
* - whether promotion candidate (due to zero priority/different location)
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
STATUS_ID = 0,
|
|
||||||
STATUS_NAME,
|
|
||||||
STATUS_ROLE,
|
|
||||||
STATUS_PG,
|
|
||||||
STATUS_RUNNING,
|
|
||||||
STATUS_PID,
|
|
||||||
STATUS_PAUSED
|
|
||||||
} StatusHeader;
|
|
||||||
|
|
||||||
#define STATUS_HEADER_COUNT 7
|
|
||||||
|
|
||||||
struct ColHeader headers_status[STATUS_HEADER_COUNT];
|
|
||||||
|
|
||||||
static void fetch_node_records(PGconn *conn, NodeInfoList *node_list);
|
|
||||||
static void _do_repmgr_pause(bool pause);
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
do_daemon_status(void)
|
|
||||||
{
|
|
||||||
PGconn *conn = NULL;
|
|
||||||
NodeInfoList nodes = T_NODE_INFO_LIST_INITIALIZER;
|
|
||||||
NodeInfoListCell *cell = NULL;
|
|
||||||
int i;
|
|
||||||
RepmgrdInfo **repmgrd_info;
|
|
||||||
ItemList warnings = {NULL, NULL};
|
|
||||||
|
|
||||||
/* Connect to local database to obtain cluster connection data */
|
|
||||||
log_verbose(LOG_INFO, _("connecting to database"));
|
|
||||||
|
|
||||||
if (strlen(config_file_options.conninfo))
|
|
||||||
conn = establish_db_connection(config_file_options.conninfo, true);
|
|
||||||
else
|
|
||||||
conn = establish_db_connection_by_params(&source_conninfo, true);
|
|
||||||
|
|
||||||
fetch_node_records(conn, &nodes);
|
|
||||||
|
|
||||||
repmgrd_info = (RepmgrdInfo **) pg_malloc0(sizeof(RepmgrdInfo *) * nodes.node_count);
|
|
||||||
|
|
||||||
if (repmgrd_info == NULL)
|
|
||||||
{
|
|
||||||
log_error(_("unable to allocate memory"));
|
|
||||||
exit(ERR_OUT_OF_MEMORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
strncpy(headers_status[STATUS_ID].title, _("ID"), MAXLEN);
|
|
||||||
strncpy(headers_status[STATUS_NAME].title, _("Name"), MAXLEN);
|
|
||||||
strncpy(headers_status[STATUS_ROLE].title, _("Role"), MAXLEN);
|
|
||||||
strncpy(headers_status[STATUS_PG].title, _("Status"), MAXLEN);
|
|
||||||
strncpy(headers_status[STATUS_RUNNING].title, _("repmgrd"), MAXLEN);
|
|
||||||
strncpy(headers_status[STATUS_PID].title, _("PID"), MAXLEN);
|
|
||||||
strncpy(headers_status[STATUS_PAUSED].title, _("Paused?"), MAXLEN);
|
|
||||||
|
|
||||||
for (i = 0; i < STATUS_HEADER_COUNT; i++)
|
|
||||||
{
|
|
||||||
headers_status[i].max_length = strlen(headers_status[i].title);
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
for (cell = nodes.head; cell; cell = cell->next)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
repmgrd_info[i] = pg_malloc0(sizeof(RepmgrdInfo));
|
|
||||||
repmgrd_info[i]->node_id = cell->node_info->node_id;
|
|
||||||
repmgrd_info[i]->pid = UNKNOWN_PID;
|
|
||||||
repmgrd_info[i]->paused = false;
|
|
||||||
repmgrd_info[i]->running = false;
|
|
||||||
repmgrd_info[i]->pg_running = true;
|
|
||||||
|
|
||||||
cell->node_info->conn = establish_db_connection_quiet(cell->node_info->conninfo);
|
|
||||||
|
|
||||||
if (PQstatus(cell->node_info->conn) != CONNECTION_OK)
|
|
||||||
{
|
|
||||||
if (runtime_options.verbose)
|
|
||||||
{
|
|
||||||
char error[MAXLEN];
|
|
||||||
|
|
||||||
strncpy(error, PQerrorMessage(cell->node_info->conn), MAXLEN);
|
|
||||||
|
|
||||||
item_list_append_format(&warnings,
|
|
||||||
"when attempting to connect to node \"%s\" (ID: %i), following error encountered :\n\"%s\"",
|
|
||||||
cell->node_info->node_name, cell->node_info->node_id, trim(error));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
item_list_append_format(&warnings,
|
|
||||||
"unable to connect to node \"%s\" (ID: %i)",
|
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
repmgrd_info[i]->pg_running = false;
|
|
||||||
maxlen_snprintf(repmgrd_info[i]->pg_running_text, "%s", _("not running"));
|
|
||||||
maxlen_snprintf(repmgrd_info[i]->repmgrd_running, "%s", _("n/a"));
|
|
||||||
maxlen_snprintf(repmgrd_info[i]->pid_text, "%s", _("n/a"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
maxlen_snprintf(repmgrd_info[i]->pg_running_text, "%s", _("running"));
|
|
||||||
|
|
||||||
repmgrd_info[i]->pid = repmgrd_get_pid(cell->node_info->conn);
|
|
||||||
|
|
||||||
repmgrd_info[i]->running = repmgrd_is_running(cell->node_info->conn);
|
|
||||||
|
|
||||||
if (repmgrd_info[i]->running == true)
|
|
||||||
{
|
|
||||||
maxlen_snprintf(repmgrd_info[i]->repmgrd_running, "%s", _("running"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
maxlen_snprintf(repmgrd_info[i]->repmgrd_running, "%s", _("not running"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (repmgrd_info[i]->pid == UNKNOWN_PID)
|
|
||||||
{
|
|
||||||
maxlen_snprintf(repmgrd_info[i]->pid_text, "%s", _("n/a"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
maxlen_snprintf(repmgrd_info[i]->pid_text, "%i", repmgrd_info[i]->pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
repmgrd_info[i]->paused = repmgrd_is_paused(cell->node_info->conn);
|
|
||||||
|
|
||||||
PQfinish(cell->node_info->conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
headers_status[STATUS_NAME].cur_length = strlen(cell->node_info->node_name);
|
|
||||||
headers_status[STATUS_ROLE].cur_length = strlen(get_node_type_string(cell->node_info->type));
|
|
||||||
headers_status[STATUS_PID].cur_length = strlen(repmgrd_info[i]->pid_text);
|
|
||||||
headers_status[STATUS_RUNNING].cur_length = strlen(repmgrd_info[i]->repmgrd_running);
|
|
||||||
headers_status[STATUS_PG].cur_length = strlen(repmgrd_info[i]->pg_running_text);
|
|
||||||
|
|
||||||
for (j = 0; j < STATUS_HEADER_COUNT; j++)
|
|
||||||
{
|
|
||||||
if (headers_status[j].cur_length > headers_status[j].max_length)
|
|
||||||
{
|
|
||||||
headers_status[j].max_length = headers_status[j].cur_length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Print column header row (text mode only) */
|
|
||||||
if (runtime_options.output_mode == OM_TEXT)
|
|
||||||
{
|
|
||||||
print_status_header(STATUS_HEADER_COUNT, headers_status);
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
for (cell = nodes.head; cell; cell = cell->next)
|
|
||||||
{
|
|
||||||
if (runtime_options.output_mode == OM_CSV)
|
|
||||||
{
|
|
||||||
printf("%i,%s,%s,%i,%i,%i,%i\n",
|
|
||||||
cell->node_info->node_id,
|
|
||||||
cell->node_info->node_name,
|
|
||||||
get_node_type_string(cell->node_info->type),
|
|
||||||
repmgrd_info[i]->pg_running ? 1 : 0,
|
|
||||||
repmgrd_info[i]->running ? 1 : 0,
|
|
||||||
repmgrd_info[i]->pid,
|
|
||||||
repmgrd_info[i]->paused ? 1 : 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(" %-*i ", headers_status[STATUS_ID].max_length, cell->node_info->node_id);
|
|
||||||
printf("| %-*s ", headers_status[STATUS_NAME].max_length, cell->node_info->node_name);
|
|
||||||
printf("| %-*s ", headers_status[STATUS_ROLE].max_length, get_node_type_string(cell->node_info->type));
|
|
||||||
|
|
||||||
printf("| %-*s ", headers_status[STATUS_PG].max_length, repmgrd_info[i]->pg_running_text);
|
|
||||||
printf("| %-*s ", headers_status[STATUS_RUNNING].max_length, repmgrd_info[i]->repmgrd_running);
|
|
||||||
printf("| %-*s ", headers_status[STATUS_PID].max_length, repmgrd_info[i]->pid_text);
|
|
||||||
|
|
||||||
if (repmgrd_info[i]->pid == UNKNOWN_PID)
|
|
||||||
printf("| %-*s ", headers_status[STATUS_PAUSED].max_length, "n/a");
|
|
||||||
else
|
|
||||||
printf("| %-*s ", headers_status[STATUS_PAUSED].max_length, repmgrd_info[i]->paused ? "yes" : "no");
|
|
||||||
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
free(repmgrd_info[i]);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(repmgrd_info);
|
|
||||||
|
|
||||||
/* emit any warnings */
|
|
||||||
|
|
||||||
if (warnings.head != NULL && runtime_options.terse == false && runtime_options.output_mode != OM_CSV)
|
|
||||||
{
|
|
||||||
ItemListCell *cell = NULL;
|
|
||||||
|
|
||||||
printf(_("\nWARNING: following issues were detected\n"));
|
|
||||||
for (cell = warnings.head; cell; cell = cell->next)
|
|
||||||
{
|
|
||||||
printf(_(" - %s\n"), cell->string);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (runtime_options.verbose == false)
|
|
||||||
{
|
|
||||||
log_hint(_("execute with --verbose option to see connection error messages"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
do_daemon_pause(void)
|
|
||||||
{
|
|
||||||
_do_repmgr_pause(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
do_daemon_unpause(void)
|
|
||||||
{
|
|
||||||
_do_repmgr_pause(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
_do_repmgr_pause(bool pause)
|
|
||||||
{
|
|
||||||
PGconn *conn = NULL;
|
|
||||||
NodeInfoList nodes = T_NODE_INFO_LIST_INITIALIZER;
|
|
||||||
NodeInfoListCell *cell = NULL;
|
|
||||||
RepmgrdInfo **repmgrd_info;
|
|
||||||
int i;
|
|
||||||
int error_nodes = 0;
|
|
||||||
|
|
||||||
repmgrd_info = (RepmgrdInfo **) pg_malloc0(sizeof(RepmgrdInfo *) * nodes.node_count);
|
|
||||||
|
|
||||||
if (repmgrd_info == NULL)
|
|
||||||
{
|
|
||||||
log_error(_("unable to allocate memory"));
|
|
||||||
exit(ERR_OUT_OF_MEMORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Connect to local database to obtain cluster connection data */
|
|
||||||
log_verbose(LOG_INFO, _("connecting to database"));
|
|
||||||
|
|
||||||
if (strlen(config_file_options.conninfo))
|
|
||||||
conn = establish_db_connection(config_file_options.conninfo, true);
|
|
||||||
else
|
|
||||||
conn = establish_db_connection_by_params(&source_conninfo, true);
|
|
||||||
|
|
||||||
fetch_node_records(conn, &nodes);
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
for (cell = nodes.head; cell; cell = cell->next)
|
|
||||||
{
|
|
||||||
repmgrd_info[i] = pg_malloc0(sizeof(RepmgrdInfo));
|
|
||||||
repmgrd_info[i]->node_id = cell->node_info->node_id;
|
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "pausing node %i (%s)",
|
|
||||||
cell->node_info->node_id,
|
|
||||||
cell->node_info->node_name);
|
|
||||||
cell->node_info->conn = establish_db_connection_quiet(cell->node_info->conninfo);
|
|
||||||
|
|
||||||
if (PQstatus(cell->node_info->conn) != CONNECTION_OK)
|
|
||||||
{
|
|
||||||
log_warning(_("unable to connect to node %i"),
|
|
||||||
cell->node_info->node_id);
|
|
||||||
error_nodes++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (runtime_options.dry_run == true)
|
|
||||||
{
|
|
||||||
if (pause == true)
|
|
||||||
{
|
|
||||||
log_info(_("would pause node %i (%s) "),
|
|
||||||
cell->node_info->node_id,
|
|
||||||
cell->node_info->node_name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log_info(_("would unpause node %i (%s) "),
|
|
||||||
cell->node_info->node_id,
|
|
||||||
cell->node_info->node_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool success = repmgrd_pause(cell->node_info->conn, pause);
|
|
||||||
|
|
||||||
if (success == false)
|
|
||||||
error_nodes++;
|
|
||||||
|
|
||||||
log_notice(_("node %i (%s) %s"),
|
|
||||||
cell->node_info->node_id,
|
|
||||||
cell->node_info->node_name,
|
|
||||||
success == true
|
|
||||||
? pause == true ? "paused" : "unpaused"
|
|
||||||
: pause == true ? "not paused" : "not unpaused");
|
|
||||||
}
|
|
||||||
PQfinish(cell->node_info->conn);
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error_nodes > 0)
|
|
||||||
{
|
|
||||||
if (pause == true)
|
|
||||||
{
|
|
||||||
log_error(_("unable to pause %i node(s)"), error_nodes);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log_error(_("unable to unpause %i node(s)"), error_nodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
log_hint(_("execute \"repmgr daemon status\" to view current status"));
|
|
||||||
|
|
||||||
exit(ERR_REPMGRD_PAUSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
exit(SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
fetch_node_records(PGconn *conn, NodeInfoList *node_list)
|
|
||||||
{
|
|
||||||
bool success = get_all_node_records(conn, node_list);
|
|
||||||
|
|
||||||
if (success == false)
|
|
||||||
{
|
|
||||||
/* get_all_node_records() will display any error message */
|
|
||||||
PQfinish(conn);
|
|
||||||
exit(ERR_BAD_CONFIG);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node_list->node_count == 0)
|
|
||||||
{
|
|
||||||
log_error(_("no node records were found"));
|
|
||||||
log_hint(_("ensure at least one node is registered"));
|
|
||||||
PQfinish(conn);
|
|
||||||
exit(ERR_BAD_CONFIG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void do_daemon_help(void)
|
|
||||||
{
|
|
||||||
print_help_header();
|
|
||||||
|
|
||||||
printf(_("Usage:\n"));
|
|
||||||
printf(_(" %s [OPTIONS] daemon status\n"), progname());
|
|
||||||
printf(_(" %s [OPTIONS] daemon pause\n"), progname());
|
|
||||||
printf(_(" %s [OPTIONS] daemon unpause\n"), progname());
|
|
||||||
puts("");
|
|
||||||
|
|
||||||
printf(_("DAEMON STATUS\n"));
|
|
||||||
puts("");
|
|
||||||
printf(_(" \"daemon status\" shows the status of repmgrd on each node in the cluster\n"));
|
|
||||||
puts("");
|
|
||||||
printf(_(" --csv emit output as CSV\n"));
|
|
||||||
printf(_(" --verbose show text of database connection error messages\n"));
|
|
||||||
puts("");
|
|
||||||
|
|
||||||
printf(_("DAEMON PAUSE\n"));
|
|
||||||
puts("");
|
|
||||||
printf(_(" \"daemon pause\" instructs repmgrd on each node to pause failover detection\n"));
|
|
||||||
puts("");
|
|
||||||
printf(_(" --dry-run check if nodes are reachable but don't pause repmgrd\n"));
|
|
||||||
puts("");
|
|
||||||
|
|
||||||
printf(_("DAEMON PAUSE\n"));
|
|
||||||
puts("");
|
|
||||||
printf(_(" \"daemon unpause\" instructs repmgrd on each node to resume failover detection\n"));
|
|
||||||
puts("");
|
|
||||||
printf(_(" --dry-run check if nodes are reachable but don't unpause repmgrd\n"));
|
|
||||||
puts("");
|
|
||||||
|
|
||||||
|
|
||||||
puts("");
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* repmgr-action-daemon.h
|
|
||||||
* Copyright (c) 2ndQuadrant, 2010-2018
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _REPMGR_ACTION_DAEMON_H_
|
|
||||||
#define _REPMGR_ACTION_DAEMON_H_
|
|
||||||
|
|
||||||
|
|
||||||
extern void do_daemon_status(void);
|
|
||||||
extern void do_daemon_pause(void);
|
|
||||||
extern void do_daemon_unpause(void);
|
|
||||||
|
|
||||||
extern void do_daemon_help(void);
|
|
||||||
#endif
|
|
||||||
@@ -189,16 +189,16 @@ do_node_status(void)
|
|||||||
|
|
||||||
if (enabled == true)
|
if (enabled == true)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&archiving_status, "enabled");
|
appendPQExpBuffer(&archiving_status, "enabled");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&archiving_status, "disabled");
|
appendPQExpBuffer(&archiving_status, "disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enabled == false && recovery_type == RECTYPE_STANDBY)
|
if (enabled == false && recovery_type == RECTYPE_STANDBY)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&archiving_status, " (on standbys \"archive_mode\" must be set to \"always\" to be effective)");
|
appendPQExpBuffer(&archiving_status, " (on standbys \"archive_mode\" must be set to \"always\" to be effective)");
|
||||||
}
|
}
|
||||||
|
|
||||||
key_value_list_set(&node_status,
|
key_value_list_set(&node_status,
|
||||||
@@ -506,7 +506,7 @@ do_node_status(void)
|
|||||||
|
|
||||||
/* output missing slot information */
|
/* output missing slot information */
|
||||||
|
|
||||||
appendPQExpBufferChar(&output, '\n');
|
appendPQExpBuffer(&output, "\n");
|
||||||
appendPQExpBuffer(&output,
|
appendPQExpBuffer(&output,
|
||||||
"\"missing_replication_slots\",%i",
|
"\"missing_replication_slots\",%i",
|
||||||
missing_slots.node_count);
|
missing_slots.node_count);
|
||||||
@@ -590,13 +590,13 @@ _do_node_status_is_shutdown_cleanly(void)
|
|||||||
|
|
||||||
initPQExpBuffer(&output);
|
initPQExpBuffer(&output);
|
||||||
|
|
||||||
appendPQExpBufferStr(&output,
|
appendPQExpBuffer(&output,
|
||||||
"--state=");
|
"--state=");
|
||||||
|
|
||||||
/* sanity-check we're dealing with a PostgreSQL directory */
|
/* sanity-check we're dealing with a PostgreSQL directory */
|
||||||
if (is_pg_dir(config_file_options.data_directory) == false)
|
if (is_pg_dir(config_file_options.data_directory) == false)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&output, "UNKNOWN");
|
appendPQExpBuffer(&output, "UNKNOWN");
|
||||||
printf("%s\n", output.data);
|
printf("%s\n", output.data);
|
||||||
termPQExpBuffer(&output);
|
termPQExpBuffer(&output);
|
||||||
return;
|
return;
|
||||||
@@ -659,10 +659,10 @@ _do_node_status_is_shutdown_cleanly(void)
|
|||||||
switch (node_status)
|
switch (node_status)
|
||||||
{
|
{
|
||||||
case NODE_STATUS_UP:
|
case NODE_STATUS_UP:
|
||||||
appendPQExpBufferStr(&output, "RUNNING");
|
appendPQExpBuffer(&output, "RUNNING");
|
||||||
break;
|
break;
|
||||||
case NODE_STATUS_SHUTTING_DOWN:
|
case NODE_STATUS_SHUTTING_DOWN:
|
||||||
appendPQExpBufferStr(&output, "SHUTTING_DOWN");
|
appendPQExpBuffer(&output, "SHUTTING_DOWN");
|
||||||
break;
|
break;
|
||||||
case NODE_STATUS_DOWN:
|
case NODE_STATUS_DOWN:
|
||||||
appendPQExpBuffer(&output,
|
appendPQExpBuffer(&output,
|
||||||
@@ -670,10 +670,10 @@ _do_node_status_is_shutdown_cleanly(void)
|
|||||||
format_lsn(checkPoint));
|
format_lsn(checkPoint));
|
||||||
break;
|
break;
|
||||||
case NODE_STATUS_UNCLEAN_SHUTDOWN:
|
case NODE_STATUS_UNCLEAN_SHUTDOWN:
|
||||||
appendPQExpBufferStr(&output, "UNCLEAN_SHUTDOWN");
|
appendPQExpBuffer(&output, "UNCLEAN_SHUTDOWN");
|
||||||
break;
|
break;
|
||||||
case NODE_STATUS_UNKNOWN:
|
case NODE_STATUS_UNKNOWN:
|
||||||
appendPQExpBufferStr(&output, "UNKNOWN");
|
appendPQExpBuffer(&output, "UNKNOWN");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -847,7 +847,7 @@ do_node_check(void)
|
|||||||
",\"%s\"",
|
",\"%s\"",
|
||||||
cell->details);
|
cell->details);
|
||||||
}
|
}
|
||||||
appendPQExpBufferChar(&output, '\n');
|
appendPQExpBuffer(&output, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -869,7 +869,7 @@ do_node_check(void)
|
|||||||
" (%s)",
|
" (%s)",
|
||||||
cell->details);
|
cell->details);
|
||||||
}
|
}
|
||||||
appendPQExpBufferChar(&output, '\n');
|
appendPQExpBuffer(&output, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -899,12 +899,12 @@ do_node_check_replication_connection(void)
|
|||||||
|
|
||||||
|
|
||||||
initPQExpBuffer(&output);
|
initPQExpBuffer(&output);
|
||||||
appendPQExpBufferStr(&output,
|
appendPQExpBuffer(&output,
|
||||||
"--connection=");
|
"--connection=");
|
||||||
|
|
||||||
if (runtime_options.remote_node_id == UNKNOWN_NODE_ID)
|
if (runtime_options.remote_node_id == UNKNOWN_NODE_ID)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&output, "UNKNOWN");
|
appendPQExpBuffer(&output, "UNKNOWN");
|
||||||
printf("%s\n", output.data);
|
printf("%s\n", output.data);
|
||||||
termPQExpBuffer(&output);
|
termPQExpBuffer(&output);
|
||||||
return;
|
return;
|
||||||
@@ -918,7 +918,7 @@ do_node_check_replication_connection(void)
|
|||||||
|
|
||||||
if (record_status != RECORD_FOUND)
|
if (record_status != RECORD_FOUND)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&output, "UNKNOWN");
|
appendPQExpBuffer(&output, "UNKNOWN");
|
||||||
printf("%s\n", output.data);
|
printf("%s\n", output.data);
|
||||||
termPQExpBuffer(&output);
|
termPQExpBuffer(&output);
|
||||||
return;
|
return;
|
||||||
@@ -938,7 +938,7 @@ do_node_check_replication_connection(void)
|
|||||||
|
|
||||||
if (PQstatus(repl_conn) != CONNECTION_OK)
|
if (PQstatus(repl_conn) != CONNECTION_OK)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&output, "BAD");
|
appendPQExpBuffer(&output, "BAD");
|
||||||
printf("%s\n", output.data);
|
printf("%s\n", output.data);
|
||||||
termPQExpBuffer(&output);
|
termPQExpBuffer(&output);
|
||||||
return;
|
return;
|
||||||
@@ -946,7 +946,7 @@ do_node_check_replication_connection(void)
|
|||||||
|
|
||||||
PQfinish(repl_conn);
|
PQfinish(repl_conn);
|
||||||
|
|
||||||
appendPQExpBufferStr(&output, "OK");
|
appendPQExpBuffer(&output, "OK");
|
||||||
printf("%s\n", output.data);
|
printf("%s\n", output.data);
|
||||||
termPQExpBuffer(&output);
|
termPQExpBuffer(&output);
|
||||||
|
|
||||||
@@ -1042,8 +1042,9 @@ do_node_check_archive_ready(PGconn *conn, OutputMode mode, CheckStatusList *list
|
|||||||
break;
|
break;
|
||||||
case OM_NAGIOS:
|
case OM_NAGIOS:
|
||||||
case OM_TEXT:
|
case OM_TEXT:
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(
|
||||||
"unable to check archive_status directory");
|
&details,
|
||||||
|
"unable to check archive_status directory");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1171,8 +1172,8 @@ do_node_check_downstream(PGconn *conn, OutputMode mode, CheckStatusList *list_ou
|
|||||||
if (missing_nodes_count == 0)
|
if (missing_nodes_count == 0)
|
||||||
{
|
{
|
||||||
if (expected_nodes_count == 0)
|
if (expected_nodes_count == 0)
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
"this node has no downstream nodes");
|
"this node has no downstream nodes");
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(&details,
|
appendPQExpBuffer(&details,
|
||||||
"%i of %i downstream nodes attached",
|
"%i of %i downstream nodes attached",
|
||||||
@@ -1193,18 +1194,20 @@ do_node_check_downstream(PGconn *conn, OutputMode mode, CheckStatusList *list_ou
|
|||||||
|
|
||||||
if (mode != OM_NAGIOS)
|
if (mode != OM_NAGIOS)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, "; missing: ");
|
appendPQExpBuffer(&details, "; missing: ");
|
||||||
|
|
||||||
for (missing_cell = missing_nodes.head; missing_cell; missing_cell = missing_cell->next)
|
for (missing_cell = missing_nodes.head; missing_cell; missing_cell = missing_cell->next)
|
||||||
{
|
{
|
||||||
if (first == false)
|
if (first == false)
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
", ");
|
", ");
|
||||||
else
|
else
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
if (first == false)
|
if (first == false)
|
||||||
appendPQExpBufferStr(&details, missing_cell->string);
|
appendPQExpBuffer(
|
||||||
|
&details,
|
||||||
|
"%s", missing_cell->string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1304,8 +1307,8 @@ do_node_check_replication_lag(PGconn *conn, OutputMode mode, t_node_info *node_i
|
|||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case OM_OPTFORMAT:
|
case OM_OPTFORMAT:
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
"--lag=0");
|
"--lag=0");
|
||||||
break;
|
break;
|
||||||
case OM_NAGIOS:
|
case OM_NAGIOS:
|
||||||
appendPQExpBuffer(&details,
|
appendPQExpBuffer(&details,
|
||||||
@@ -1316,13 +1319,13 @@ do_node_check_replication_lag(PGconn *conn, OutputMode mode, t_node_info *node_i
|
|||||||
case OM_TEXT:
|
case OM_TEXT:
|
||||||
if (node_info->type == WITNESS)
|
if (node_info->type == WITNESS)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
"N/A - node is witness");
|
"N/A - node is witness");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
"N/A - node is primary");
|
"N/A - node is primary");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1403,8 +1406,9 @@ do_node_check_replication_lag(PGconn *conn, OutputMode mode, t_node_info *node_i
|
|||||||
break;
|
break;
|
||||||
case OM_NAGIOS:
|
case OM_NAGIOS:
|
||||||
case OM_TEXT:
|
case OM_TEXT:
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(
|
||||||
"unable to query replication lag");
|
&details,
|
||||||
|
"unable to query replication lag");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1504,39 +1508,39 @@ do_node_check_role(PGconn *conn, OutputMode mode, t_node_info *node_info, CheckS
|
|||||||
if (recovery_type == RECTYPE_STANDBY)
|
if (recovery_type == RECTYPE_STANDBY)
|
||||||
{
|
{
|
||||||
status = CHECK_STATUS_CRITICAL;
|
status = CHECK_STATUS_CRITICAL;
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
_("node is registered as primary but running as standby"));
|
_("node is registered as primary but running as standby"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
_("node is primary"));
|
_("node is primary"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STANDBY:
|
case STANDBY:
|
||||||
if (recovery_type == RECTYPE_PRIMARY)
|
if (recovery_type == RECTYPE_PRIMARY)
|
||||||
{
|
{
|
||||||
status = CHECK_STATUS_CRITICAL;
|
status = CHECK_STATUS_CRITICAL;
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
_("node is registered as standby but running as primary"));
|
_("node is registered as standby but running as primary"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
_("node is standby"));
|
_("node is standby"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WITNESS:
|
case WITNESS:
|
||||||
if (recovery_type == RECTYPE_STANDBY)
|
if (recovery_type == RECTYPE_STANDBY)
|
||||||
{
|
{
|
||||||
status = CHECK_STATUS_CRITICAL;
|
status = CHECK_STATUS_CRITICAL;
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
_("node is registered as witness but running as standby"));
|
_("node is registered as witness but running as standby"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
_("node is witness"));
|
_("node is witness"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BDR:
|
case BDR:
|
||||||
@@ -1547,8 +1551,8 @@ do_node_check_role(PGconn *conn, OutputMode mode, t_node_info *node_info, CheckS
|
|||||||
if (is_bdr_db(conn, &output) == false)
|
if (is_bdr_db(conn, &output) == false)
|
||||||
{
|
{
|
||||||
status = CHECK_STATUS_CRITICAL;
|
status = CHECK_STATUS_CRITICAL;
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
output.data);
|
"%s", output.data);
|
||||||
}
|
}
|
||||||
termPQExpBuffer(&output);
|
termPQExpBuffer(&output);
|
||||||
|
|
||||||
@@ -1557,13 +1561,13 @@ do_node_check_role(PGconn *conn, OutputMode mode, t_node_info *node_info, CheckS
|
|||||||
if (is_active_bdr_node(conn, node_info->node_name) == false)
|
if (is_active_bdr_node(conn, node_info->node_name) == false)
|
||||||
{
|
{
|
||||||
status = CHECK_STATUS_CRITICAL;
|
status = CHECK_STATUS_CRITICAL;
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
_("node is not an active BDR node"));
|
_("node is not an active BDR node"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
_("node is an active BDR node"));
|
_("node is an active BDR node"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1620,13 +1624,13 @@ do_node_check_slots(PGconn *conn, OutputMode mode, t_node_info *node_info, Check
|
|||||||
|
|
||||||
if (server_version_num < 90400)
|
if (server_version_num < 90400)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
_("replication slots not available for this PostgreSQL version"));
|
_("replication slots not available for this PostgreSQL version"));
|
||||||
}
|
}
|
||||||
else if (node_info->total_replication_slots == 0)
|
else if (node_info->total_replication_slots == 0)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
_("node has no replication slots"));
|
_("node has no replication slots"));
|
||||||
}
|
}
|
||||||
else if (node_info->inactive_replication_slots == 0)
|
else if (node_info->inactive_replication_slots == 0)
|
||||||
{
|
{
|
||||||
@@ -1696,8 +1700,8 @@ do_node_check_missing_slots(PGconn *conn, OutputMode mode, t_node_info *node_inf
|
|||||||
|
|
||||||
if (server_version_num < 90400)
|
if (server_version_num < 90400)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
_("replication slots not available for this PostgreSQL version"));
|
_("replication slots not available for this PostgreSQL version"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1707,8 +1711,9 @@ do_node_check_missing_slots(PGconn *conn, OutputMode mode, t_node_info *node_inf
|
|||||||
|
|
||||||
if (missing_slots.node_count == 0)
|
if (missing_slots.node_count == 0)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
_("node has no missing replication slots"));
|
_("node has no missing replication slots"));
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1723,7 +1728,7 @@ do_node_check_missing_slots(PGconn *conn, OutputMode mode, t_node_info *node_inf
|
|||||||
|
|
||||||
if (missing_slots.node_count)
|
if (missing_slots.node_count)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, ": ");
|
appendPQExpBuffer(&details, ": ");
|
||||||
|
|
||||||
for (missing_slot_cell = missing_slots.head; missing_slot_cell; missing_slot_cell = missing_slot_cell->next)
|
for (missing_slot_cell = missing_slots.head; missing_slot_cell; missing_slot_cell = missing_slot_cell->next)
|
||||||
{
|
{
|
||||||
@@ -1733,10 +1738,10 @@ do_node_check_missing_slots(PGconn *conn, OutputMode mode, t_node_info *node_inf
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details, ", ");
|
appendPQExpBuffer(&details, ", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBufferStr(&details, missing_slot_cell->node_info->slot_name);
|
appendPQExpBuffer(&details, "%s", missing_slot_cell->node_info->slot_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1779,7 +1784,7 @@ do_node_check_missing_slots(PGconn *conn, OutputMode mode, t_node_info *node_inf
|
|||||||
if (list_output != NULL)
|
if (list_output != NULL)
|
||||||
{
|
{
|
||||||
check_status_list_set(list_output,
|
check_status_list_set(list_output,
|
||||||
"Missing replication slots",
|
"Replication slots",
|
||||||
status,
|
status,
|
||||||
details.data);
|
details.data);
|
||||||
}
|
}
|
||||||
@@ -2132,8 +2137,8 @@ do_node_rejoin(void)
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBufferStr(&msg,
|
appendPQExpBuffer(&msg,
|
||||||
_("prerequisites for using pg_rewind are met"));
|
_("prerequisites for using pg_rewind are met"));
|
||||||
|
|
||||||
if (runtime_options.dry_run == true)
|
if (runtime_options.dry_run == true)
|
||||||
{
|
{
|
||||||
@@ -2963,7 +2968,6 @@ do_node_help(void)
|
|||||||
printf(_(" --dry-run show what action would be performed, but don't execute it\n"));
|
printf(_(" --dry-run show what action would be performed, but don't execute it\n"));
|
||||||
printf(_(" --action action to perform (one of \"start\", \"stop\", \"restart\" or \"reload\")\n"));
|
printf(_(" --action action to perform (one of \"start\", \"stop\", \"restart\" or \"reload\")\n"));
|
||||||
printf(_(" --list-actions show what command would be performed for each action\n"));
|
printf(_(" --list-actions show what command would be performed for each action\n"));
|
||||||
printf(_(" --checkpoint issue a CHECKPOINT before stopping or restarting the node\n"));
|
|
||||||
puts("");
|
puts("");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -170,8 +170,8 @@ do_primary_register(void)
|
|||||||
&node_info);
|
&node_info);
|
||||||
if (record_created == true)
|
if (record_created == true)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&event_description,
|
appendPQExpBuffer(&event_description,
|
||||||
"existing primary record updated");
|
"existing primary record updated");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -731,16 +731,16 @@ do_standby_clone(void)
|
|||||||
runtime_options.host,
|
runtime_options.host,
|
||||||
runtime_options.port);
|
runtime_options.port);
|
||||||
|
|
||||||
appendPQExpBufferStr(&event_details,
|
appendPQExpBuffer(&event_details,
|
||||||
_("; backup method: "));
|
_("; backup method: "));
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case pg_basebackup:
|
case pg_basebackup:
|
||||||
appendPQExpBufferStr(&event_details, "pg_basebackup");
|
appendPQExpBuffer(&event_details, "pg_basebackup");
|
||||||
break;
|
break;
|
||||||
case barman:
|
case barman:
|
||||||
appendPQExpBufferStr(&event_details, "barman");
|
appendPQExpBuffer(&event_details, "barman");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1672,12 +1672,12 @@ do_standby_register(void)
|
|||||||
|
|
||||||
if (record_created == false)
|
if (record_created == false)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
"standby registration failed");
|
"standby registration failed");
|
||||||
|
|
||||||
if (runtime_options.force == true)
|
if (runtime_options.force == true)
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
" (-F/--force option was used)");
|
" (-F/--force option was used)");
|
||||||
|
|
||||||
create_event_notification_extended(
|
create_event_notification_extended(
|
||||||
primary_conn,
|
primary_conn,
|
||||||
@@ -1697,12 +1697,12 @@ do_standby_register(void)
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
"standby registration succeeded");
|
"standby registration succeeded");
|
||||||
|
|
||||||
if (runtime_options.force == true)
|
if (runtime_options.force == true)
|
||||||
appendPQExpBufferStr(&details,
|
appendPQExpBuffer(&details,
|
||||||
" (-F/--force option was used)");
|
" (-F/--force option was used)");
|
||||||
|
|
||||||
|
|
||||||
/* Log the event */
|
/* Log the event */
|
||||||
@@ -2771,8 +2771,8 @@ do_standby_follow_internal(PGconn *primary_conn, t_node_info *primary_node_recor
|
|||||||
primary_node_record->node_id,
|
primary_node_record->node_id,
|
||||||
true) == false)
|
true) == false)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(output,
|
appendPQExpBuffer(output,
|
||||||
_("unable to update upstream node"));
|
_("unable to update upstream node"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2788,13 +2788,15 @@ do_standby_follow_internal(PGconn *primary_conn, t_node_info *primary_node_recor
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Perform a switchover by:
|
* Perform a switchover by:
|
||||||
*
|
|
||||||
* - stopping current primary node
|
* - stopping current primary node
|
||||||
* - promoting this standby node to primary
|
* - promoting this standby node to primary
|
||||||
* - forcing the previous primary node to follow this node
|
* - forcing previous primary node to follow this node
|
||||||
*
|
*
|
||||||
* Where running and not already paused, repmgrd will be paused (and
|
* Caveat:
|
||||||
* subsequently unpaused), unless --repmgrd-no-pause provided.
|
* - repmgrd must not be running, otherwise it may
|
||||||
|
* attempt a failover
|
||||||
|
* (TODO: find some way of notifying repmgrd of planned
|
||||||
|
* activity like this)
|
||||||
*
|
*
|
||||||
* TODO:
|
* TODO:
|
||||||
* - make connection test timeouts/intervals configurable (see below)
|
* - make connection test timeouts/intervals configurable (see below)
|
||||||
@@ -2852,11 +2854,6 @@ do_standby_switchover(void)
|
|||||||
|
|
||||||
t_event_info event_info = T_EVENT_INFO_INITIALIZER;
|
t_event_info event_info = T_EVENT_INFO_INITIALIZER;
|
||||||
|
|
||||||
/* used for handling repmgrd pause/unpause */
|
|
||||||
NodeInfoList all_nodes = T_NODE_INFO_LIST_INITIALIZER;
|
|
||||||
RepmgrdInfo **repmgrd_info = NULL;
|
|
||||||
int repmgrd_running_count = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SANITY CHECKS
|
* SANITY CHECKS
|
||||||
*
|
*
|
||||||
@@ -2927,7 +2924,7 @@ do_standby_switchover(void)
|
|||||||
|
|
||||||
if (record_status != RECORD_FOUND)
|
if (record_status != RECORD_FOUND)
|
||||||
{
|
{
|
||||||
log_error(_("unable to retrieve node record for currentr primary (node %i)"),
|
log_error(_("unable to retrieve node record for node %i"),
|
||||||
remote_node_id);
|
remote_node_id);
|
||||||
|
|
||||||
PQfinish(local_conn);
|
PQfinish(local_conn);
|
||||||
@@ -2937,11 +2934,11 @@ do_standby_switchover(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check that there are no exclusive backups running on the primary.
|
* Check that there's no exclusive backups running on the primary.
|
||||||
* We don't want to end up damaging the backup and also leaving the server in an
|
* We don't want to end up damaging the backup and also leaving the server in an
|
||||||
* state where there's control data saying it's in backup mode but there's no
|
* state where there's control data saying it's in backup mode but there's no
|
||||||
* backup_label in PGDATA.
|
* backup_label in PGDATA.
|
||||||
* If the user wants to do the switchover anyway, they should first stop the
|
* If the DBA wants to do the switchover anyway, he should first stop the
|
||||||
* backup that's running.
|
* backup that's running.
|
||||||
*/
|
*/
|
||||||
if (server_in_exclusive_backup_mode(remote_conn) != BACKUP_STATE_NO_BACKUP)
|
if (server_in_exclusive_backup_mode(remote_conn) != BACKUP_STATE_NO_BACKUP)
|
||||||
@@ -2983,7 +2980,6 @@ do_standby_switchover(void)
|
|||||||
{
|
{
|
||||||
min_required_free_slots++;
|
min_required_free_slots++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If --force-rewind specified, check pg_rewind can be used, and
|
* If --force-rewind specified, check pg_rewind can be used, and
|
||||||
* pre-emptively fetch the list of configuration files which should be
|
* pre-emptively fetch the list of configuration files which should be
|
||||||
@@ -3010,8 +3006,8 @@ do_standby_switchover(void)
|
|||||||
termPQExpBuffer(&reason);
|
termPQExpBuffer(&reason);
|
||||||
|
|
||||||
initPQExpBuffer(&msg);
|
initPQExpBuffer(&msg);
|
||||||
appendPQExpBufferStr(&msg,
|
appendPQExpBuffer(&msg,
|
||||||
_("prerequisites for using pg_rewind are met"));
|
_("prerequisites for using pg_rewind are met"));
|
||||||
|
|
||||||
if (runtime_options.dry_run == true)
|
if (runtime_options.dry_run == true)
|
||||||
{
|
{
|
||||||
@@ -3069,7 +3065,7 @@ do_standby_switchover(void)
|
|||||||
initPQExpBuffer(&remote_command_str);
|
initPQExpBuffer(&remote_command_str);
|
||||||
make_remote_repmgr_path(&remote_command_str, &remote_node_record);
|
make_remote_repmgr_path(&remote_command_str, &remote_node_record);
|
||||||
|
|
||||||
appendPQExpBufferStr(&remote_command_str, "--version 2>/dev/null && echo \"1\" || echo \"0\"");
|
appendPQExpBuffer(&remote_command_str, "--version 2>/dev/null && echo \"1\" || echo \"0\"");
|
||||||
initPQExpBuffer(&command_output);
|
initPQExpBuffer(&command_output);
|
||||||
command_success = remote_command(remote_host,
|
command_success = remote_command(remote_host,
|
||||||
runtime_options.remote_user,
|
runtime_options.remote_user,
|
||||||
@@ -3091,8 +3087,8 @@ do_standby_switchover(void)
|
|||||||
termPQExpBuffer(&command_output);
|
termPQExpBuffer(&command_output);
|
||||||
|
|
||||||
initPQExpBuffer(&hint);
|
initPQExpBuffer(&hint);
|
||||||
appendPQExpBufferStr(&hint,
|
appendPQExpBuffer(&hint,
|
||||||
_("check \"pg_bindir\" is set to the correct path in \"repmgr.conf\"; current value: "));
|
_("check \"pg_bindir\" is set to the correct path in \"repmgr.conf\"; current value: "));
|
||||||
|
|
||||||
if (strlen(config_file_options.pg_bindir))
|
if (strlen(config_file_options.pg_bindir))
|
||||||
{
|
{
|
||||||
@@ -3101,8 +3097,8 @@ do_standby_switchover(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&hint,
|
appendPQExpBuffer(&hint,
|
||||||
"(not set)");
|
"(not set)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3349,8 +3345,8 @@ do_standby_switchover(void)
|
|||||||
|
|
||||||
initPQExpBuffer(&remote_command_str);
|
initPQExpBuffer(&remote_command_str);
|
||||||
make_remote_repmgr_path(&remote_command_str, &remote_node_record);
|
make_remote_repmgr_path(&remote_command_str, &remote_node_record);
|
||||||
appendPQExpBufferStr(&remote_command_str,
|
appendPQExpBuffer(&remote_command_str,
|
||||||
"node check --terse -LERROR --archive-ready --optformat");
|
"node check --terse -LERROR --archive-ready --optformat");
|
||||||
|
|
||||||
initPQExpBuffer(&command_output);
|
initPQExpBuffer(&command_output);
|
||||||
|
|
||||||
@@ -3548,8 +3544,8 @@ do_standby_switchover(void)
|
|||||||
|
|
||||||
log_debug("minimum of %i free slots (%i for siblings) required; %i available",
|
log_debug("minimum of %i free slots (%i for siblings) required; %i available",
|
||||||
min_required_free_slots,
|
min_required_free_slots,
|
||||||
reachable_sibling_nodes_with_slot_count,
|
reachable_sibling_nodes_with_slot_count
|
||||||
available_slots);
|
, available_slots);
|
||||||
|
|
||||||
if (available_slots < min_required_free_slots)
|
if (available_slots < min_required_free_slots)
|
||||||
{
|
{
|
||||||
@@ -3579,156 +3575,6 @@ do_standby_switchover(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Attempt to pause all repmgrd instances, unless user explicitly
|
|
||||||
* specifies not to.
|
|
||||||
*/
|
|
||||||
if (runtime_options.repmgrd_no_pause == false)
|
|
||||||
{
|
|
||||||
NodeInfoListCell *cell = NULL;
|
|
||||||
ItemList repmgrd_connection_errors = {NULL, NULL};
|
|
||||||
int i = 0;
|
|
||||||
int unreachable_node_count = 0;
|
|
||||||
|
|
||||||
get_all_node_records(local_conn, &all_nodes);
|
|
||||||
|
|
||||||
repmgrd_info = (RepmgrdInfo **) pg_malloc0(sizeof(RepmgrdInfo *) * all_nodes.node_count);
|
|
||||||
|
|
||||||
for (cell = all_nodes.head; cell; cell = cell->next)
|
|
||||||
{
|
|
||||||
cell->node_info->conn = establish_db_connection_quiet(cell->node_info->conninfo);
|
|
||||||
|
|
||||||
repmgrd_info[i] = pg_malloc0(sizeof(RepmgrdInfo));
|
|
||||||
repmgrd_info[i]->node_id = cell->node_info->node_id;
|
|
||||||
repmgrd_info[i]->pid = UNKNOWN_PID;
|
|
||||||
repmgrd_info[i]->paused = false;
|
|
||||||
repmgrd_info[i]->running = false;
|
|
||||||
|
|
||||||
if (PQstatus(cell->node_info->conn) != CONNECTION_OK)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* unable to connect; treat this as an error
|
|
||||||
*/
|
|
||||||
|
|
||||||
repmgrd_info[i]->pg_running = false;
|
|
||||||
|
|
||||||
item_list_append_format(&repmgrd_connection_errors,
|
|
||||||
_("unable to connect to node \"%s\" (ID %i)"),
|
|
||||||
cell->node_info->node_name,
|
|
||||||
cell->node_info->node_id);
|
|
||||||
|
|
||||||
unreachable_node_count++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
repmgrd_info[i]->running = repmgrd_is_running(cell->node_info->conn);
|
|
||||||
repmgrd_info[i]->pid = repmgrd_get_pid(cell->node_info->conn);
|
|
||||||
repmgrd_info[i]->paused = repmgrd_is_paused(cell->node_info->conn);
|
|
||||||
|
|
||||||
if (repmgrd_info[i]->running == true)
|
|
||||||
repmgrd_running_count++;
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unreachable_node_count > 0)
|
|
||||||
{
|
|
||||||
PQExpBufferData msg;
|
|
||||||
PQExpBufferData detail;
|
|
||||||
ItemListCell *cell;
|
|
||||||
|
|
||||||
initPQExpBuffer(&msg);
|
|
||||||
appendPQExpBuffer(&msg,
|
|
||||||
_("unable to connect to %i node(s), unable to pause all repmgrd instances"),
|
|
||||||
unreachable_node_count);
|
|
||||||
|
|
||||||
initPQExpBuffer(&detail);
|
|
||||||
|
|
||||||
for (cell = repmgrd_connection_errors.head; cell; cell = cell->next)
|
|
||||||
{
|
|
||||||
appendPQExpBuffer(&detail,
|
|
||||||
" %s\n",
|
|
||||||
cell->string);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (runtime_options.force == false)
|
|
||||||
{
|
|
||||||
log_error("%s", msg.data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log_warning("%s", msg.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
log_detail(_("following node(s) unreachable:\n%s"), detail.data);
|
|
||||||
|
|
||||||
termPQExpBuffer(&msg);
|
|
||||||
termPQExpBuffer(&detail);
|
|
||||||
|
|
||||||
/* tell user about footgun */
|
|
||||||
if (runtime_options.force == false)
|
|
||||||
{
|
|
||||||
log_hint(_("use -F/--force to continue anyway"));
|
|
||||||
|
|
||||||
clear_node_info_list(&sibling_nodes);
|
|
||||||
clear_node_info_list(&all_nodes);
|
|
||||||
|
|
||||||
exit(ERR_SWITCHOVER_FAIL);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (repmgrd_running_count > 0)
|
|
||||||
{
|
|
||||||
i = 0;
|
|
||||||
for (cell = all_nodes.head; cell; cell = cell->next)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Skip if node is already paused. Note we won't unpause these, to
|
|
||||||
* leave the repmgrd instances in the cluster in the same state they
|
|
||||||
* were before the switchover.
|
|
||||||
*/
|
|
||||||
if (repmgrd_info[i]->paused == true)
|
|
||||||
{
|
|
||||||
PQfinish(cell->node_info->conn);
|
|
||||||
cell->node_info->conn = NULL;
|
|
||||||
i++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (runtime_options.dry_run == true)
|
|
||||||
{
|
|
||||||
log_info(_("would pause repmgrd on node %s (ID %i)"),
|
|
||||||
cell->node_info->node_name,
|
|
||||||
cell->node_info->node_id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* XXX check result */
|
|
||||||
log_debug("pausing repmgrd on node %s (ID %i)",
|
|
||||||
cell->node_info->node_name,
|
|
||||||
cell->node_info->node_id);
|
|
||||||
|
|
||||||
(void) repmgrd_pause(cell->node_info->conn, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
PQfinish(cell->node_info->conn);
|
|
||||||
cell->node_info->conn = NULL;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* close all connections - we'll reestablish later */
|
|
||||||
for (cell = all_nodes.head; cell; cell = cell->next)
|
|
||||||
{
|
|
||||||
PQfinish(cell->node_info->conn);
|
|
||||||
cell->node_info->conn = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sanity checks completed - prepare for the switchover
|
* Sanity checks completed - prepare for the switchover
|
||||||
@@ -3769,8 +3615,8 @@ do_standby_switchover(void)
|
|||||||
|
|
||||||
if (runtime_options.dry_run == true)
|
if (runtime_options.dry_run == true)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&remote_command_str,
|
appendPQExpBuffer(&remote_command_str,
|
||||||
"node service --terse -LERROR --list-actions --action=stop");
|
"node service --terse -LERROR --list-actions --action=stop");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3778,8 +3624,8 @@ do_standby_switchover(void)
|
|||||||
log_notice(_("stopping current primary node \"%s\" (ID: %i)"),
|
log_notice(_("stopping current primary node \"%s\" (ID: %i)"),
|
||||||
remote_node_record.node_name,
|
remote_node_record.node_name,
|
||||||
remote_node_record.node_id);
|
remote_node_record.node_id);
|
||||||
appendPQExpBufferStr(&remote_command_str,
|
appendPQExpBuffer(&remote_command_str,
|
||||||
"node service --action=stop --checkpoint");
|
"node service --action=stop --checkpoint");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX handle failure */
|
/* XXX handle failure */
|
||||||
@@ -3810,7 +3656,6 @@ do_standby_switchover(void)
|
|||||||
shutdown_command);
|
shutdown_command);
|
||||||
|
|
||||||
clear_node_info_list(&sibling_nodes);
|
clear_node_info_list(&sibling_nodes);
|
||||||
|
|
||||||
key_value_list_free(&remote_config_files);
|
key_value_list_free(&remote_config_files);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -3821,14 +3666,13 @@ do_standby_switchover(void)
|
|||||||
|
|
||||||
/* loop for timeout waiting for current primary to stop */
|
/* loop for timeout waiting for current primary to stop */
|
||||||
|
|
||||||
for (i = 0; i < config_file_options.shutdown_check_timeout; i++)
|
for (i = 0; i < config_file_options.reconnect_attempts; i++)
|
||||||
{
|
{
|
||||||
/* Check whether primary is available */
|
/* Check whether primary is available */
|
||||||
PGPing ping_res;
|
PGPing ping_res;
|
||||||
|
|
||||||
log_info(_("checking for primary shutdown; %i of %i attempts (\"shutdown_check_timeout\")"),
|
log_info(_("checking primary status; %i of %i attempts"),
|
||||||
i + 1, config_file_options.shutdown_check_timeout);
|
i + 1, config_file_options.reconnect_attempts);
|
||||||
|
|
||||||
ping_res = PQping(remote_conninfo);
|
ping_res = PQping(remote_conninfo);
|
||||||
|
|
||||||
log_debug("ping status is: %s", print_pqping_status(ping_res));
|
log_debug("ping status is: %s", print_pqping_status(ping_res));
|
||||||
@@ -3847,8 +3691,8 @@ do_standby_switchover(void)
|
|||||||
|
|
||||||
initPQExpBuffer(&remote_command_str);
|
initPQExpBuffer(&remote_command_str);
|
||||||
make_remote_repmgr_path(&remote_command_str, &remote_node_record);
|
make_remote_repmgr_path(&remote_command_str, &remote_node_record);
|
||||||
appendPQExpBufferStr(&remote_command_str,
|
appendPQExpBuffer(&remote_command_str,
|
||||||
"node status --is-shutdown-cleanly");
|
"node status --is-shutdown-cleanly");
|
||||||
|
|
||||||
initPQExpBuffer(&command_output);
|
initPQExpBuffer(&command_output);
|
||||||
|
|
||||||
@@ -3897,8 +3741,9 @@ do_standby_switchover(void)
|
|||||||
termPQExpBuffer(&command_output);
|
termPQExpBuffer(&command_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_debug("sleeping 1 second until next check");
|
log_debug("sleeping %i seconds (\"reconnect_interval\") until next check",
|
||||||
sleep(1);
|
config_file_options.reconnect_interval);
|
||||||
|
sleep(config_file_options.reconnect_interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shutdown_success == false)
|
if (shutdown_success == false)
|
||||||
@@ -3948,7 +3793,7 @@ do_standby_switchover(void)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If pg_rewind is requested, issue a checkpoint immediately after promoting
|
* if pg_rewind is requested, issue a checkpoint immediately after promoting
|
||||||
* the local node, as pg_rewind compares timelines on the basis of the value
|
* the local node, as pg_rewind compares timelines on the basis of the value
|
||||||
* in pg_control, which is written at the first checkpoint, which might not
|
* in pg_control, which is written at the first checkpoint, which might not
|
||||||
* occur immediately.
|
* occur immediately.
|
||||||
@@ -3960,7 +3805,7 @@ do_standby_switchover(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Execute "repmgr node rejoin" to create recovery.conf and start the
|
* Execute `repmgr node rejoin` to create recovery.conf and start the
|
||||||
* remote server. Additionally execute "pg_rewind", if required and
|
* remote server. Additionally execute "pg_rewind", if required and
|
||||||
* requested.
|
* requested.
|
||||||
*/
|
*/
|
||||||
@@ -3974,13 +3819,12 @@ do_standby_switchover(void)
|
|||||||
{
|
{
|
||||||
log_error(_("new primary diverges from former primary and --force-rewind not provided"));
|
log_error(_("new primary diverges from former primary and --force-rewind not provided"));
|
||||||
log_hint(_("the former primary will need to be restored manually, or use \"repmgr node rejoin\""));
|
log_hint(_("the former primary will need to be restored manually, or use \"repmgr node rejoin\""));
|
||||||
|
|
||||||
termPQExpBuffer(&node_rejoin_options);
|
termPQExpBuffer(&node_rejoin_options);
|
||||||
PQfinish(local_conn);
|
PQfinish(local_conn);
|
||||||
exit(ERR_SWITCHOVER_FAIL);
|
exit(ERR_SWITCHOVER_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBufferStr(&node_rejoin_options,
|
appendPQExpBuffer(&node_rejoin_options,
|
||||||
" --force-rewind");
|
" --force-rewind");
|
||||||
|
|
||||||
if (runtime_options.force_rewind_path[0] != '\0')
|
if (runtime_options.force_rewind_path[0] != '\0')
|
||||||
@@ -3989,20 +3833,20 @@ do_standby_switchover(void)
|
|||||||
"=%s",
|
"=%s",
|
||||||
runtime_options.force_rewind_path);
|
runtime_options.force_rewind_path);
|
||||||
}
|
}
|
||||||
appendPQExpBufferStr(&node_rejoin_options,
|
appendPQExpBuffer(&node_rejoin_options,
|
||||||
" --config-files=");
|
" --config-files=");
|
||||||
|
|
||||||
for (cell = remote_config_files.head; cell; cell = cell->next)
|
for (cell = remote_config_files.head; cell; cell = cell->next)
|
||||||
{
|
{
|
||||||
if (first_entry == false)
|
if (first_entry == false)
|
||||||
appendPQExpBufferChar(&node_rejoin_options, ',');
|
appendPQExpBuffer(&node_rejoin_options, ",");
|
||||||
else
|
else
|
||||||
first_entry = false;
|
first_entry = false;
|
||||||
|
|
||||||
appendPQExpBufferStr(&node_rejoin_options, cell->key);
|
appendPQExpBuffer(&node_rejoin_options, "%s", cell->key);
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBufferChar(&node_rejoin_options, ' ');
|
appendPQExpBuffer(&node_rejoin_options, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
key_value_list_free(&remote_config_files);
|
key_value_list_free(&remote_config_files);
|
||||||
@@ -4031,7 +3875,7 @@ do_standby_switchover(void)
|
|||||||
|
|
||||||
if (command_success == false)
|
if (command_success == false)
|
||||||
{
|
{
|
||||||
log_error(_("rejoin failed with error code %i"), r);
|
log_error(_("rejoin failed %i"), r);
|
||||||
|
|
||||||
create_event_notification_extended(local_conn,
|
create_event_notification_extended(local_conn,
|
||||||
&config_file_options,
|
&config_file_options,
|
||||||
@@ -4096,32 +3940,14 @@ do_standby_switchover(void)
|
|||||||
|
|
||||||
if (sibling_node_record.type == WITNESS)
|
if (sibling_node_record.type == WITNESS)
|
||||||
{
|
{
|
||||||
PGconn *witness_conn = NULL;
|
|
||||||
|
|
||||||
/* TODO: create "repmgr witness resync" or similar */
|
|
||||||
appendPQExpBuffer(&remote_command_str,
|
appendPQExpBuffer(&remote_command_str,
|
||||||
"witness register -d \\'%s\\' --force 2>/dev/null && echo \"1\" || echo \"0\"",
|
"witness register -d \\'%s\\' --force 2>/dev/null && echo \"1\" || echo \"0\"",
|
||||||
local_node_record.conninfo);
|
local_node_record.conninfo);
|
||||||
|
|
||||||
/*
|
|
||||||
* Notify the witness repmgrd about the new primary, as at this point it will be assuming
|
|
||||||
* a failover situation is in place. It will detect the new primary at some point, this
|
|
||||||
* just speeds up the process.
|
|
||||||
*
|
|
||||||
* In the unlikely event repmgrd is not running or not in use, this will have no effect.
|
|
||||||
*/
|
|
||||||
witness_conn = establish_db_connection_quiet(cell->node_info->conninfo);
|
|
||||||
|
|
||||||
if (PQstatus(witness_conn) == CONNECTION_OK)
|
|
||||||
{
|
|
||||||
notify_follow_primary(witness_conn, local_node_record.node_id);
|
|
||||||
}
|
|
||||||
PQfinish(witness_conn);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&remote_command_str,
|
appendPQExpBuffer(&remote_command_str,
|
||||||
"standby follow 2>/dev/null && echo \"1\" || echo \"0\"");
|
"standby follow 2>/dev/null && echo \"1\" || echo \"0\"");
|
||||||
}
|
}
|
||||||
get_conninfo_value(cell->node_info->conninfo, "host", host);
|
get_conninfo_value(cell->node_info->conninfo, "host", host);
|
||||||
log_debug("executing:\n %s", remote_command_str.data);
|
log_debug("executing:\n %s", remote_command_str.data);
|
||||||
@@ -4174,8 +4000,8 @@ do_standby_switchover(void)
|
|||||||
PQfinish(local_conn);
|
PQfinish(local_conn);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clean up remote node (primary demoted to standby). It's possible that the node is
|
* Clean up remote node. It's possible that the standby is still starting up,
|
||||||
* still starting up, so poll for a while until we get a connection.
|
* so poll for a while until we get a connection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (i = 0; i < config_file_options.standby_reconnect_timeout; i++)
|
for (i = 0; i < config_file_options.standby_reconnect_timeout; i++)
|
||||||
@@ -4227,84 +4053,6 @@ do_standby_switchover(void)
|
|||||||
|
|
||||||
PQfinish(remote_conn);
|
PQfinish(remote_conn);
|
||||||
|
|
||||||
/*
|
|
||||||
* Attempt to unpause all paused repmgrd instances, unless user explicitly
|
|
||||||
* specifies not to.
|
|
||||||
*/
|
|
||||||
if (runtime_options.repmgrd_no_pause == false)
|
|
||||||
{
|
|
||||||
if (repmgrd_running_count > 0)
|
|
||||||
{
|
|
||||||
ItemList repmgrd_unpause_errors = {NULL, NULL};
|
|
||||||
NodeInfoListCell *cell = NULL;
|
|
||||||
int i = 0;
|
|
||||||
int error_node_count = 0;
|
|
||||||
|
|
||||||
for (cell = all_nodes.head; cell; cell = cell->next)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (repmgrd_info[i]->paused == true)
|
|
||||||
{
|
|
||||||
log_debug("repmgrd on node %s (ID %i) paused before switchover, not unpausing",
|
|
||||||
cell->node_info->node_name,
|
|
||||||
cell->node_info->node_id);
|
|
||||||
|
|
||||||
i++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_debug("unpausing repmgrd on node %s (ID %i)",
|
|
||||||
cell->node_info->node_name,
|
|
||||||
cell->node_info->node_id);
|
|
||||||
|
|
||||||
cell->node_info->conn = establish_db_connection_quiet(cell->node_info->conninfo);
|
|
||||||
|
|
||||||
if (PQstatus(cell->node_info->conn) == CONNECTION_OK)
|
|
||||||
{
|
|
||||||
if (repmgrd_pause(cell->node_info->conn, false) == false)
|
|
||||||
{
|
|
||||||
item_list_append_format(&repmgrd_unpause_errors,
|
|
||||||
_("unable to unpause node \"%s\" (ID %i)"),
|
|
||||||
cell->node_info->node_name,
|
|
||||||
cell->node_info->node_id);
|
|
||||||
error_node_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
item_list_append_format(&repmgrd_unpause_errors,
|
|
||||||
_("unable to connect to node \"%s\" (ID %i)"),
|
|
||||||
cell->node_info->node_name,
|
|
||||||
cell->node_info->node_id);
|
|
||||||
error_node_count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error_node_count > 0)
|
|
||||||
{
|
|
||||||
PQExpBufferData detail;
|
|
||||||
ItemListCell *cell;
|
|
||||||
|
|
||||||
for (cell = repmgrd_unpause_errors.head; cell; cell = cell->next)
|
|
||||||
{
|
|
||||||
appendPQExpBuffer(&detail,
|
|
||||||
" %s\n",
|
|
||||||
cell->string);
|
|
||||||
}
|
|
||||||
|
|
||||||
log_warning(_("unable to unpause repmgrd on %i node(s)"),
|
|
||||||
error_node_count);
|
|
||||||
log_detail(_("errors encountered for following node(s):\n%s"), detail.data);
|
|
||||||
log_hint(_("check node connection and status; unpause manually with \"repmgr daemon unpause\""));
|
|
||||||
|
|
||||||
termPQExpBuffer(&detail);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clear_node_info_list(&all_nodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (switchover_success == true)
|
if (switchover_success == true)
|
||||||
{
|
{
|
||||||
@@ -4397,7 +4145,7 @@ check_source_server()
|
|||||||
* to be used as a standalone clone tool)
|
* to be used as a standalone clone tool)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extension_status = get_repmgr_extension_status(primary_conn, NULL);
|
extension_status = get_repmgr_extension_status(primary_conn);
|
||||||
|
|
||||||
if (extension_status != REPMGR_INSTALLED)
|
if (extension_status != REPMGR_INSTALLED)
|
||||||
{
|
{
|
||||||
@@ -5277,7 +5025,7 @@ run_basebackup(t_node_info *node_record)
|
|||||||
|
|
||||||
if (runtime_options.fast_checkpoint)
|
if (runtime_options.fast_checkpoint)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(¶ms, " -c fast");
|
appendPQExpBuffer(¶ms, " -c fast");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_file_options.tablespace_mapping.head != NULL)
|
if (config_file_options.tablespace_mapping.head != NULL)
|
||||||
@@ -5299,7 +5047,7 @@ run_basebackup(t_node_info *node_record)
|
|||||||
*/
|
*/
|
||||||
if (!strlen(backup_options.xlog_method))
|
if (!strlen(backup_options.xlog_method))
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(¶ms, " -X stream");
|
appendPQExpBuffer(¶ms, " -X stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -6339,8 +6087,8 @@ create_recovery_file(t_node_info *node_record, t_conninfo_param_list *recovery_c
|
|||||||
initPQExpBuffer(&recovery_file_buf);
|
initPQExpBuffer(&recovery_file_buf);
|
||||||
|
|
||||||
/* standby_mode = 'on' */
|
/* standby_mode = 'on' */
|
||||||
appendPQExpBufferStr(&recovery_file_buf,
|
appendPQExpBuffer(&recovery_file_buf,
|
||||||
"standby_mode = 'on'\n");
|
"standby_mode = 'on'\n");
|
||||||
|
|
||||||
/* primary_conninfo = '...' */
|
/* primary_conninfo = '...' */
|
||||||
|
|
||||||
@@ -6368,8 +6116,8 @@ create_recovery_file(t_node_info *node_record, t_conninfo_param_list *recovery_c
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* recovery_target_timeline = 'latest' */
|
/* recovery_target_timeline = 'latest' */
|
||||||
appendPQExpBufferStr(&recovery_file_buf,
|
appendPQExpBuffer(&recovery_file_buf,
|
||||||
"recovery_target_timeline = 'latest'\n");
|
"recovery_target_timeline = 'latest'\n");
|
||||||
|
|
||||||
|
|
||||||
/* recovery_min_apply_delay = ... (optional) */
|
/* recovery_min_apply_delay = ... (optional) */
|
||||||
@@ -6502,12 +6250,12 @@ write_primary_conninfo(PQExpBufferData *dest, t_conninfo_param_list *param_list)
|
|||||||
{
|
{
|
||||||
if (strlen(config_file_options.node_name))
|
if (strlen(config_file_options.node_name))
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&conninfo_buf, " application_name=");
|
appendPQExpBuffer(&conninfo_buf, " application_name=");
|
||||||
appendConnStrVal(&conninfo_buf, config_file_options.node_name);
|
appendConnStrVal(&conninfo_buf, config_file_options.node_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&conninfo_buf, " application_name=repmgr");
|
appendPQExpBuffer(&conninfo_buf, " application_name=repmgr");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6520,7 +6268,7 @@ write_primary_conninfo(PQExpBufferData *dest, t_conninfo_param_list *param_list)
|
|||||||
|
|
||||||
if (password != NULL)
|
if (password != NULL)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&conninfo_buf, " password=");
|
appendPQExpBuffer(&conninfo_buf, " password=");
|
||||||
appendConnStrVal(&conninfo_buf, password);
|
appendConnStrVal(&conninfo_buf, password);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6532,7 +6280,7 @@ write_primary_conninfo(PQExpBufferData *dest, t_conninfo_param_list *param_list)
|
|||||||
/* check if the libpq we're using supports "passfile=" */
|
/* check if the libpq we're using supports "passfile=" */
|
||||||
if (has_passfile() == true)
|
if (has_passfile() == true)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(&conninfo_buf, " passfile=");
|
appendPQExpBuffer(&conninfo_buf, " passfile=");
|
||||||
appendConnStrVal(&conninfo_buf, config_file_options.passfile);
|
appendConnStrVal(&conninfo_buf, config_file_options.passfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6854,7 +6602,6 @@ do_standby_help(void)
|
|||||||
printf(_(" (9.3 and 9.4 - provide \"pg_rewind\" path)\n"));
|
printf(_(" (9.3 and 9.4 - provide \"pg_rewind\" path)\n"));
|
||||||
|
|
||||||
printf(_(" -R, --remote-user=USERNAME database server username for SSH operations (default: \"%s\")\n"), runtime_options.username);
|
printf(_(" -R, --remote-user=USERNAME database server username for SSH operations (default: \"%s\")\n"), runtime_options.username);
|
||||||
printf(_(" --repmgrd-no-pause don't pause repmgrd\n"));
|
|
||||||
printf(_(" --siblings-follow have other standbys follow new primary\n"));
|
printf(_(" --siblings-follow have other standbys follow new primary\n"));
|
||||||
|
|
||||||
puts("");
|
puts("");
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ do_witness_register(void)
|
|||||||
PGconn *witness_conn = NULL;
|
PGconn *witness_conn = NULL;
|
||||||
PGconn *primary_conn = NULL;
|
PGconn *primary_conn = NULL;
|
||||||
RecoveryType recovery_type = RECTYPE_UNKNOWN;
|
RecoveryType recovery_type = RECTYPE_UNKNOWN;
|
||||||
ExtensionStatus extension_status = REPMGR_UNKNOWN;
|
|
||||||
NodeInfoList nodes = T_NODE_INFO_LIST_INITIALIZER;
|
NodeInfoList nodes = T_NODE_INFO_LIST_INITIALIZER;
|
||||||
t_node_info node_record = T_NODE_INFO_INITIALIZER;
|
t_node_info node_record = T_NODE_INFO_INITIALIZER;
|
||||||
RecordStatus record_status = RECORD_NOT_FOUND;
|
RecordStatus record_status = RECORD_NOT_FOUND;
|
||||||
@@ -215,46 +214,28 @@ do_witness_register(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension_status = get_repmgr_extension_status(witness_conn, NULL);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if the witness database already contains node records;
|
* if repmgr.nodes contains entries, delete if -F/--force provided,
|
||||||
* only do this if the extension is actually installed.
|
* otherwise exit with error
|
||||||
*/
|
*/
|
||||||
if (extension_status == REPMGR_INSTALLED
|
get_all_node_records(witness_conn, &nodes);
|
||||||
|| extension_status == REPMGR_OLD_VERSION_INSTALLED)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* if repmgr.nodes contains entries, exit with error unless
|
|
||||||
* -F/--force provided (which will cause the existing records
|
|
||||||
* to be overwritten)
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (get_all_node_records(witness_conn, &nodes) == false)
|
log_verbose(LOG_DEBUG, "%i node records found", nodes.node_count);
|
||||||
|
|
||||||
|
if (nodes.node_count > 0)
|
||||||
|
{
|
||||||
|
if (!runtime_options.force)
|
||||||
{
|
{
|
||||||
/* get_all_node_records() will display the error */
|
log_error(_("witness node is already initialised and contains node records"));
|
||||||
PQfinish(witness_conn);
|
log_hint(_("use option -F/--force to reinitialise the node"));
|
||||||
PQfinish(primary_conn);
|
PQfinish(primary_conn);
|
||||||
|
PQfinish(witness_conn);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "%i node records found", nodes.node_count);
|
|
||||||
|
|
||||||
if (nodes.node_count > 0)
|
|
||||||
{
|
|
||||||
if (!runtime_options.force)
|
|
||||||
{
|
|
||||||
log_error(_("witness node is already initialised and contains node records"));
|
|
||||||
log_hint(_("use option -F/--force to reinitialise the node"));
|
|
||||||
PQfinish(primary_conn);
|
|
||||||
PQfinish(witness_conn);
|
|
||||||
exit(ERR_BAD_CONFIG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clear_node_info_list(&nodes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear_node_info_list(&nodes);
|
||||||
|
|
||||||
if (runtime_options.dry_run == true)
|
if (runtime_options.dry_run == true)
|
||||||
{
|
{
|
||||||
log_info(_("prerequisites for registering the witness node are met"));
|
log_info(_("prerequisites for registering the witness node are met"));
|
||||||
@@ -484,15 +465,13 @@ void do_witness_help(void)
|
|||||||
printf(_("Usage:\n"));
|
printf(_("Usage:\n"));
|
||||||
printf(_(" %s [OPTIONS] witness register\n"), progname());
|
printf(_(" %s [OPTIONS] witness register\n"), progname());
|
||||||
printf(_(" %s [OPTIONS] witness unregister\n"), progname());
|
printf(_(" %s [OPTIONS] witness unregister\n"), progname());
|
||||||
puts("");
|
|
||||||
printf(_("WITNESS REGISTER\n"));
|
printf(_("WITNESS REGISTER\n"));
|
||||||
puts("");
|
puts("");
|
||||||
printf(_(" \"witness register\" registers a witness node.\n"));
|
printf(_(" \"witness register\" registers a witness node.\n"));
|
||||||
puts("");
|
puts("");
|
||||||
printf(_(" Requires provision of connection information for the primary node,\n"));
|
printf(_(" Requires provision of connection information for the primary\n"));
|
||||||
printf(_(" typically usually just the host name.\n"));
|
|
||||||
puts("");
|
puts("");
|
||||||
printf(_(" -h/--host host name of the primary node\n"));
|
|
||||||
printf(_(" --dry-run check prerequisites but don't make any changes\n"));
|
printf(_(" --dry-run check prerequisites but don't make any changes\n"));
|
||||||
printf(_(" -F, --force overwrite an existing node record\n"));
|
printf(_(" -F, --force overwrite an existing node record\n"));
|
||||||
puts("");
|
puts("");
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ typedef struct
|
|||||||
bool force_rewind_used;
|
bool force_rewind_used;
|
||||||
char force_rewind_path[MAXPGPATH];
|
char force_rewind_path[MAXPGPATH];
|
||||||
bool siblings_follow;
|
bool siblings_follow;
|
||||||
bool repmgrd_no_pause;
|
|
||||||
|
|
||||||
/* "node status" options */
|
/* "node status" options */
|
||||||
bool is_shutdown_cleanly;
|
bool is_shutdown_cleanly;
|
||||||
@@ -157,7 +156,7 @@ typedef struct
|
|||||||
/* "standby register" options */ \
|
/* "standby register" options */ \
|
||||||
false, -1, DEFAULT_WAIT_START, \
|
false, -1, DEFAULT_WAIT_START, \
|
||||||
/* "standby switchover" options */ \
|
/* "standby switchover" options */ \
|
||||||
false, false, "", false, false, \
|
false, false, "", false, \
|
||||||
/* "node status" options */ \
|
/* "node status" options */ \
|
||||||
false, \
|
false, \
|
||||||
/* "node check" options */ \
|
/* "node check" options */ \
|
||||||
@@ -194,14 +193,6 @@ typedef enum
|
|||||||
} t_server_action;
|
} t_server_action;
|
||||||
|
|
||||||
|
|
||||||
typedef struct ColHeader
|
|
||||||
{
|
|
||||||
char title[MAXLEN];
|
|
||||||
int max_length;
|
|
||||||
int cur_length;
|
|
||||||
} ColHeader;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* global configuration structures */
|
/* global configuration structures */
|
||||||
extern t_runtime_options runtime_options;
|
extern t_runtime_options runtime_options;
|
||||||
@@ -237,10 +228,7 @@ extern void get_superuser_connection(PGconn **conn, PGconn **superuser_conn, PGc
|
|||||||
extern bool remote_command(const char *host, const char *user, const char *command, PQExpBufferData *outputbuf);
|
extern bool remote_command(const char *host, const char *user, const char *command, PQExpBufferData *outputbuf);
|
||||||
|
|
||||||
extern void make_remote_repmgr_path(PQExpBufferData *outputbuf, t_node_info *remote_node_record);
|
extern void make_remote_repmgr_path(PQExpBufferData *outputbuf, t_node_info *remote_node_record);
|
||||||
|
|
||||||
/* display functions */
|
|
||||||
extern void print_help_header(void);
|
extern void print_help_header(void);
|
||||||
extern void print_status_header(int cols, ColHeader *headers);
|
|
||||||
|
|
||||||
/* server control functions */
|
/* server control functions */
|
||||||
extern void get_server_action(t_server_action action, char *script, char *data_dir);
|
extern void get_server_action(t_server_action action, char *script, char *data_dir);
|
||||||
|
|||||||
144
repmgr-client.c
144
repmgr-client.c
@@ -29,14 +29,11 @@
|
|||||||
*
|
*
|
||||||
* NODE STATUS
|
* NODE STATUS
|
||||||
* NODE CHECK
|
* NODE CHECK
|
||||||
|
*
|
||||||
|
* For internal use:
|
||||||
* NODE REJOIN
|
* NODE REJOIN
|
||||||
* NODE SERVICE
|
* NODE SERVICE
|
||||||
*
|
*
|
||||||
* DAEMON STATUS
|
|
||||||
* DAEMON PAUSE
|
|
||||||
* DAEMON UNPAUSE
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
@@ -65,7 +62,6 @@
|
|||||||
#include "repmgr-action-bdr.h"
|
#include "repmgr-action-bdr.h"
|
||||||
#include "repmgr-action-node.h"
|
#include "repmgr-action-node.h"
|
||||||
#include "repmgr-action-cluster.h"
|
#include "repmgr-action-cluster.h"
|
||||||
#include "repmgr-action-daemon.h"
|
|
||||||
|
|
||||||
#include <storage/fd.h> /* for PG_TEMP_FILE_PREFIX */
|
#include <storage/fd.h> /* for PG_TEMP_FILE_PREFIX */
|
||||||
|
|
||||||
@@ -442,10 +438,6 @@ main(int argc, char **argv)
|
|||||||
runtime_options.siblings_follow = true;
|
runtime_options.siblings_follow = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPT_REPMGRD_NO_PAUSE:
|
|
||||||
runtime_options.repmgrd_no_pause = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
/*----------------------
|
/*----------------------
|
||||||
* "node status" options
|
* "node status" options
|
||||||
*----------------------
|
*----------------------
|
||||||
@@ -774,7 +766,6 @@ main(int argc, char **argv)
|
|||||||
* BDR { REGISTER | UNREGISTER } |
|
* BDR { REGISTER | UNREGISTER } |
|
||||||
* NODE { STATUS | CHECK | REJOIN | SERVICE } |
|
* NODE { STATUS | CHECK | REJOIN | SERVICE } |
|
||||||
* CLUSTER { CROSSCHECK | MATRIX | SHOW | EVENT | CLEANUP }
|
* CLUSTER { CROSSCHECK | MATRIX | SHOW | EVENT | CLEANUP }
|
||||||
* DAEMON { STATUS | PAUSE | UNPAUSE }
|
|
||||||
*
|
*
|
||||||
* [node] is an optional hostname, provided instead of the -h/--host
|
* [node] is an optional hostname, provided instead of the -h/--host
|
||||||
* option
|
* option
|
||||||
@@ -808,7 +799,6 @@ main(int argc, char **argv)
|
|||||||
action = PRIMARY_REGISTER;
|
action = PRIMARY_REGISTER;
|
||||||
else if (strcasecmp(repmgr_action, "UNREGISTER") == 0)
|
else if (strcasecmp(repmgr_action, "UNREGISTER") == 0)
|
||||||
action = PRIMARY_UNREGISTER;
|
action = PRIMARY_UNREGISTER;
|
||||||
/* allow "primary check"/"primary status" as aliases for "node check"/"node status" */
|
|
||||||
else if (strcasecmp(repmgr_action, "CHECK") == 0)
|
else if (strcasecmp(repmgr_action, "CHECK") == 0)
|
||||||
action = NODE_CHECK;
|
action = NODE_CHECK;
|
||||||
else if (strcasecmp(repmgr_action, "STATUS") == 0)
|
else if (strcasecmp(repmgr_action, "STATUS") == 0)
|
||||||
@@ -835,7 +825,6 @@ main(int argc, char **argv)
|
|||||||
action = STANDBY_FOLLOW;
|
action = STANDBY_FOLLOW;
|
||||||
else if (strcasecmp(repmgr_action, "SWITCHOVER") == 0)
|
else if (strcasecmp(repmgr_action, "SWITCHOVER") == 0)
|
||||||
action = STANDBY_SWITCHOVER;
|
action = STANDBY_SWITCHOVER;
|
||||||
/* allow "standby check"/"standby status" as aliases for "node check"/"node status" */
|
|
||||||
else if (strcasecmp(repmgr_action, "CHECK") == 0)
|
else if (strcasecmp(repmgr_action, "CHECK") == 0)
|
||||||
action = NODE_CHECK;
|
action = NODE_CHECK;
|
||||||
else if (strcasecmp(repmgr_action, "STATUS") == 0)
|
else if (strcasecmp(repmgr_action, "STATUS") == 0)
|
||||||
@@ -911,21 +900,6 @@ main(int argc, char **argv)
|
|||||||
else if (strcasecmp(repmgr_action, "CLEANUP") == 0)
|
else if (strcasecmp(repmgr_action, "CLEANUP") == 0)
|
||||||
action = CLUSTER_CLEANUP;
|
action = CLUSTER_CLEANUP;
|
||||||
}
|
}
|
||||||
else if (strcasecmp(repmgr_command, "DAEMON") == 0)
|
|
||||||
{
|
|
||||||
if (help_option == true)
|
|
||||||
{
|
|
||||||
do_daemon_help();
|
|
||||||
exit(SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcasecmp(repmgr_action, "STATUS") == 0)
|
|
||||||
action = DAEMON_STATUS;
|
|
||||||
else if (strcasecmp(repmgr_action, "PAUSE") == 0)
|
|
||||||
action = DAEMON_PAUSE;
|
|
||||||
else if (strcasecmp(repmgr_action, "UNPAUSE") == 0)
|
|
||||||
action = DAEMON_UNPAUSE;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
valid_repmgr_command_found = false;
|
valid_repmgr_command_found = false;
|
||||||
@@ -1324,17 +1298,6 @@ main(int argc, char **argv)
|
|||||||
do_cluster_cleanup();
|
do_cluster_cleanup();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* DAEMON */
|
|
||||||
case DAEMON_STATUS:
|
|
||||||
do_daemon_status();
|
|
||||||
break;
|
|
||||||
case DAEMON_PAUSE:
|
|
||||||
do_daemon_pause();
|
|
||||||
break;
|
|
||||||
case DAEMON_UNPAUSE:
|
|
||||||
do_daemon_unpause();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* An action will have been determined by this point */
|
/* An action will have been determined by this point */
|
||||||
break;
|
break;
|
||||||
@@ -1399,7 +1362,7 @@ check_cli_parameters(const int action)
|
|||||||
if (!runtime_options.host_param_provided)
|
if (!runtime_options.host_param_provided)
|
||||||
{
|
{
|
||||||
item_list_append_format(&cli_errors,
|
item_list_append_format(&cli_errors,
|
||||||
_("host name for the source node must be provided with -h/--host when executing %s"),
|
_("host name for the source node must be provided when executing %s"),
|
||||||
action_name(action));
|
action_name(action));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1456,7 +1419,7 @@ check_cli_parameters(const int action)
|
|||||||
if (!runtime_options.host_param_provided)
|
if (!runtime_options.host_param_provided)
|
||||||
{
|
{
|
||||||
item_list_append_format(&cli_errors,
|
item_list_append_format(&cli_errors,
|
||||||
_("host name for the source node must be provided with -h/--host when executing %s"),
|
_("host name for the source node must be provided when executing %s"),
|
||||||
action_name(action));
|
action_name(action));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1557,7 +1520,6 @@ check_cli_parameters(const int action)
|
|||||||
case PRIMARY_UNREGISTER:
|
case PRIMARY_UNREGISTER:
|
||||||
case STANDBY_UNREGISTER:
|
case STANDBY_UNREGISTER:
|
||||||
case WITNESS_UNREGISTER:
|
case WITNESS_UNREGISTER:
|
||||||
case CLUSTER_CLEANUP:
|
|
||||||
case CLUSTER_EVENT:
|
case CLUSTER_EVENT:
|
||||||
case CLUSTER_MATRIX:
|
case CLUSTER_MATRIX:
|
||||||
case CLUSTER_CROSSCHECK:
|
case CLUSTER_CROSSCHECK:
|
||||||
@@ -1781,18 +1743,6 @@ check_cli_parameters(const int action)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runtime_options.repmgrd_no_pause == true)
|
|
||||||
{
|
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case STANDBY_SWITCHOVER:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
item_list_append_format(&cli_warnings,
|
|
||||||
_("--repmgrd-no-pause will be ignored when executing %s"),
|
|
||||||
action_name(action));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (runtime_options.config_files[0] != '\0')
|
if (runtime_options.config_files[0] != '\0')
|
||||||
{
|
{
|
||||||
@@ -1821,8 +1771,6 @@ check_cli_parameters(const int action)
|
|||||||
case WITNESS_UNREGISTER:
|
case WITNESS_UNREGISTER:
|
||||||
case NODE_REJOIN:
|
case NODE_REJOIN:
|
||||||
case NODE_SERVICE:
|
case NODE_SERVICE:
|
||||||
case DAEMON_PAUSE:
|
|
||||||
case DAEMON_UNPAUSE:
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
item_list_append_format(&cli_warnings,
|
item_list_append_format(&cli_warnings,
|
||||||
@@ -1902,14 +1850,6 @@ action_name(const int action)
|
|||||||
return "CLUSTER MATRIX";
|
return "CLUSTER MATRIX";
|
||||||
case CLUSTER_CROSSCHECK:
|
case CLUSTER_CROSSCHECK:
|
||||||
return "CLUSTER CROSSCHECK";
|
return "CLUSTER CROSSCHECK";
|
||||||
|
|
||||||
case DAEMON_STATUS:
|
|
||||||
return "DAEMON STATUS";
|
|
||||||
case DAEMON_PAUSE:
|
|
||||||
return "DAEMON PAUSE";
|
|
||||||
case DAEMON_UNPAUSE:
|
|
||||||
return "DAEMON UNPAUSE";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "UNKNOWN ACTION";
|
return "UNKNOWN ACTION";
|
||||||
@@ -1937,42 +1877,6 @@ print_error_list(ItemList *error_list, int log_level)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
print_status_header(int cols, ColHeader *headers)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < cols; i++)
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
printf(" ");
|
|
||||||
else
|
|
||||||
printf(" | ");
|
|
||||||
|
|
||||||
printf("%-*s",
|
|
||||||
headers[i].max_length,
|
|
||||||
headers[i].title);
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
printf("-");
|
|
||||||
|
|
||||||
for (i = 0; i < cols; i++)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
for (j = 0; j < headers[i].max_length; j++)
|
|
||||||
printf("-");
|
|
||||||
|
|
||||||
if (i < (cols - 1))
|
|
||||||
printf("-+-");
|
|
||||||
else
|
|
||||||
printf("-");
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
print_help_header(void)
|
print_help_header(void)
|
||||||
{
|
{
|
||||||
@@ -2001,11 +1905,10 @@ do_help(void)
|
|||||||
printf(_(" %s [OPTIONS] node {status|check|rejoin|service}\n"), progname());
|
printf(_(" %s [OPTIONS] node {status|check|rejoin|service}\n"), progname());
|
||||||
printf(_(" %s [OPTIONS] cluster {show|event|matrix|crosscheck|cleanup}\n"), progname());
|
printf(_(" %s [OPTIONS] cluster {show|event|matrix|crosscheck|cleanup}\n"), progname());
|
||||||
printf(_(" %s [OPTIONS] witness {register|unregister}\n"), progname());
|
printf(_(" %s [OPTIONS] witness {register|unregister}\n"), progname());
|
||||||
printf(_(" %s [OPTIONS] daemon {status|pause|unpause}\n"), progname());
|
|
||||||
|
|
||||||
puts("");
|
puts("");
|
||||||
|
|
||||||
printf(_(" Execute \"%s {primary|standby|bdr|node|cluster|witness|daemon} --help\" to see command-specific options\n"), progname());
|
printf(_(" Execute \"%s {primary|standby|bdr|node|cluster} --help\" to see command-specific options\n"), progname());
|
||||||
|
|
||||||
puts("");
|
puts("");
|
||||||
|
|
||||||
@@ -2053,6 +1956,8 @@ do_help(void)
|
|||||||
printf(_(" -t, --terse don't display detail, hints and other non-critical output\n"));
|
printf(_(" -t, --terse don't display detail, hints and other non-critical output\n"));
|
||||||
printf(_(" -v, --verbose display additional log output (useful for debugging)\n"));
|
printf(_(" -v, --verbose display additional log output (useful for debugging)\n"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
puts("");
|
puts("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2079,9 +1984,8 @@ create_repmgr_extension(PGconn *conn)
|
|||||||
bool is_superuser = false;
|
bool is_superuser = false;
|
||||||
PGconn *superuser_conn = NULL;
|
PGconn *superuser_conn = NULL;
|
||||||
PGconn *schema_create_conn = NULL;
|
PGconn *schema_create_conn = NULL;
|
||||||
t_extension_versions extversions = T_EXTENSION_VERSIONS_INITIALIZER;
|
|
||||||
|
|
||||||
extension_status = get_repmgr_extension_status(conn, &extversions);
|
extension_status = get_repmgr_extension_status(conn);
|
||||||
|
|
||||||
switch (extension_status)
|
switch (extension_status)
|
||||||
{
|
{
|
||||||
@@ -2093,15 +1997,8 @@ create_repmgr_extension(PGconn *conn)
|
|||||||
log_error(_("\"repmgr\" extension is not available"));
|
log_error(_("\"repmgr\" extension is not available"));
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case REPMGR_OLD_VERSION_INSTALLED:
|
|
||||||
log_error(_("an older version of the \"repmgr\" extension is installed"));
|
|
||||||
log_detail(_("version %s is installed but newer version %s is available"),
|
|
||||||
extversions.installed_version,
|
|
||||||
extversions.default_version);
|
|
||||||
log_hint(_("execute \"ALTER EXTENSION repmgr UPGRADE\""));
|
|
||||||
return false;
|
|
||||||
|
|
||||||
case REPMGR_INSTALLED:
|
case REPMGR_INSTALLED:
|
||||||
|
/* TODO: check version */
|
||||||
log_info(_("\"repmgr\" extension is already installed"));
|
log_info(_("\"repmgr\" extension is already installed"));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -2679,29 +2576,11 @@ remote_command(const char *host, const char *user, const char *command, PQExpBuf
|
|||||||
void
|
void
|
||||||
make_remote_repmgr_path(PQExpBufferData *output_buf, t_node_info *remote_node_record)
|
make_remote_repmgr_path(PQExpBufferData *output_buf, t_node_info *remote_node_record)
|
||||||
{
|
{
|
||||||
if (config_file_options.repmgr_bindir[0] != '\0')
|
|
||||||
{
|
|
||||||
int len = strlen(config_file_options.repmgr_bindir);
|
|
||||||
|
|
||||||
appendPQExpBufferStr(output_buf,
|
|
||||||
config_file_options.repmgr_bindir);
|
|
||||||
|
|
||||||
/* Add trailing slash */
|
|
||||||
if (config_file_options.repmgr_bindir[len - 1] != '/')
|
|
||||||
{
|
|
||||||
appendPQExpBufferChar(output_buf, '/');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (pg_bindir[0] != '\0')
|
|
||||||
{
|
|
||||||
appendPQExpBufferStr(output_buf,
|
|
||||||
pg_bindir);
|
|
||||||
}
|
|
||||||
|
|
||||||
appendPQExpBuffer(output_buf,
|
appendPQExpBuffer(output_buf,
|
||||||
"%s -f %s ",
|
"%s -f %s ",
|
||||||
progname(),
|
make_pg_path(progname()),
|
||||||
remote_node_record->config_file);
|
remote_node_record->config_file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3141,3 +3020,4 @@ drop_replication_slot_if_exists(PGconn *conn, int node_id, char *slot_name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,9 +45,6 @@
|
|||||||
#define CLUSTER_MATRIX 19
|
#define CLUSTER_MATRIX 19
|
||||||
#define CLUSTER_CROSSCHECK 20
|
#define CLUSTER_CROSSCHECK 20
|
||||||
#define CLUSTER_EVENT 21
|
#define CLUSTER_EVENT 21
|
||||||
#define DAEMON_STATUS 22
|
|
||||||
#define DAEMON_PAUSE 23
|
|
||||||
#define DAEMON_UNPAUSE 24
|
|
||||||
|
|
||||||
/* command line options without short versions */
|
/* command line options without short versions */
|
||||||
#define OPT_HELP 1001
|
#define OPT_HELP 1001
|
||||||
@@ -91,7 +88,6 @@
|
|||||||
#define OPT_RECOVERY_CONF_ONLY 1039
|
#define OPT_RECOVERY_CONF_ONLY 1039
|
||||||
#define OPT_NO_WAIT 1040
|
#define OPT_NO_WAIT 1040
|
||||||
#define OPT_MISSING_SLOTS 1041
|
#define OPT_MISSING_SLOTS 1041
|
||||||
#define OPT_REPMGRD_NO_PAUSE 1042
|
|
||||||
|
|
||||||
/* deprecated since 3.3 */
|
/* deprecated since 3.3 */
|
||||||
#define OPT_DATA_DIR 999
|
#define OPT_DATA_DIR 999
|
||||||
@@ -160,7 +156,6 @@ static struct option long_options[] =
|
|||||||
*/
|
*/
|
||||||
{"always-promote", no_argument, NULL, OPT_ALWAYS_PROMOTE},
|
{"always-promote", no_argument, NULL, OPT_ALWAYS_PROMOTE},
|
||||||
{"siblings-follow", no_argument, NULL, OPT_SIBLINGS_FOLLOW},
|
{"siblings-follow", no_argument, NULL, OPT_SIBLINGS_FOLLOW},
|
||||||
{"repmgrd-no-pause", no_argument, NULL, OPT_REPMGRD_NO_PAUSE},
|
|
||||||
|
|
||||||
/* "node status" options */
|
/* "node status" options */
|
||||||
{"is-shutdown-cleanly", no_argument, NULL, OPT_IS_SHUTDOWN_CLEANLY},
|
{"is-shutdown-cleanly", no_argument, NULL, OPT_IS_SHUTDOWN_CLEANLY},
|
||||||
|
|||||||
260
repmgr.c
260
repmgr.c
@@ -26,7 +26,6 @@
|
|||||||
#include "access/xlog.h"
|
#include "access/xlog.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#include "replication/walreceiver.h"
|
#include "replication/walreceiver.h"
|
||||||
#include "storage/fd.h"
|
|
||||||
#include "storage/ipc.h"
|
#include "storage/ipc.h"
|
||||||
#include "storage/lwlock.h"
|
#include "storage/lwlock.h"
|
||||||
#include "storage/procarray.h"
|
#include "storage/procarray.h"
|
||||||
@@ -44,21 +43,14 @@
|
|||||||
#include "lib/stringinfo.h"
|
#include "lib/stringinfo.h"
|
||||||
#include "access/xact.h"
|
#include "access/xact.h"
|
||||||
#include "utils/snapmgr.h"
|
#include "utils/snapmgr.h"
|
||||||
|
|
||||||
#if (PG_VERSION_NUM >= 90400)
|
|
||||||
#include "pgstat.h"
|
#include "pgstat.h"
|
||||||
#else
|
|
||||||
#define PGSTAT_STAT_PERMANENT_DIRECTORY "pg_stat"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "voting.h"
|
#include "voting.h"
|
||||||
|
|
||||||
#define UNKNOWN_NODE_ID -1
|
#define UNKNOWN_NODE_ID -1
|
||||||
#define UNKNOWN_PID -1
|
|
||||||
|
|
||||||
#define TRANCHE_NAME "repmgrd"
|
#define TRANCHE_NAME "repmgrd"
|
||||||
#define REPMGRD_STATE_FILE PGSTAT_STAT_PERMANENT_DIRECTORY "/repmgrd_state.txt"
|
|
||||||
#define REPMGRD_STATE_FILE_BUF_SIZE 128
|
|
||||||
|
|
||||||
PG_MODULE_MAGIC;
|
PG_MODULE_MAGIC;
|
||||||
|
|
||||||
@@ -74,9 +66,6 @@ typedef struct repmgrdSharedState
|
|||||||
LWLockId lock; /* protects search/modification */
|
LWLockId lock; /* protects search/modification */
|
||||||
TimestampTz last_updated;
|
TimestampTz last_updated;
|
||||||
int local_node_id;
|
int local_node_id;
|
||||||
int repmgrd_pid;
|
|
||||||
char repmgrd_pidfile[MAXPGPATH];
|
|
||||||
bool repmgrd_paused;
|
|
||||||
/* streaming failover */
|
/* streaming failover */
|
||||||
NodeVotingStatus voting_status;
|
NodeVotingStatus voting_status;
|
||||||
int current_electoral_term;
|
int current_electoral_term;
|
||||||
@@ -123,25 +112,6 @@ PG_FUNCTION_INFO_V1(am_bdr_failover_handler);
|
|||||||
Datum unset_bdr_failover_handler(PG_FUNCTION_ARGS);
|
Datum unset_bdr_failover_handler(PG_FUNCTION_ARGS);
|
||||||
PG_FUNCTION_INFO_V1(unset_bdr_failover_handler);
|
PG_FUNCTION_INFO_V1(unset_bdr_failover_handler);
|
||||||
|
|
||||||
Datum set_repmgrd_pid(PG_FUNCTION_ARGS);
|
|
||||||
PG_FUNCTION_INFO_V1(set_repmgrd_pid);
|
|
||||||
|
|
||||||
Datum get_repmgrd_pid(PG_FUNCTION_ARGS);
|
|
||||||
PG_FUNCTION_INFO_V1(get_repmgrd_pid);
|
|
||||||
|
|
||||||
Datum get_repmgrd_pidfile(PG_FUNCTION_ARGS);
|
|
||||||
PG_FUNCTION_INFO_V1(get_repmgrd_pidfile);
|
|
||||||
|
|
||||||
Datum repmgrd_is_running(PG_FUNCTION_ARGS);
|
|
||||||
PG_FUNCTION_INFO_V1(repmgrd_is_running);
|
|
||||||
|
|
||||||
Datum repmgrd_pause(PG_FUNCTION_ARGS);
|
|
||||||
PG_FUNCTION_INFO_V1(repmgrd_pause);
|
|
||||||
|
|
||||||
Datum repmgrd_is_paused(PG_FUNCTION_ARGS);
|
|
||||||
PG_FUNCTION_INFO_V1(repmgrd_is_paused);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Module load callback
|
* Module load callback
|
||||||
@@ -215,9 +185,6 @@ repmgr_shmem_startup(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
shared_state->local_node_id = UNKNOWN_NODE_ID;
|
shared_state->local_node_id = UNKNOWN_NODE_ID;
|
||||||
shared_state->repmgrd_pid = UNKNOWN_PID;
|
|
||||||
memset(shared_state->repmgrd_pidfile, 0, MAXPGPATH);
|
|
||||||
shared_state->repmgrd_paused = false;
|
|
||||||
shared_state->current_electoral_term = 0;
|
shared_state->current_electoral_term = 0;
|
||||||
shared_state->voting_status = VS_NO_VOTE;
|
shared_state->voting_status = VS_NO_VOTE;
|
||||||
shared_state->candidate_node_id = UNKNOWN_NODE_ID;
|
shared_state->candidate_node_id = UNKNOWN_NODE_ID;
|
||||||
@@ -237,8 +204,6 @@ Datum
|
|||||||
set_local_node_id(PG_FUNCTION_ARGS)
|
set_local_node_id(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
int local_node_id = UNKNOWN_NODE_ID;
|
int local_node_id = UNKNOWN_NODE_ID;
|
||||||
int stored_node_id = UNKNOWN_NODE_ID;
|
|
||||||
int paused = -1;
|
|
||||||
|
|
||||||
if (!shared_state)
|
if (!shared_state)
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
@@ -248,34 +213,6 @@ set_local_node_id(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
local_node_id = PG_GETARG_INT32(0);
|
local_node_id = PG_GETARG_INT32(0);
|
||||||
|
|
||||||
/* read state file and if exists/valid, update "repmgrd_paused" */
|
|
||||||
{
|
|
||||||
FILE *file = NULL;
|
|
||||||
|
|
||||||
file = AllocateFile(REPMGRD_STATE_FILE, PG_BINARY_R);
|
|
||||||
|
|
||||||
if (file != NULL)
|
|
||||||
{
|
|
||||||
int buffer_size = REPMGRD_STATE_FILE_BUF_SIZE;
|
|
||||||
char buffer[REPMGRD_STATE_FILE_BUF_SIZE];
|
|
||||||
|
|
||||||
if (fgets(buffer, buffer_size, file) != NULL)
|
|
||||||
{
|
|
||||||
if (sscanf(buffer, "%i:%i", &stored_node_id, &paused) != 2)
|
|
||||||
{
|
|
||||||
elog(WARNING, "unable to parse repmgrd state file");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
elog(DEBUG1, "node_id: %i; paused: %i", stored_node_id, paused);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FreeFile(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
LWLockAcquire(shared_state->lock, LW_EXCLUSIVE);
|
LWLockAcquire(shared_state->lock, LW_EXCLUSIVE);
|
||||||
|
|
||||||
/* only set local_node_id once, as it should never change */
|
/* only set local_node_id once, as it should never change */
|
||||||
@@ -284,19 +221,6 @@ set_local_node_id(PG_FUNCTION_ARGS)
|
|||||||
shared_state->local_node_id = local_node_id;
|
shared_state->local_node_id = local_node_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* only update if state file valid */
|
|
||||||
if (stored_node_id == shared_state->local_node_id)
|
|
||||||
{
|
|
||||||
if (paused == 0)
|
|
||||||
{
|
|
||||||
shared_state->repmgrd_paused = false;
|
|
||||||
}
|
|
||||||
else if (paused == 1)
|
|
||||||
{
|
|
||||||
shared_state->repmgrd_paused = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LWLockRelease(shared_state->lock);
|
LWLockRelease(shared_state->lock);
|
||||||
|
|
||||||
PG_RETURN_VOID();
|
PG_RETURN_VOID();
|
||||||
@@ -498,185 +422,3 @@ unset_bdr_failover_handler(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
PG_RETURN_VOID();
|
PG_RETURN_VOID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the repmgrd pid; or NULL if none set; or -1 if set but repmgrd
|
|
||||||
* process not running (TODO!)
|
|
||||||
*/
|
|
||||||
Datum
|
|
||||||
get_repmgrd_pid(PG_FUNCTION_ARGS)
|
|
||||||
{
|
|
||||||
int repmgrd_pid = UNKNOWN_PID;
|
|
||||||
|
|
||||||
if (!shared_state)
|
|
||||||
PG_RETURN_NULL();
|
|
||||||
|
|
||||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
|
||||||
repmgrd_pid = shared_state->repmgrd_pid;
|
|
||||||
LWLockRelease(shared_state->lock);
|
|
||||||
|
|
||||||
PG_RETURN_INT32(repmgrd_pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the repmgrd pidfile
|
|
||||||
*/
|
|
||||||
Datum
|
|
||||||
get_repmgrd_pidfile(PG_FUNCTION_ARGS)
|
|
||||||
{
|
|
||||||
char repmgrd_pidfile[MAXPGPATH];
|
|
||||||
|
|
||||||
if (!shared_state)
|
|
||||||
PG_RETURN_NULL();
|
|
||||||
|
|
||||||
memset(repmgrd_pidfile, 0, MAXPGPATH);
|
|
||||||
|
|
||||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
|
||||||
strncpy(repmgrd_pidfile, shared_state->repmgrd_pidfile, MAXPGPATH);
|
|
||||||
LWLockRelease(shared_state->lock);
|
|
||||||
|
|
||||||
if (repmgrd_pidfile[0] == '\0')
|
|
||||||
PG_RETURN_NULL();
|
|
||||||
|
|
||||||
PG_RETURN_TEXT_P(cstring_to_text(repmgrd_pidfile));
|
|
||||||
}
|
|
||||||
|
|
||||||
Datum
|
|
||||||
set_repmgrd_pid(PG_FUNCTION_ARGS)
|
|
||||||
{
|
|
||||||
int repmgrd_pid = UNKNOWN_PID;
|
|
||||||
char *repmgrd_pidfile = NULL;
|
|
||||||
|
|
||||||
if (!shared_state)
|
|
||||||
PG_RETURN_VOID();
|
|
||||||
|
|
||||||
if (PG_ARGISNULL(0))
|
|
||||||
{
|
|
||||||
repmgrd_pid = UNKNOWN_PID;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
repmgrd_pid = PG_GETARG_INT32(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
elog(DEBUG3, "set_repmgrd_pid(): provided pid is %i", repmgrd_pid);
|
|
||||||
|
|
||||||
if (repmgrd_pid != UNKNOWN_PID && !PG_ARGISNULL(1))
|
|
||||||
{
|
|
||||||
repmgrd_pidfile = text_to_cstring(PG_GETARG_TEXT_PP(1));
|
|
||||||
elog(INFO, "set_repmgrd_pid(): provided pidfile is %s", repmgrd_pidfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
LWLockAcquire(shared_state->lock, LW_EXCLUSIVE);
|
|
||||||
|
|
||||||
shared_state->repmgrd_pid = repmgrd_pid;
|
|
||||||
memset(shared_state->repmgrd_pidfile, 0, MAXPGPATH);
|
|
||||||
|
|
||||||
if(repmgrd_pidfile != NULL)
|
|
||||||
{
|
|
||||||
strncpy(shared_state->repmgrd_pidfile, repmgrd_pidfile, MAXPGPATH);
|
|
||||||
}
|
|
||||||
|
|
||||||
LWLockRelease(shared_state->lock);
|
|
||||||
PG_RETURN_VOID();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Datum
|
|
||||||
repmgrd_is_running(PG_FUNCTION_ARGS)
|
|
||||||
{
|
|
||||||
int repmgrd_pid = UNKNOWN_PID;
|
|
||||||
int kill_ret;
|
|
||||||
|
|
||||||
if (!shared_state)
|
|
||||||
PG_RETURN_NULL();
|
|
||||||
|
|
||||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
|
||||||
repmgrd_pid = shared_state->repmgrd_pid;
|
|
||||||
LWLockRelease(shared_state->lock);
|
|
||||||
|
|
||||||
/* No PID registered - assume not running */
|
|
||||||
if (repmgrd_pid == UNKNOWN_PID)
|
|
||||||
{
|
|
||||||
PG_RETURN_BOOL(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
kill_ret = kill(repmgrd_pid, 0);
|
|
||||||
|
|
||||||
if (kill_ret == 0)
|
|
||||||
{
|
|
||||||
PG_RETURN_BOOL(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
PG_RETURN_BOOL(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Datum
|
|
||||||
repmgrd_pause(PG_FUNCTION_ARGS)
|
|
||||||
{
|
|
||||||
bool pause;
|
|
||||||
FILE *file = NULL;
|
|
||||||
StringInfoData buf;
|
|
||||||
|
|
||||||
if (!shared_state)
|
|
||||||
PG_RETURN_NULL();
|
|
||||||
|
|
||||||
if (PG_ARGISNULL(0))
|
|
||||||
PG_RETURN_NULL();
|
|
||||||
|
|
||||||
pause = PG_GETARG_BOOL(0);
|
|
||||||
|
|
||||||
LWLockAcquire(shared_state->lock, LW_EXCLUSIVE);
|
|
||||||
shared_state->repmgrd_paused = pause;
|
|
||||||
LWLockRelease(shared_state->lock);
|
|
||||||
|
|
||||||
/* write state to file */
|
|
||||||
file = AllocateFile(REPMGRD_STATE_FILE, PG_BINARY_W);
|
|
||||||
|
|
||||||
if (file == NULL)
|
|
||||||
{
|
|
||||||
elog(DEBUG1, "unable to allocate %s", REPMGRD_STATE_FILE);
|
|
||||||
|
|
||||||
// XXX anything else we can do? log?
|
|
||||||
PG_RETURN_VOID();
|
|
||||||
}
|
|
||||||
|
|
||||||
elog(DEBUG1, "allocated");
|
|
||||||
|
|
||||||
initStringInfo(&buf);
|
|
||||||
|
|
||||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
|
||||||
|
|
||||||
appendStringInfo(&buf, "%i:%i",
|
|
||||||
shared_state->local_node_id,
|
|
||||||
pause ? 1 : 0);
|
|
||||||
LWLockRelease(shared_state->lock);
|
|
||||||
|
|
||||||
// XXX check success
|
|
||||||
fwrite(buf.data, strlen(buf.data) + 1, 1, file);
|
|
||||||
|
|
||||||
|
|
||||||
resetStringInfo(&buf);
|
|
||||||
FreeFile(file);
|
|
||||||
|
|
||||||
PG_RETURN_VOID();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Datum
|
|
||||||
repmgrd_is_paused(PG_FUNCTION_ARGS)
|
|
||||||
{
|
|
||||||
bool is_paused;
|
|
||||||
|
|
||||||
if (!shared_state)
|
|
||||||
PG_RETURN_NULL();
|
|
||||||
|
|
||||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
|
||||||
is_paused = shared_state->repmgrd_paused;
|
|
||||||
LWLockRelease(shared_state->lock);
|
|
||||||
|
|
||||||
PG_RETURN_BOOL(is_paused);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,13 +5,7 @@
|
|||||||
# Some configuration items will be set with a default value; this
|
# Some configuration items will be set with a default value; this
|
||||||
# is noted for each item. Where no default value is shown, the
|
# is noted for each item. Where no default value is shown, the
|
||||||
# parameter will be treated as empty or false.
|
# parameter will be treated as empty or false.
|
||||||
#
|
|
||||||
# IMPORTANT: string values can be provided as-is, or enclosed in single quotes
|
|
||||||
# (but not double-quotes, which will be interpreted as part of the string), e.g.:
|
|
||||||
#
|
|
||||||
# node_name=foo
|
|
||||||
# node_name = 'foo'
|
|
||||||
#
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Required configuration items
|
# Required configuration items
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
@@ -153,11 +147,7 @@
|
|||||||
# *NOTE* "pg_bindir" is only used when repmgr directly
|
# *NOTE* "pg_bindir" is only used when repmgr directly
|
||||||
# executes PostgreSQL binaries; any user-defined scripts
|
# executes PostgreSQL binaries; any user-defined scripts
|
||||||
# *must* be specified with the full path
|
# *must* be specified with the full path
|
||||||
|
#
|
||||||
#repmgr_bindir='' # Path to repmgr binary directory (location of the repmgr
|
|
||||||
# binary. Only needed if the repmgr executable is not in
|
|
||||||
# the system $PATH or the path defined in "pg_bindir".
|
|
||||||
|
|
||||||
#use_primary_conninfo_password=false # explicitly set "password" in recovery.conf's
|
#use_primary_conninfo_password=false # explicitly set "password" in recovery.conf's
|
||||||
# "primary_conninfo" parameter using the value contained
|
# "primary_conninfo" parameter using the value contained
|
||||||
# in the environment variable PGPASSWORD
|
# in the environment variable PGPASSWORD
|
||||||
@@ -241,8 +231,6 @@ ssh_options='-q -o ConnectTimeout=10' # Options to append to "ssh"
|
|||||||
# These settings apply when switching roles between a primary and a standby
|
# These settings apply when switching roles between a primary and a standby
|
||||||
# ("repmgr standby switchover").
|
# ("repmgr standby switchover").
|
||||||
|
|
||||||
#shutdown_check_timeout=60 # The max length of time (in seconds) to wait for the demotion
|
|
||||||
# candidate (current primary) to shut down
|
|
||||||
#standby_reconnect_timeout=60 # The max length of time (in seconds) to wait
|
#standby_reconnect_timeout=60 # The max length of time (in seconds) to wait
|
||||||
# for the demoted standby to reconnect to the promoted
|
# for the demoted standby to reconnect to the promoted
|
||||||
# primary (note: this value should be equal to or greater
|
# primary (note: this value should be equal to or greater
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# repmgr extension
|
# repmgr extension
|
||||||
comment = 'Replication manager for PostgreSQL'
|
comment = 'Replication manager for PostgreSQL'
|
||||||
default_version = '4.2'
|
default_version = '4.1'
|
||||||
module_pathname = '$libdir/repmgr'
|
module_pathname = '$libdir/repmgr'
|
||||||
relocatable = false
|
relocatable = false
|
||||||
schema = repmgr
|
schema = repmgr
|
||||||
|
|||||||
2
repmgr.h
2
repmgr.h
@@ -53,7 +53,6 @@
|
|||||||
|
|
||||||
#define UNKNOWN_TIMELINE_ID -1
|
#define UNKNOWN_TIMELINE_ID -1
|
||||||
#define UNKNOWN_SYSTEM_IDENTIFIER 0
|
#define UNKNOWN_SYSTEM_IDENTIFIER 0
|
||||||
#define UNKNOWN_PID -1
|
|
||||||
|
|
||||||
#define NODE_NOT_FOUND -1
|
#define NODE_NOT_FOUND -1
|
||||||
#define NO_UPSTREAM_NODE -1
|
#define NO_UPSTREAM_NODE -1
|
||||||
@@ -85,7 +84,6 @@
|
|||||||
#define DEFAULT_WAIT_START 30 /* seconds */
|
#define DEFAULT_WAIT_START 30 /* seconds */
|
||||||
#define DEFAULT_PROMOTE_CHECK_TIMEOUT 60 /* seconds */
|
#define DEFAULT_PROMOTE_CHECK_TIMEOUT 60 /* seconds */
|
||||||
#define DEFAULT_PROMOTE_CHECK_INTERVAL 1 /* seconds */
|
#define DEFAULT_PROMOTE_CHECK_INTERVAL 1 /* seconds */
|
||||||
#define DEFAULT_SHUTDOWN_CHECK_TIMEOUT 60 /* seconds */
|
|
||||||
#define DEFAULT_STANDBY_RECONNECT_TIMEOUT 60 /* seconds */
|
#define DEFAULT_STANDBY_RECONNECT_TIMEOUT 60 /* seconds */
|
||||||
#define DEFAULT_NODE_REJOIN_TIMEOUT 60 /* seconds */
|
#define DEFAULT_NODE_REJOIN_TIMEOUT 60 /* seconds */
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
#define REPMGR_VERSION_DATE ""
|
#define REPMGR_VERSION_DATE ""
|
||||||
#define REPMGR_VERSION "4.2"
|
#define REPMGR_VERSION "4.1.2"
|
||||||
|
|||||||
@@ -150,13 +150,7 @@ monitor_bdr(void)
|
|||||||
* retrieve list of all nodes - we'll need these if the DB connection goes
|
* retrieve list of all nodes - we'll need these if the DB connection goes
|
||||||
* away
|
* away
|
||||||
*/
|
*/
|
||||||
if (get_all_node_records(local_conn, &nodes) == false)
|
get_all_node_records(local_conn, &nodes);
|
||||||
{
|
|
||||||
/* get_all_node_records() will display the error */
|
|
||||||
PQfinish(local_conn);
|
|
||||||
exit(ERR_BAD_CONFIG);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* we're expecting all (both) nodes to be up */
|
/* we're expecting all (both) nodes to be up */
|
||||||
for (cell = nodes.head; cell; cell = cell->next)
|
for (cell = nodes.head; cell; cell = cell->next)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
55
repmgrd.c
55
repmgrd.c
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
static char *config_file = NULL;
|
static char *config_file = NULL;
|
||||||
static bool verbose = false;
|
static bool verbose = false;
|
||||||
char pid_file[MAXPGPATH];
|
static char pid_file[MAXPGPATH];
|
||||||
static bool daemonize = true;
|
static bool daemonize = true;
|
||||||
static bool show_pid_file = false;
|
static bool show_pid_file = false;
|
||||||
static bool no_pid_file = false;
|
static bool no_pid_file = false;
|
||||||
@@ -88,7 +88,6 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
RecordStatus record_status;
|
RecordStatus record_status;
|
||||||
ExtensionStatus extension_status = REPMGR_UNKNOWN;
|
ExtensionStatus extension_status = REPMGR_UNKNOWN;
|
||||||
t_extension_versions extversions = T_EXTENSION_VERSIONS_INITIALIZER;
|
|
||||||
|
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
|
|
||||||
@@ -102,8 +101,7 @@ main(int argc, char **argv)
|
|||||||
{"config-file", required_argument, NULL, 'f'},
|
{"config-file", required_argument, NULL, 'f'},
|
||||||
|
|
||||||
/* daemon options */
|
/* daemon options */
|
||||||
{"daemonize-short", optional_argument, NULL, 'd'},
|
{"daemonize", optional_argument, NULL, 'd'},
|
||||||
{"daemonize", optional_argument, NULL, OPT_DAEMONIZE},
|
|
||||||
{"pid-file", required_argument, NULL, 'p'},
|
{"pid-file", required_argument, NULL, 'p'},
|
||||||
{"show-pid-file", no_argument, NULL, 's'},
|
{"show-pid-file", no_argument, NULL, 's'},
|
||||||
{"no-pid-file", no_argument, NULL, OPT_NO_PID_FILE},
|
{"no-pid-file", no_argument, NULL, OPT_NO_PID_FILE},
|
||||||
@@ -177,11 +175,10 @@ main(int argc, char **argv)
|
|||||||
/* daemon options */
|
/* daemon options */
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
daemonize = true;
|
if (optarg != NULL)
|
||||||
break;
|
{
|
||||||
|
daemonize = parse_bool(optarg, "-d/--daemonize", &cli_errors);
|
||||||
case OPT_DAEMONIZE:
|
}
|
||||||
daemonize = parse_bool(optarg, "-d/--daemonize", &cli_errors);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
@@ -390,7 +387,7 @@ main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Check "repmgr" the extension is installed */
|
/* Check "repmgr" the extension is installed */
|
||||||
extension_status = get_repmgr_extension_status(local_conn, &extversions);
|
extension_status = get_repmgr_extension_status(local_conn);
|
||||||
|
|
||||||
if (extension_status != REPMGR_INSTALLED)
|
if (extension_status != REPMGR_INSTALLED)
|
||||||
{
|
{
|
||||||
@@ -403,32 +400,19 @@ main(int argc, char **argv)
|
|||||||
exit(ERR_DB_QUERY);
|
exit(ERR_DB_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extension_status == REPMGR_OLD_VERSION_INSTALLED)
|
log_error(_("repmgr extension not found on this node"));
|
||||||
{
|
|
||||||
log_error(_("an older version of the \"repmgr\" extension is installed"));
|
|
||||||
log_detail(_("version %s is installed but newer version %s is available"),
|
|
||||||
extversions.installed_version,
|
|
||||||
extversions.default_version);
|
|
||||||
log_hint(_("verify the repmgr installation is updated properly before continuing"));
|
|
||||||
|
|
||||||
|
if (extension_status == REPMGR_AVAILABLE)
|
||||||
|
{
|
||||||
|
log_detail(_("repmgr extension is available but not installed in database \"%s\""),
|
||||||
|
PQdb(local_conn));
|
||||||
}
|
}
|
||||||
else
|
else if (extension_status == REPMGR_UNAVAILABLE)
|
||||||
{
|
{
|
||||||
log_error(_("repmgr extension not found on this node"));
|
log_detail(_("repmgr extension is not available on this node"));
|
||||||
|
|
||||||
if (extension_status == REPMGR_AVAILABLE)
|
|
||||||
{
|
|
||||||
log_detail(_("repmgr extension is available but not installed in database \"%s\""),
|
|
||||||
PQdb(local_conn));
|
|
||||||
}
|
|
||||||
else if (extension_status == REPMGR_UNAVAILABLE)
|
|
||||||
{
|
|
||||||
log_detail(_("repmgr extension is not available on this node"));
|
|
||||||
}
|
|
||||||
|
|
||||||
log_hint(_("check that this node is part of a repmgr cluster"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_hint(_("check that this node is part of a repmgr cluster"));
|
||||||
close_connection(&local_conn);
|
close_connection(&local_conn);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
@@ -504,9 +488,6 @@ main(int argc, char **argv)
|
|||||||
check_and_create_pid_file(pid_file);
|
check_and_create_pid_file(pid_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
repmgrd_set_pid(local_conn, getpid(), pid_file);
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
setup_event_handlers();
|
setup_event_handlers();
|
||||||
#endif
|
#endif
|
||||||
@@ -779,8 +760,7 @@ show_help(void)
|
|||||||
puts("");
|
puts("");
|
||||||
|
|
||||||
printf(_("Daemon configuration options:\n"));
|
printf(_("Daemon configuration options:\n"));
|
||||||
printf(_(" -d\n"));
|
printf(_(" -d, --daemonize[=true/false]\n"));
|
||||||
printf(_(" --daemonize[=true/false]\n"));
|
|
||||||
printf(_(" detach process from foreground (default: true)\n"));
|
printf(_(" detach process from foreground (default: true)\n"));
|
||||||
printf(_(" -p, --pid-file=PATH use the specified PID file\n"));
|
printf(_(" -p, --pid-file=PATH use the specified PID file\n"));
|
||||||
printf(_(" -s, --show-pid-file show PID file which would be used by the current configuration\n"));
|
printf(_(" -s, --show-pid-file show PID file which would be used by the current configuration\n"));
|
||||||
@@ -921,9 +901,6 @@ print_monitoring_state(MonitoringState monitoring_state)
|
|||||||
void
|
void
|
||||||
terminate(int retval)
|
terminate(int retval)
|
||||||
{
|
{
|
||||||
if (PQstatus(local_conn) == CONNECTION_OK)
|
|
||||||
repmgrd_set_pid(local_conn, UNKNOWN_PID, NULL);
|
|
||||||
|
|
||||||
logger_shutdown();
|
logger_shutdown();
|
||||||
|
|
||||||
if (pid_file[0] != '\0')
|
if (pid_file[0] != '\0')
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#include "portability/instr_time.h"
|
#include "portability/instr_time.h"
|
||||||
|
|
||||||
#define OPT_NO_PID_FILE 1000
|
#define OPT_NO_PID_FILE 1000
|
||||||
#define OPT_DAEMONIZE 1001
|
|
||||||
|
|
||||||
extern volatile sig_atomic_t got_SIGHUP;
|
extern volatile sig_atomic_t got_SIGHUP;
|
||||||
extern MonitoringState monitoring_state;
|
extern MonitoringState monitoring_state;
|
||||||
@@ -21,7 +20,6 @@ extern t_configuration_options config_file_options;
|
|||||||
extern t_node_info local_node_info;
|
extern t_node_info local_node_info;
|
||||||
extern PGconn *local_conn;
|
extern PGconn *local_conn;
|
||||||
extern bool startup_event_logged;
|
extern bool startup_event_logged;
|
||||||
extern char pid_file[MAXPGPATH];
|
|
||||||
|
|
||||||
void try_reconnect(PGconn **conn, t_node_info *node_info);
|
void try_reconnect(PGconn **conn, t_node_info *node_info);
|
||||||
|
|
||||||
|
|||||||
12
strutil.c
12
strutil.c
@@ -87,17 +87,17 @@ append_where_clause(PQExpBufferData *where_clause, const char *format,...)
|
|||||||
|
|
||||||
if (where_clause->data[0] == '\0')
|
if (where_clause->data[0] == '\0')
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(where_clause,
|
appendPQExpBuffer(where_clause,
|
||||||
" WHERE ");
|
" WHERE ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(where_clause,
|
appendPQExpBuffer(where_clause,
|
||||||
" AND ");
|
" AND ");
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBufferStr(where_clause,
|
appendPQExpBuffer(where_clause,
|
||||||
stringbuf);
|
"%s", stringbuf);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user