From 5bba37cebd981b766d5e108cf5f190c474e53398 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 14 Mar 2015 11:17:46 -0700 Subject: [PATCH 01/14] 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 02/14] 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 03/14] 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 04/14] 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 05/14] 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 06/14] 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 07/14] 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 08/14] 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 09/14] 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 10/14] 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 11/14] 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 12/14] 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 13/14] 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 14/14] 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 =====