From 9093a9d1ce571ba10f6f2e5c90c7f2e17031aece Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Sat, 3 Jan 2015 08:06:09 +0900 Subject: [PATCH 01/29] Update copyright to 2015 --- COPYRIGHT | 2 +- Makefile | 2 +- README.rst | 2 +- check_dir.c | 2 +- check_dir.h | 2 +- config.c | 2 +- config.h | 2 +- dbutils.c | 2 +- dbutils.h | 2 +- errcode.h | 2 +- log.c | 2 +- log.h | 2 +- repmgr.c | 2 +- repmgr.h | 2 +- repmgr.sql | 2 +- repmgrd.c | 2 +- sql/repmgr_funcs.sql.in | 2 +- sql/uninstall_repmgr_funcs.sql | 2 +- strutil.c | 2 +- strutil.h | 2 +- uninstall_repmgr.sql | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/COPYRIGHT b/COPYRIGHT index 5ee437aa..5d7a3523 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,4 +1,4 @@ -Copyright (c) 2010-2014, 2ndQuadrant Limited +Copyright (c) 2010-2015, 2ndQuadrant Limited All rights reserved. This program is free software: you can redistribute it and/or modify diff --git a/Makefile b/Makefile index 1bd36c3a..e4e48e30 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # # Makefile -# Copyright (c) 2ndQuadrant, 2010-2014 +# Copyright (c) 2ndQuadrant, 2010-2015 repmgrd_OBJS = dbutils.o config.o repmgrd.o log.o strutil.o repmgr_OBJS = dbutils.o check_dir.o config.o repmgr.o log.o strutil.o diff --git a/README.rst b/README.rst index 12e74764..2fdbae19 100644 --- a/README.rst +++ b/README.rst @@ -1087,7 +1087,7 @@ License and Contributions ========================= repmgr is licensed under the GPL v3. All of its code and documentation is -Copyright 2010-2014, 2ndQuadrant Limited. See the files COPYRIGHT and LICENSE for +Copyright 2010-2015, 2ndQuadrant Limited. See the files COPYRIGHT and LICENSE for details. Main sponsorship of repmgr has been from 2ndQuadrant customers. diff --git a/check_dir.c b/check_dir.c index 5826e11c..44083885 100644 --- a/check_dir.c +++ b/check_dir.c @@ -1,6 +1,6 @@ /* * check_dir.c - Directories management functions - * Copyright (C) 2ndQuadrant, 2010-2014 + * Copyright (C) 2ndQuadrant, 2010-2015 * * 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 diff --git a/check_dir.h b/check_dir.h index 77db94bb..d11ec589 100644 --- a/check_dir.h +++ b/check_dir.h @@ -1,6 +1,6 @@ /* * check_dir.h - * Copyright (c) 2ndQuadrant, 2010-2014 + * Copyright (c) 2ndQuadrant, 2010-2015 * * 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 diff --git a/config.c b/config.c index 9e2b67ea..0e24e54f 100644 --- a/config.c +++ b/config.c @@ -1,6 +1,6 @@ /* * config.c - Functions to parse the config file - * Copyright (C) 2ndQuadrant, 2010-2014 + * Copyright (C) 2ndQuadrant, 2010-2015 * * 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 diff --git a/config.h b/config.h index 2f304250..bf95a21f 100644 --- a/config.h +++ b/config.h @@ -1,6 +1,6 @@ /* * config.h - * Copyright (c) 2ndQuadrant, 2010-2014 + * Copyright (c) 2ndQuadrant, 2010-2015 * * 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 diff --git a/dbutils.c b/dbutils.c index 18527331..3cc57201 100644 --- a/dbutils.c +++ b/dbutils.c @@ -1,6 +1,6 @@ /* * dbutils.c - Database connection/management functions - * Copyright (C) 2ndQuadrant, 2010-2014 + * Copyright (C) 2ndQuadrant, 2010-2015 * * 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 diff --git a/dbutils.h b/dbutils.h index 39d2233f..1beb4409 100644 --- a/dbutils.h +++ b/dbutils.h @@ -1,6 +1,6 @@ /* * dbutils.h - * Copyright (c) 2ndQuadrant, 2010-2014 + * Copyright (c) 2ndQuadrant, 2010-2015 * * 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 diff --git a/errcode.h b/errcode.h index e3114716..a4ae1454 100644 --- a/errcode.h +++ b/errcode.h @@ -1,6 +1,6 @@ /* * errcode.h - * Copyright (C) 2ndQuadrant, 2010-2014 + * Copyright (C) 2ndQuadrant, 2010-2015 * * 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 diff --git a/log.c b/log.c index a0709b1f..f753328a 100644 --- a/log.c +++ b/log.c @@ -1,6 +1,6 @@ /* * log.c - Logging methods - * Copyright (C) 2ndQuadrant, 2010-2014 + * Copyright (C) 2ndQuadrant, 2010-2015 * * This module is a set of methods for logging (currently only syslog) * diff --git a/log.h b/log.h index 6faebf07..f6b80c70 100644 --- a/log.h +++ b/log.h @@ -1,6 +1,6 @@ /* * log.h - * Copyright (c) 2ndQuadrant, 2010-2014 + * Copyright (c) 2ndQuadrant, 2010-2015 * * 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 diff --git a/repmgr.c b/repmgr.c index fbafda0e..fa249230 100644 --- a/repmgr.c +++ b/repmgr.c @@ -1,6 +1,6 @@ /* * repmgr.c - Command interpreter for the repmgr - * Copyright (C) 2ndQuadrant, 2010-2014 + * Copyright (C) 2ndQuadrant, 2010-2015 * * This module is a command-line utility to easily setup a cluster of * hot standby servers for an HA environment diff --git a/repmgr.h b/repmgr.h index c7c43f1e..9636786f 100644 --- a/repmgr.h +++ b/repmgr.h @@ -1,6 +1,6 @@ /* * repmgr.h - * Copyright (c) 2ndQuadrant, 2010-2014 + * Copyright (c) 2ndQuadrant, 2010-2015 * * 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 diff --git a/repmgr.sql b/repmgr.sql index dea6aba9..52f4e58d 100644 --- a/repmgr.sql +++ b/repmgr.sql @@ -1,7 +1,7 @@ /* * repmgr.sql * - * Copyright (C) 2ndQuadrant, 2010-2014 + * Copyright (C) 2ndQuadrant, 2010-2015 * */ diff --git a/repmgrd.c b/repmgrd.c index ad4dcd9b..2ebb7df8 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -1,6 +1,6 @@ /* * repmgrd.c - Replication manager daemon - * Copyright (C) 2ndQuadrant, 2010-2014 + * Copyright (C) 2ndQuadrant, 2010-2015 * * This module connects to the nodes of a replication cluster and monitors * how far are they from master diff --git a/sql/repmgr_funcs.sql.in b/sql/repmgr_funcs.sql.in index fc438cd6..864c1c98 100644 --- a/sql/repmgr_funcs.sql.in +++ b/sql/repmgr_funcs.sql.in @@ -1,6 +1,6 @@ /* * repmgr_function.sql - * Copyright (c) 2ndQuadrant, 2010-2014 + * Copyright (c) 2ndQuadrant, 2010-2015 * */ diff --git a/sql/uninstall_repmgr_funcs.sql b/sql/uninstall_repmgr_funcs.sql index 08ecca58..d32637e3 100644 --- a/sql/uninstall_repmgr_funcs.sql +++ b/sql/uninstall_repmgr_funcs.sql @@ -1,6 +1,6 @@ /* * uninstall_repmgr_funcs.sql - * Copyright (c) 2ndQuadrant, 2010-2014 + * Copyright (c) 2ndQuadrant, 2010-2015 * */ diff --git a/strutil.c b/strutil.c index 018ec3b9..1234fb10 100644 --- a/strutil.c +++ b/strutil.c @@ -1,7 +1,7 @@ /* * strutil.c * - * Copyright (C) 2ndQuadrant, 2010-2014 + * Copyright (C) 2ndQuadrant, 2010-2015 * * 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 diff --git a/strutil.h b/strutil.h index 142f588b..5c041cc2 100644 --- a/strutil.h +++ b/strutil.h @@ -1,6 +1,6 @@ /* * strutil.h - * Copyright (C) 2ndQuadrant, 2010-2014 + * Copyright (C) 2ndQuadrant, 2010-2015 * * * This program is free software: you can redistribute it and/or modify diff --git a/uninstall_repmgr.sql b/uninstall_repmgr.sql index b71e7c7e..efe327fe 100644 --- a/uninstall_repmgr.sql +++ b/uninstall_repmgr.sql @@ -1,7 +1,7 @@ /* * uninstall_repmgr.sql * - * Copyright (C) 2ndQuadrant, 2010-2014 + * Copyright (C) 2ndQuadrant, 2010-2015 * */ From 3e983b258c5d056a636c372c69befa23a7169dfe Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Sat, 3 Jan 2015 08:08:47 +0900 Subject: [PATCH 02/29] Fix help output formatting --- repmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repmgr.c b/repmgr.c index fa249230..41a5a0ec 100644 --- a/repmgr.c +++ b/repmgr.c @@ -1960,7 +1960,7 @@ help(const char *progname) printf(_(" -F, --force force potentially dangerous operations\n" \ " to happen\n")); printf(_(" -W, --wait wait for a master to appear\n")); - printf(_(" -r, --min-recovery-apply-delay=VALUE enable recovery time delay, value has to be a valid time atom (e.g. 5min)")); + printf(_(" -r, --min-recovery-apply-delay=VALUE enable recovery time delay, value has to be a valid time atom (e.g. 5min)\n")); printf(_(" --initdb-no-pwprompt don't require superuser password when running initdb\n")); printf(_("\n%s performs some tasks like clone a node, promote it or making follow\n"), progname); printf(_("another node and then exits.\n\n")); From e886e72f14a14b966104a3a89c63a454a2cac082 Mon Sep 17 00:00:00 2001 From: Jaime Casanova Date: Tue, 10 Feb 2015 20:15:40 -0500 Subject: [PATCH 03/29] Add "--checksum" in rsync when using "--force" If the user don't put that option in rsync_options using of "--force" could be unsafe. While the probability of failures because of this are low they aren't zero. --- repmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repmgr.c b/repmgr.c index 41a5a0ec..4d4f32a5 100644 --- a/repmgr.c +++ b/repmgr.c @@ -2086,7 +2086,7 @@ copy_remote_files(char *host, char *remote_user, char *remote_path, maxlen_snprintf(rsync_flags, "%s", options.rsync_options); if (runtime_options.force) - strcat(rsync_flags, " --delete"); + strcat(rsync_flags, " --delete --checksum"); if (!remote_user[0]) { From e213f3b99db60cba2dbdf865d4e883725004b671 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 12 Feb 2015 14:39:05 +0900 Subject: [PATCH 04/29] Fix master port check Check introduced in dc0dfe9b56800b9fb03b338031da2bb91f1058b6 was comparing the provided database name instead of the port. --- repmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repmgr.c b/repmgr.c index 4d4f32a5..86a9f6aa 100644 --- a/repmgr.c +++ b/repmgr.c @@ -318,7 +318,7 @@ main(int argc, char **argv) } /* We check that port number is not null */ - if (!runtime_options.dbname[0]) + if (!runtime_options.masterport[0]) { strncpy(runtime_options.masterport, DEFAULT_MASTER_PORT, MAXLEN); } From 09c7ba95ac34b205f5b691e885e09a544cb9a524 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 12 Feb 2015 14:42:23 +0900 Subject: [PATCH 05/29] Update HISTORY notes --- HISTORY | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/HISTORY b/HISTORY index 6b476d2f..2bb88960 100644 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,11 @@ +2.0.2 2015-02-?? + Add "--checksum" in rsync when using "--force" (Jaime) + Add option "--initdb-no-pwprompt" (Ian) + Add -S/--superuser option for witness database creation + Use createdb/createuser instead of psql (Jaime) + Fixes to witness creation and monitoring (wamonite) + Documentation fixes and improvements (Ian) + 2.0.1 2014-07-16 Documentation fixes and new QUICKSTART file (Ian) Explicitly specify directories to ignore when cloning (Ian) @@ -25,7 +33,7 @@ Add a ssh_options parameter (Jay Taylor) 2.0beta1 2012-07-27 - Make CLONE command try to make an exact copy including $PGDATA location (Cedric) + Make CLONE command try to make an exact copy including $PGDATA location (Cedric) Add detection of master failure (Jaime) Add the notion of a witness server (Jaime) Add autofailover capabilities (Jaime) From 5dff3017c85c00494c305c44badf37efa3294f6b Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 12 Feb 2015 17:22:34 +0900 Subject: [PATCH 06/29] Update HISTORY file --- HISTORY | 1 + 1 file changed, 1 insertion(+) diff --git a/HISTORY b/HISTORY index 2bb88960..b0f3af26 100644 --- a/HISTORY +++ b/HISTORY @@ -4,6 +4,7 @@ Add -S/--superuser option for witness database creation Use createdb/createuser instead of psql (Jaime) Fixes to witness creation and monitoring (wamonite) + Use default master port if none supplied (Martín) Documentation fixes and improvements (Ian) 2.0.1 2014-07-16 From 0762b28679e4fc7a7195ca9fe55bd0d2d7a34ec1 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 17 Feb 2015 16:12:37 +0900 Subject: [PATCH 07/29] Update HISTORY file with items included in 2.0.2 Also standardize on spaces instead of tabs --- HISTORY | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/HISTORY b/HISTORY index b0f3af26..468f6a95 100644 --- a/HISTORY +++ b/HISTORY @@ -1,19 +1,21 @@ -2.0.2 2015-02-?? - Add "--checksum" in rsync when using "--force" (Jaime) +2.0.3 2015-??-?? Add option "--initdb-no-pwprompt" (Ian) - Add -S/--superuser option for witness database creation + Add -S/--superuser option for witness database creation Ian) + +2.0.2 2015-02-17 + Add "--checksum" in rsync when using "--force" (Jaime) Use createdb/createuser instead of psql (Jaime) Fixes to witness creation and monitoring (wamonite) Use default master port if none supplied (Martín) Documentation fixes and improvements (Ian) -2.0.1 2014-07-16 - Documentation fixes and new QUICKSTART file (Ian) - Explicitly specify directories to ignore when cloning (Ian) - Fix log level for some log messages (Ian) - RHEL/CentOS specfile, init script and Makefile fixes (Nathan Van Overloop) +2.0.1 2014-07-16 + Documentation fixes and new QUICKSTART file (Ian) + Explicitly specify directories to ignore when cloning (Ian) + Fix log level for some log messages (Ian) + RHEL/CentOS specfile, init script and Makefile fixes (Nathan Van Overloop) Debian init script and config file documentation fixes (József Kószó) - Typo fixes (Riegie Godwin Jeyaranchen, PriceChild) + Typo fixes (Riegie Godwin Jeyaranchen, PriceChild) 2.0stable 2014-01-30 Documentation fixes (Christian) @@ -42,15 +44,15 @@ Make the monitoring optional and turned off by default, it can be turned on with --monitoring-history switch (Jaime) Add tunables to specify number of retries to reconnect to master and the time between them (Jaime) -1.2.0 2012-07-27 - Test ssh connection before trying to rsync (Cédric) +1.2.0 2012-07-27 + Test ssh connection before trying to rsync (Cédric) Add CLUSTER SHOW command (Carlo) Add CLUSTER CLEANUP command (Jaime) Add function write_primary_conninfo (Marco) Teach repmgr how to get tablespace's location in different pg version (Jaime) - Improve version message (Carlo) + Improve version message (Carlo) -1.1.1 2012-04-18 +1.1.1 2012-04-18 Add --ignore-rsync-warning (Cédric) Add strnlen for compatibility with OS X (Greg) Improve performance of the repl_status view (Jaime) @@ -61,7 +63,7 @@ 1.1.0 2011-03-09 Make options -U, -R and -p not mandatory (Jaime) -1.1.0b1 2011-02-24 +1.1.0b1 2011-02-24 Fix missing "--force" option in help (Greg Smith) Correct warning message for wal_keep_segments (Bas van Oostveen) Add Debian build/usage docs (Bas, Hannu Krosing, Cedric Villemain) From 6791bd9ad3a5f592593ea68dd77a1ceb4276af60 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 23 Feb 2015 15:17:06 +0900 Subject: [PATCH 08/29] Clean up rempgr debugging output --- repmgr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/repmgr.c b/repmgr.c index 86a9f6aa..236291a8 100644 --- a/repmgr.c +++ b/repmgr.c @@ -1768,7 +1768,7 @@ do_witness_create(void) /* start new instance */ sprintf(script, "%s/pg_ctl %s -w -D %s start", options.pg_bindir, options.pgctl_options, runtime_options.dest_dir); - log_info(_("Start cluster for witness: %s"), script); + log_info(_("Start cluster for witness: %s\n"), script); r = system(script); if (r != 0) { @@ -1815,7 +1815,7 @@ do_witness_create(void) sqlquery_snprintf(sqlquery, "SELECT name, setting " " FROM pg_settings " " WHERE name IN ('hba_file')"); - log_debug(_("witness create: %s"), sqlquery); + log_debug(_("witness create: %s\n"), sqlquery); res = PQexec(masterconn, sqlquery); if (PQresultStatus(res) != PGRES_TUPLES_OK) { @@ -1898,7 +1898,6 @@ do_witness_create(void) sqlquery_snprintf(sqlquery, "ALTER ROLE %s NOSUPERUSER", runtime_options.username); log_info("Drop superuser powers on user for witness db: %s.\n", sqlquery); - log_debug(_("witness create: %s"), sqlquery); res = PQexec(witnessconn, sqlquery); if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) { From 99e1c33668b52e02a9883db3df9f55c8e94e05d7 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Mon, 23 Feb 2015 15:33:41 +0100 Subject: [PATCH 09/29] Fix markup This was broken in commit 8faf41dd94b01aa0735a6ba8b9ead60b65065ac1, most likely because of a runaway search/replace. --- QUICKSTART.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/QUICKSTART.md b/QUICKSTART.md index 04b02818..b71d0fd9 100644 --- a/QUICKSTART.md +++ b/QUICKSTART.md @@ -50,8 +50,8 @@ Installation see README.rst for further details. * Source installation - - `repmgr` source code is hosted at github (https://github.com/2ndQuadrant/`repmgr`); - tar.gz files can be downloaded from https://github.com/2ndQuadrant/`repmgr`/releases . + - `repmgr` source code is hosted at github (https://github.com/2ndQuadrant/repmgr); + tar.gz files can be downloaded from https://github.com/2ndQuadrant/repmgr/releases . `repmgr` can be built easily using PGXS: From 41e9a370afdf8bcc4132d86fc506f4074f75f2c7 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Fri, 27 Feb 2015 10:01:38 +0900 Subject: [PATCH 10/29] Clarify repmgr.conf usage --- QUICKSTART.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/QUICKSTART.md b/QUICKSTART.md index b71d0fd9..dd0ec817 100644 --- a/QUICKSTART.md +++ b/QUICKSTART.md @@ -20,7 +20,7 @@ Conceptual Overview - `repmgrd`: an optional daemon process which runs on standby nodes to monitor replication and node status -Each PostgreSQL node requires a `repmgr` configuration file; additionally +Each PostgreSQL node requires a `repmgr.conf` configuration file; additionally it must be "registered" using the `repmgr` command-line client. `repmgr` stores information about managed nodes in a custom schema on the node's current master database. @@ -92,7 +92,7 @@ usage. ### repmgr configuration -Each PostgreSQL node requires a `repmgr` configuration file containing +Each PostgreSQL node requires a `repmgr.conf` configuration file containing identification and database connection information: cluster=test @@ -111,7 +111,10 @@ identification and database connection information: * `pg_bindir`: (optional) location of PostgreSQL binaries, if not in the default $PATH Note that the configuration file should *not* be stored inside the PostgreSQL -data directory. +data directory. The configuration file can be specified with the +`-f, --config-file=PATH` option and can have any arbitrary name. If no +configuration file is specified, `repmgr` will search for `repmgr.conf` +in the current working directory. Each node configuration needs to be registered with `repmgr`, either using the `repmgr` command line tool, or the `repmgrd` daemon; for details see below. Details From 66b399b886b1995a75624c208056115c0b3ba6ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Marqu=C3=A9s?= Date: Fri, 6 Mar 2015 10:37:43 -0300 Subject: [PATCH 11/29] Add check for wal_level = logical so we don't fail on 9.4 On 9.4 we have logical decoding, which introduced a new wal_level called logical. This level includes all the previous ones, so you can run a hot_standby if wal_level = logical, because the relevant information for hot_standby will be there, plus other information needed for logical decoding. We fix this be adding a second check when wal_level is not hot_standby. --- repmgr.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/repmgr.c b/repmgr.c index 236291a8..c8d09934 100644 --- a/repmgr.c +++ b/repmgr.c @@ -841,7 +841,7 @@ do_standby_clone(void) int r = 0, retval = SUCCESS; - int i, + int i,j, is_standby_retval; bool flag_success = false; bool test_mode = false; @@ -919,11 +919,30 @@ do_standby_clone(void) i = guc_set(conn, "wal_level", "=", "hot_standby"); if (i == 0 || i == -1) { - PQfinish(conn); if (i == 0) - log_err(_("%s needs parameter 'wal_level' to be set to 'hot_standby'\n"), - progname); - exit(ERR_BAD_CONFIG); + { + /* We could be using PG 9.4 with log_level logical, which is good enough for + hot standby replication. + We should check if the wal_level is set to that value, in which case we are + good to proceed. + No need to check if we are in 9.4 first, as the query used in guc_set will just + return zero rows if on < 9.4, and so will work anyway. + */ + j = guc_set(conn, "wal_level", "=", "logical"); + if (j == 0 || j == -1) + { + PQfinish(conn); + if (j == 0) + log_err(_("%s needs parameter 'wal_level' to be set to at least 'hot_standby'\n"), + progname); + exit(ERR_BAD_CONFIG); + } + } + else if (i == -1) + { + PQfinish(conn); + exit(ERR_BAD_CONFIG); + } } i = guc_set_typed(conn, "wal_keep_segments", ">=", From 5a9b6eea1fd8f267429896627b3180a78b9992ab Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Sat, 7 Mar 2015 23:45:07 +0900 Subject: [PATCH 12/29] Prevent trim() from segfaulting on an empty string --- config.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.c b/config.c index 0e24e54f..bf779967 100644 --- a/config.c +++ b/config.c @@ -185,6 +185,10 @@ trim(char *s) char *s1 = s, *s2 = &s[strlen(s) - 1]; + /* If string is empty, no action needed */ + if(s2 < s1) + return s; + /* Trim and delimit right side */ while ((isspace(*s2)) && (s2 >= s1)) --s2; From 7ad001e0c5c9342eb0445e33f094d81ee6ccc7be Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 9 Mar 2015 08:21:54 +0900 Subject: [PATCH 13/29] Parse config file before daemonizing Daemonizing changes the current working directory to '/', which breaks configuration file parsing if the file is in the previous working directory and provided without an explicit path. Also it makes general sense to parse the configuration file before daemonizing. --- repmgrd.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/repmgrd.c b/repmgrd.c index 2ebb7df8..cb0a942f 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -218,6 +218,17 @@ main(int argc, char **argv) } } + /* + * Read the configuration file: repmgr.conf + */ + parse_config(config_file, &local_options); + if (local_options.node == -1) + { + log_err(_("Node information is missing. " + "Check the configuration file, or provide one if you have not done so.\n")); + terminate(ERR_BAD_CONFIG); + } + if (daemonize) { do_daemonize(); @@ -232,17 +243,6 @@ main(int argc, char **argv) setup_event_handlers(); #endif - /* - * Read the configuration file: repmgr.conf - */ - parse_config(config_file, &local_options); - if (local_options.node == -1) - { - log_err(_("Node information is missing. " - "Check the configuration file, or provide one if you have not done so.\n")); - terminate(ERR_BAD_CONFIG); - } - fd = freopen("/dev/null", "r", stdin); if (fd == NULL) { From 5bba37cebd981b766d5e108cf5f190c474e53398 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 11:17:46 -0700 Subject: [PATCH 14/29] autofailover_quick_setup.rst: Replace 'fail-over' with 'failover' Use the more common spelling. Before this commit: $ git grep -i failover | wc -l 67 $ git grep -i fail-over | wc -l 2 --- autofailover_quick_setup.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/autofailover_quick_setup.rst b/autofailover_quick_setup.rst index 1826b521..e5a88650 100644 --- a/autofailover_quick_setup.rst +++ b/autofailover_quick_setup.rst @@ -1,6 +1,6 @@ -===================================================== - PostgreSQL Automatic Fail-Over - User Documentation -===================================================== +==================================================== + PostgreSQL Automatic Failover - User Documentation +==================================================== Automatic Failover ================== @@ -27,7 +27,7 @@ now on the «standbyserver». Summary ------- -2 PostgreSQL servers are involved in the replication. Automatic fail-over need +2 PostgreSQL servers are involved in the replication. Automatic failover need to vote to decide what server it should promote, thus an odd number is required and a witness-repmgrd is installed in a third server where it uses a PostgreSQL cluster to communicate with other repmgrd daemons. From 0d971d9009c651ac9a05acefbe1cacb2fbb61dc3 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 11:19:26 -0700 Subject: [PATCH 15/29] autofailover_quick_setup.rst: Reword name-with-status caution Fix the 'recommanded' typo and reword to drop the passive voice and some awkward phrasing. --- autofailover_quick_setup.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autofailover_quick_setup.rst b/autofailover_quick_setup.rst index e5a88650..7a6d20d7 100644 --- a/autofailover_quick_setup.rst +++ b/autofailover_quick_setup.rst @@ -20,8 +20,8 @@ For convenience, we define: **witness** is the hostname fully qualified of the server used for witness, IP 192.168.1.12 -**Note:** It is not recommanded to use name defining status of a server like «masterserver», -this is a name leading to confusion once a failover take place and the Master is +**Note:** We don't recommend using names with the status of a server like «masterserver», +because it would be confusing once a failover takes place and the Master is now on the «standbyserver». Summary From 25ea635689e19d87de915cf0a3b9071106db52e7 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 11:23:34 -0700 Subject: [PATCH 16/29] autofailover_quick_setup.rst: Reword 'failover need to vote' And some other minor tweaks to this paragraph. I split the witness-repmgrd bit off into its own sentence, since that's pretty independent of the voting business. --- autofailover_quick_setup.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autofailover_quick_setup.rst b/autofailover_quick_setup.rst index 7a6d20d7..d743627f 100644 --- a/autofailover_quick_setup.rst +++ b/autofailover_quick_setup.rst @@ -27,9 +27,9 @@ now on the «standbyserver». Summary ------- -2 PostgreSQL servers are involved in the replication. Automatic failover need -to vote to decide what server it should promote, thus an odd number is required -and a witness-repmgrd is installed in a third server where it uses a PostgreSQL +2 PostgreSQL servers are involved in the replication. Automatic failover needs +a vote to decide what server it should promote, so an odd number is required. +A witness-repmgrd is installed in a third server where it uses a PostgreSQL cluster to communicate with other repmgrd daemons. 1. Install PostgreSQL in all the servers involved (including the server used for From 9517624297d829c6074ab803ef7ac0aa90d7360f Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 11:27:13 -0700 Subject: [PATCH 17/29] autofailover_quick_setup.rst: Replace 'server used for witness' With 'witness server' in most places. When defining the nodes, I went with 'server used as a witness', since '**witness** is the hostname ... of the witness server' sounded like a tautology. The longer phrasing isn't really any different, but it sounds better to me ;). --- autofailover_quick_setup.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/autofailover_quick_setup.rst b/autofailover_quick_setup.rst index d743627f..4e7f1b1d 100644 --- a/autofailover_quick_setup.rst +++ b/autofailover_quick_setup.rst @@ -18,7 +18,7 @@ For convenience, we define: **node2** is the hostname fully qualified of the Standby server, IP 192.168.1.11 **witness** - is the hostname fully qualified of the server used for witness, IP 192.168.1.12 + is the hostname fully qualified of the server used as a witness, IP 192.168.1.12 **Note:** We don't recommend using names with the status of a server like «masterserver», because it would be confusing once a failover takes place and the Master is @@ -32,16 +32,15 @@ a vote to decide what server it should promote, so an odd number is required. A witness-repmgrd is installed in a third server where it uses a PostgreSQL cluster to communicate with other repmgrd daemons. -1. Install PostgreSQL in all the servers involved (including the server used for - witness) +1. Install PostgreSQL in all the servers involved (including the witness server) -2. Install repmgr in all the servers involved (including the server used for witness) +2. Install repmgr in all the servers involved (including the witness server) 3. Configure the Master PostreSQL 4. Clone the Master to the Standby using "repmgr standby clone" command -5. Configure repmgr in all the servers involved (including the server used for witness) +5. Configure repmgr in all the servers involved (including the witness server) 6. Register Master and Standby nodes From 7fed433df157445894a64f4b332c1a8898377097 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 11:29:58 -0700 Subject: [PATCH 18/29] autofailover_quick_setup.rst: 'hostname fully qualified' -> FQDN This is the usual terminology [1]. [1]: http://en.wikipedia.org/wiki/Fully_qualified_domain_name --- autofailover_quick_setup.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autofailover_quick_setup.rst b/autofailover_quick_setup.rst index 4e7f1b1d..2ca320d1 100644 --- a/autofailover_quick_setup.rst +++ b/autofailover_quick_setup.rst @@ -14,11 +14,11 @@ Installation For convenience, we define: **node1** - is the hostname fully qualified of the Master server, IP 192.168.1.10 + is the fully qualified domain name of the Master server, IP 192.168.1.10 **node2** - is the hostname fully qualified of the Standby server, IP 192.168.1.11 + is the fully qualified domain name of the Standby server, IP 192.168.1.11 **witness** - is the hostname fully qualified of the server used as a witness, IP 192.168.1.12 + is the fully qualified domain name of the server used as a witness, IP 192.168.1.12 **Note:** We don't recommend using names with the status of a server like «masterserver», because it would be confusing once a failover takes place and the Master is From d06bd0ddeadf8a7933c3969c6ecd07d6c41ea2f6 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 11:34:42 -0700 Subject: [PATCH 19/29] autofailover_quick_setup.rst: 'allows setups' -> 'allows for' --- autofailover_quick_setup.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autofailover_quick_setup.rst b/autofailover_quick_setup.rst index 2ca320d1..bbf06056 100644 --- a/autofailover_quick_setup.rst +++ b/autofailover_quick_setup.rst @@ -5,7 +5,7 @@ Automatic Failover ================== -repmgr allows setups for automatic failover when it detects the failure of the master node. +repmgr allows for automatic failover when it detects the failure of the master node. Following is a quick setup for this. Installation From 3799d089a1ce2afdc137d47f650c5db545ad1ca8 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 11:40:37 -0700 Subject: [PATCH 20/29] autofailover_quick_setup.rst: 'Log in' -> 'Log in to' For some discussion, see [1]. [1]: http://english.stackexchange.com/questions/5302/log-in-to-or-log-into-or-login-to --- autofailover_quick_setup.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/autofailover_quick_setup.rst b/autofailover_quick_setup.rst index bbf06056..0224a4de 100644 --- a/autofailover_quick_setup.rst +++ b/autofailover_quick_setup.rst @@ -65,7 +65,7 @@ Install repmgr following the steps in the README file. Configure PostreSQL ------------------- -Log in node1. +Log in to node1. Edit the file postgresql.conf and modify the parameters:: @@ -116,7 +116,7 @@ Create the ssh-key for the postgres user and copy it to other servers:: Clone Master ------------ -Log in node2. +Log in to node2. Clone the node1 (the current Master):: @@ -132,7 +132,7 @@ And check everything is fine in the server log. Configure repmgr ---------------- -Log in each server and configure repmgr by editing the file +Log in to each server and configure repmgr by editing the file /etc/repmgr/repmgr.conf:: cluster=my_cluster @@ -170,14 +170,14 @@ Log in each server and configure repmgr by editing the file Register Master and Standby --------------------------- -Log in node1. +Log in to node1. Register the node as Master:: su - postgres repmgr -f /etc/repmgr/repmgr.conf master register -Log in node2. Register it as a standby:: +Log in to node2. Register it as a standby:: su - postgres repmgr -f /etc/repmgr/repmgr.conf standby register @@ -185,7 +185,7 @@ Log in node2. Register it as a standby:: Initialize witness server ------------------------- -Log in witness. +Log in to witness. Initialize the witness server:: @@ -198,7 +198,7 @@ As part of the procees it also ask for the superuser password so it can connect Start the repmgrd daemons ------------------------- -Log in node2 and witness. +Log in to node2 and witness. su - postgres repmgrd -f /etc/repmgr/repmgr.conf --daemonize -> /var/log/postgresql/repmgr.log 2>&1 From bdb8ee1a6f2bd42388068a1f68363e421146c98d Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 11:43:54 -0700 Subject: [PATCH 21/29] autofailover_quick_setup.rst: 'Clone the node1' -> 'Clone node1' This sounds better to me, but maybe that's just my American dialect :p. The issue of what name get articles is complicated [1]. [1]: http://english.stackexchange.com/questions/59271/why-there-is-the-before-some-names-but-not-others --- autofailover_quick_setup.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autofailover_quick_setup.rst b/autofailover_quick_setup.rst index 0224a4de..91074445 100644 --- a/autofailover_quick_setup.rst +++ b/autofailover_quick_setup.rst @@ -118,7 +118,7 @@ Clone Master Log in to node2. -Clone the node1 (the current Master):: +Clone node1 (the current Master):: su - postgres repmgr -d repmgr -U repmgr -h node1 standby clone From af7dee05a4693d3c2092a939742954a4fd1065a4 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 11:49:10 -0700 Subject: [PATCH 22/29] autofailover_quick_setup.rst: 'it is needed' -> 'you need' Drop the passive voice. --- autofailover_quick_setup.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autofailover_quick_setup.rst b/autofailover_quick_setup.rst index 91074445..0ba9987d 100644 --- a/autofailover_quick_setup.rst +++ b/autofailover_quick_setup.rst @@ -153,7 +153,7 @@ Log in to each server and configure repmgr by editing the file **node_name** is an identifier for every node. **conninfo** - is used to connect to the local PostgreSQL server (where the configuration file is) from any node. In the witness server configuration it is needed to add a 'port=5499' to the conninfo. + is used to connect to the local PostgreSQL server (where the configuration file is) from any node. In the witness server configuration you need to add a 'port=5499' to the conninfo. **master_response_timeout** is the maximum amount of time we are going to wait before deciding the master has died and start failover procedure. **reconnect_attempts** From 5c64f09889255b95c14845e664d66758e7fdc0d9 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 11:49:50 -0700 Subject: [PATCH 23/29] autofailover_quick_setup.rst: 'failover procedure' -> 'the failover procedure' --- autofailover_quick_setup.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autofailover_quick_setup.rst b/autofailover_quick_setup.rst index 0ba9987d..a4fd7b47 100644 --- a/autofailover_quick_setup.rst +++ b/autofailover_quick_setup.rst @@ -155,11 +155,11 @@ Log in to each server and configure repmgr by editing the file **conninfo** is used to connect to the local PostgreSQL server (where the configuration file is) from any node. In the witness server configuration you need to add a 'port=5499' to the conninfo. **master_response_timeout** - is the maximum amount of time we are going to wait before deciding the master has died and start failover procedure. + is the maximum amount of time we are going to wait before deciding the master has died and start the failover procedure. **reconnect_attempts** - is the number of times we will try to reconnect to master after a failure has been detected and before start failover procedure. + is the number of times we will try to reconnect to master after a failure has been detected and before start the failover procedure. **reconnect_interval** - is the amount of time between retries to reconnect to master after a failure has been detected and before start failover procedure. + is the amount of time between retries to reconnect to master after a failure has been detected and before start the failover procedure. **failover** configure behavior: *manual* or *automatic*. **promote_command** From e0b82393b065b32760593bea38d94750aed5c258 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 11:56:36 -0700 Subject: [PATCH 24/29] autofailover_quick_setup.rst: Restructure notes about witness server information Avoid repeating "it needs", and explain that the superuser password it needs is for the witness database (and not a sudo password, or a superuser on the production database). --- autofailover_quick_setup.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/autofailover_quick_setup.rst b/autofailover_quick_setup.rst index a4fd7b47..eaa01c95 100644 --- a/autofailover_quick_setup.rst +++ b/autofailover_quick_setup.rst @@ -192,8 +192,15 @@ Initialize the witness server:: su - postgres repmgr -d repmgr -U repmgr -h 192.168.1.10 -D $WITNESS_PGDATA -f /etc/repmgr/repmgr.conf witness create -It needs information to connect to the master to copy the configuration of the cluster, also it needs to know where it should initialize it's own $PGDATA. -As part of the procees it also ask for the superuser password so it can connect when needed. +The witness server needs the following information from the command +line: + +* Connection details for the current master, to copy the cluster + configuration. +* A location for initializing its own $PGDATA. + +It will also ask for the superuser password on the witness database so +it can reconnect when needed. Start the repmgrd daemons ------------------------- From 9e5b3e0a2da766a40692e8ffa89533042518bcbd Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 11:59:46 -0700 Subject: [PATCH 25/29] autofailover_quick_setup.rst: Replace tabs with spaces Before this commit there was inconsistency over the indentation. This commit consolidates around two spaces. --- autofailover_quick_setup.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/autofailover_quick_setup.rst b/autofailover_quick_setup.rst index eaa01c95..d08354a1 100644 --- a/autofailover_quick_setup.rst +++ b/autofailover_quick_setup.rst @@ -72,7 +72,7 @@ Edit the file postgresql.conf and modify the parameters:: listen_addresses='*' wal_level = 'hot_standby' archive_mode = on - archive_command = 'cd .' # we can also use exit 0, anything that + archive_command = 'cd .' # we can also use exit 0, anything that # just does nothing max_wal_senders = 10 wal_keep_segments = 5000 # 80 GB required on pg_xlog @@ -207,8 +207,8 @@ Start the repmgrd daemons Log in to node2 and witness. - su - postgres - repmgrd -f /etc/repmgr/repmgr.conf --daemonize -> /var/log/postgresql/repmgr.log 2>&1 + su - postgres + repmgrd -f /etc/repmgr/repmgr.conf --daemonize -> /var/log/postgresql/repmgr.log 2>&1 **Note:** The Master does not need a repmgrd daemon. @@ -218,12 +218,12 @@ Suspend Automatic behavior Edit the repmgr.conf of the node to remove from automatic processing and change:: - failover=manual + failover=manual Then, signal repmgrd daemon:: - su - postgres - kill -HUP `pidof repmgrd` + su - postgres + kill -HUP `pidof repmgrd` Usage ===== From 2fa2dfff9535b049bf56d93cd7707fd91adebe91 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 12:00:30 -0700 Subject: [PATCH 26/29] autofailover_quick_setup.rst: Double-colon before literal block --- autofailover_quick_setup.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autofailover_quick_setup.rst b/autofailover_quick_setup.rst index d08354a1..647c5f76 100644 --- a/autofailover_quick_setup.rst +++ b/autofailover_quick_setup.rst @@ -205,7 +205,7 @@ it can reconnect when needed. Start the repmgrd daemons ------------------------- -Log in to node2 and witness. +Log in to node2 and witness:: su - postgres repmgrd -f /etc/repmgr/repmgr.conf --daemonize -> /var/log/postgresql/repmgr.log 2>&1 From 5d26e27b48bfa36eafe92f354b8f08abebca7be4 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 12:04:38 -0700 Subject: [PATCH 27/29] autofailover_quick_setup.rst: '$(...)' for command substitution Both are in POSIX [1], but the dollar-paren form is nicer [2]. [1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03 [2]: http://mywiki.wooledge.org/BashFAQ/082 --- autofailover_quick_setup.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autofailover_quick_setup.rst b/autofailover_quick_setup.rst index 647c5f76..3ed0820f 100644 --- a/autofailover_quick_setup.rst +++ b/autofailover_quick_setup.rst @@ -223,7 +223,7 @@ Edit the repmgr.conf of the node to remove from automatic processing and change: Then, signal repmgrd daemon:: su - postgres - kill -HUP `pidof repmgrd` + kill -HUP $(pidof repmgrd) Usage ===== From 22423aa51af13892400b9734dd639931390c20d3 Mon Sep 17 00:00:00 2001 From: Germ van Ek Date: Mon, 23 Mar 2015 16:53:04 +0100 Subject: [PATCH 28/29] Added postgresql-9.4 to debian control file --- debian/DEBIAN/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/DEBIAN/control b/debian/DEBIAN/control index e96a799a..b0d776db 100644 --- a/debian/DEBIAN/control +++ b/debian/DEBIAN/control @@ -3,7 +3,7 @@ Version: 2.0beta2 Section: database Priority: optional Architecture: all -Depends: rsync, postgresql-9.0 | postgresql-9.1 | postgresql-9.2 | postgresql-9.3 +Depends: rsync, postgresql-9.0 | postgresql-9.1 | postgresql-9.2 | postgresql-9.3 | postgresql-9.4 Maintainer: Jaime Casanova Description: PostgreSQL replication setup, magament and monitoring has two main executables From 81b7b3bae7098ab987ce7f2642e3e1e46b1efd02 Mon Sep 17 00:00:00 2001 From: John Galt Date: Mon, 23 Mar 2015 21:08:48 -0400 Subject: [PATCH 29/29] Fixed typo --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 2fdbae19..e498914b 100644 --- a/README.rst +++ b/README.rst @@ -427,7 +427,7 @@ system you already have superuser access to. Clearing the PostgreSQL installation on the Standby --------------------------------------------------- -To setup a new streaming replica, startin by removing any PostgreSQL +To setup a new streaming replica, start by removing any PostgreSQL installation on the existing standby nodes. * Stop any server on "node2" and "node3". You can confirm the database