Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
postgresql_repmgr_installation [2021/09/16 07:51] – andonovj | postgresql_repmgr_installation [2021/09/28 11:30] (current) – andonovj | ||
---|---|---|---|
Line 9: | Line 9: | ||
* 2nd Quandrant - For Rempgr | * 2nd Quandrant - For Rempgr | ||
+ | |||
+ | {{: | ||
=====Virtual Environment Config===== | =====Virtual Environment Config===== | ||
Line 52: | Line 54: | ||
(1..2).each do |n| | (1..2).each do |n| | ||
config.vm.define " | config.vm.define " | ||
- | define.vm.box = "consumerlab/ubuntu-server-16-04-LTS" | + | define.vm.box = "bento/ubuntu-20.04" |
define.ssh.insert_key = false | define.ssh.insert_key = false | ||
define.vm.hostname = " | define.vm.hostname = " | ||
Line 69: | Line 71: | ||
- | ====Server Config==== | + | =====Server Config===== |
+ | For the servers we have to: | ||
+ | - Configure /etc/hosts | ||
+ | - Configure 2nd Quadrant Repository | ||
+ | - Install 2nd Quadrant Packages | ||
+ | |||
+ | |||
+ | So, let's get going. | ||
+ | |||
+ | |||
+ | ====Modify /etc/hosts ==== | ||
+ | That is pretty trivial, just add the IPs and the hostnames to /etc/hosts: | ||
+ | |||
+ | |||
+ | < | ||
+ | 10.0.15.21 server1 | ||
+ | 10.0.15.22 server2 | ||
+ | </ | ||
+ | |||
+ | That will allow, the hosts to see and ping each other. | ||
+ | |||
+ | Then we can configure the repositories: | ||
+ | |||
+ | |||
+ | ====Configure Repositories==== | ||
+ | I decided to use 2nd quadrant packages, as they are the ones I use for work as well :) | ||
+ | First thing first, we have to update our repos and pull the latest metadata from them. | ||
+ | |||
+ | < | ||
+ | root@server1: | ||
+ | Hit:1 http:// | ||
+ | Get:2 http:// | ||
+ | Get:3 http:// | ||
+ | Get:4 http:// | ||
+ | Get:5 http:// | ||
+ | Get:6 http:// | ||
+ | Get:7 http:// | ||
+ | Get:8 http:// | ||
+ | Get:9 http:// | ||
+ | Get:10 http:// | ||
+ | Get:11 http:// | ||
+ | Get:12 http:// | ||
+ | Get:13 http:// | ||
+ | Get:14 http:// | ||
+ | Get:15 http:// | ||
+ | Get:16 http:// | ||
+ | Get:17 http:// | ||
+ | Get:18 http:// | ||
+ | Get:19 http:// | ||
+ | Get:20 http:// | ||
+ | Get:21 http:// | ||
+ | Get:22 http:// | ||
+ | Get:23 http:// | ||
+ | Get:24 http:// | ||
+ | Get:25 http:// | ||
+ | Get:26 http:// | ||
+ | Get:27 http:// | ||
+ | Get:28 http:// | ||
+ | Get:29 http:// | ||
+ | Fetched 7,652 kB in 7s (1,048 kB/s) | ||
+ | Reading package lists... Done | ||
+ | </ | ||
+ | |||
+ | ====Install PostgreSQL==== | ||
+ | Then we can proceed with installation of PostgreSQL | ||
+ | < | ||
+ | root@server1: | ||
+ | Reading package lists... Done | ||
+ | Building dependency tree | ||
+ | Reading state information... Done | ||
+ | The following additional packages will be installed: | ||
+ | libllvm10 libpq5 libsensors-config libsensors5 postgresql-12 postgresql-client-12 postgresql-client-common postgresql-common ssl-cert sysstat | ||
+ | Suggested packages: | ||
+ | lm-sensors postgresql-doc postgresql-doc-12 libjson-perl openssl-blacklist isag | ||
+ | The following NEW packages will be installed: | ||
+ | libllvm10 libpq5 libsensors-config libsensors5 postgresql postgresql-12 postgresql-client-12 postgresql-client-common postgresql-common ssl-cert sysstat | ||
+ | 0 upgraded, 11 newly installed, 0 to remove and 54 not upgraded. | ||
+ | Need to get 15.1 MB/30.6 MB of archives. | ||
+ | After this operation, 122 MB of additional disk space will be used. | ||
+ | Get:1 http:// | ||
+ | Get:2 http:// | ||
+ | Get:3 http:// | ||
+ | Get:4 http:// | ||
+ | Fetched 15.1 MB in 15s (1,015 kB/s) | ||
+ | Preconfiguring packages ... | ||
+ | *************************************************** | ||
+ | |||
+ | Success. You can now start the database server using: | ||
+ | |||
+ | pg_ctlcluster 12 main start | ||
+ | |||
+ | Ver Cluster Port Status Owner Data directory | ||
+ | 12 main 5432 down | ||
+ | update-alternatives: | ||
+ | Setting up sysstat (12.2.0-2ubuntu0.1) ... | ||
+ | |||
+ | Creating config file / | ||
+ | update-alternatives: | ||
+ | Created symlink / | ||
+ | Setting up postgresql (12+214ubuntu0.1) ... | ||
+ | Processing triggers for systemd (245.4-4ubuntu3.11) ... | ||
+ | Processing triggers for man-db (2.9.1-1) ... | ||
+ | Processing triggers for libc-bin (2.31-0ubuntu9.2) ... | ||
+ | </ | ||
+ | |||
+ | Do this on both machines: server1 and server2 | ||
+ | |||
+ | ====Install REPMGR Repos==== | ||
+ | Then we can proceed with adding the repo for REPMGR | ||
+ | |||
+ | < | ||
+ | root@server1: | ||
+ | Hit:1 http:// | ||
+ | Get:2 http:// | ||
+ | Hit:3 http:// | ||
+ | Hit:4 http:// | ||
+ | Get:5 http:// | ||
+ | Err:2 http:// | ||
+ | The following signatures couldn' | ||
+ | Reading package lists... Done | ||
+ | W: GPG error: http:// | ||
+ | E: The repository ' | ||
+ | N: Updating from such a repository can't be done securely, and is therefore disabled by default. | ||
+ | N: See apt-secure(8) manpage for repository creation and user configuration details. | ||
+ | root@server1: | ||
+ | Hit:1 http:// | ||
+ | Hit:2 http:// | ||
+ | Get:3 http:// | ||
+ | Hit:4 http:// | ||
+ | Get:5 http:// | ||
+ | Err:3 http:// | ||
+ | The following signatures couldn' | ||
+ | Reading package lists... Done | ||
+ | W: GPG error: http:// | ||
+ | E: The repository ' | ||
+ | N: Updating from such a repository can't be done securely, and is therefore disabled by default. | ||
+ | N: See apt-secure(8) manpage for repository creation and user configuration details. | ||
+ | root@server1: | ||
+ | </ | ||
+ | |||
+ | ====Configure SSH keys==== | ||
+ | To configure passwordless connection, we have to: | ||
+ | |||
+ | - Generate public / private key pair | ||
+ | - Put the public key in the authorized keys on the other host (e.g. the public key of server1, in the authorized_keys file on server2) | ||
+ | |||
+ | So let's get going: | ||
+ | |||
+ | |||
+ | < | ||
+ | postgres@server2: | ||
+ | Generating public/ | ||
+ | Enter file in which to save the key (/ | ||
+ | Created directory '/ | ||
+ | Enter passphrase (empty for no passphrase): | ||
+ | Enter same passphrase again: | ||
+ | Your identification has been saved in / | ||
+ | Your public key has been saved in / | ||
+ | The key fingerprint is: | ||
+ | SHA256: | ||
+ | The key's randomart image is: | ||
+ | +---[RSA 3072]----+ | ||
+ | | oo .oo. | | ||
+ | | . .. + o.. | | ||
+ | | . .. o Ooo | | ||
+ | |. .. = E =o | | ||
+ | | o+ * o S. | | ||
+ | |.o B. +.. | | ||
+ | |. o..* * | | ||
+ | | . o=.B o | | ||
+ | | ..o*== | ||
+ | +----[SHA256]-----+ | ||
+ | </ | ||
+ | |||
+ | This will generate us two files: Private and Public key. Private key, NEVER SHARE :) | ||
+ | |||
+ | < | ||
+ | postgres@server2: | ||
+ | total 20 | ||
+ | -rw-r--r-- 1 postgres postgres | ||
+ | -rw------- 1 postgres postgres 2602 Sep 16 08:58 id_rsa | ||
+ | </ | ||
+ | |||
+ | The content of that server and put it in the authorized_keys file of server1 and vica versa: | ||
+ | |||
+ | |||
+ | < | ||
+ | postgres@server1: | ||
+ | total 24 | ||
+ | -rw-r--r-- 1 postgres postgres | ||
+ | -rw------- 1 postgres postgres 2602 Sep 16 08:57 id_rsa | ||
+ | -rw-rw-r-- 1 postgres postgres | ||
+ | -rw-r--r-- 1 postgres postgres | ||
+ | drwx------ 2 postgres postgres 4096 Sep 16 08:59 . | ||
+ | drwxr-xr-x 5 postgres postgres 4096 Sep 16 09:12 .. | ||
+ | postgres@server1: | ||
+ | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDc7WdWJWmc6ArXUkFFhArVa/ | ||
+ | |||
+ | postgres@server1: | ||
+ | </ | ||
+ | |||
+ | |||
+ | After you do that on both servers, you can connect without password: | ||
+ | |||
+ | < | ||
+ | postgres@server1: | ||
+ | Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-80-generic x86_64) | ||
+ | |||
+ | * Documentation: | ||
+ | * Management: | ||
+ | * Support: | ||
+ | |||
+ | System information as of Thu 16 Sep 2021 09:30:52 AM UTC | ||
+ | |||
+ | System load: 0.08 Processes: | ||
+ | Usage of /: 2.8% of 61.31GB | ||
+ | Memory usage: 25% IPv4 address for eth0: 10.0.2.15 | ||
+ | Swap usage: | ||
+ | |||
+ | |||
+ | This system is built by the Bento project by Chef Software | ||
+ | More information can be found at https:// | ||
+ | Last login: Thu Sep 16 08:59:34 2021 from 10.0.15.21 | ||
+ | postgres@server2: | ||
+ | </ | ||
+ | |||
+ | =====Cluster Environment===== | ||
+ | After we've installed and configured all the packages, we can proceed with cluster configuration. | ||
+ | Firstly, we have to configure the database and the users: | ||
+ | |||
+ | ====Configure User==== | ||
+ | The user to be used for the replication can be configured as so: | ||
+ | |||
+ | < | ||
+ | root@server1: | ||
+ | postgres@server1: | ||
+ | postgres@server1: | ||
+ | ALTER ROLE | ||
+ | postgres@server1: | ||
+ | postgres@server1: | ||
+ | </ | ||
+ | |||
+ | Do that on both servers. | ||
+ | |||
+ | After, we have done that, we can configure security connection to the PostgreSQL in pg_hba.conf | ||
+ | |||
+ | ====Connection Configuration==== | ||
+ | To allow repmgr user to be able to connect to PostgreSQL, we need to append to the pg_hba.conf file the following entries. | ||
+ | |||
+ | < | ||
+ | host repmgr repmgr 10.0.15.21/ | ||
+ | host replication repmgr 10.0.15.21/ | ||
+ | host repmgr repmgr 10.0.15.22/ | ||
+ | host replication repmgr 10.0.15.22/ | ||
+ | </ | ||
+ | |||
+ | We can test the settings as follows: | ||
+ | |||
+ | |||
+ | < | ||
+ | postgres@server2:/ | ||
+ | psql (12.8 (Ubuntu 12.8-0ubuntu0.20.04.1)) | ||
+ | SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, | ||
+ | Type " | ||
+ | |||
+ | repmgr=# \q | ||
+ | postgres@server2:/ | ||
+ | psql (12.8 (Ubuntu 12.8-0ubuntu0.20.04.1)) | ||
+ | SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, | ||
+ | Type " | ||
+ | |||
+ | repmgr=# | ||
+ | </ | ||
+ | |||
+ | Finally we have to set pre-loaded library for repmgr in the postgresql.conf | ||
+ | |||
+ | < | ||
+ | shared_preload_libraries = ' | ||
+ | </ | ||
+ | |||
+ | Do that on both servers, to verify the configuration. | ||
+ | Now, finally we can configure the REPMGR | ||
+ | |||
+ | =====REPMGR===== | ||
+ | The default configuration of Repmgr is located in: | ||
+ | |||
+ | * / | ||
+ | * / | ||
+ | |||
+ | We can do a basic configuration as follows: | ||
+ | |||
+ | ====Configuration==== | ||
+ | < | ||
+ | cluster=cluster | ||
+ | node_id=(1/ | ||
+ | node_name=server2 | ||
+ | conninfo=' | ||
+ | failover=automatic | ||
+ | promote_command=' | ||
+ | follow_command=' | ||
+ | logfile='/ | ||
+ | loglevel=NOTICE | ||
+ | reconnect_attempts=4 | ||
+ | reconnect_interval=5 | ||
+ | data_directory='/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | This files, defines the structure of the replication. Including the commands for promotion and follow-up command. | ||
+ | The next file, will define either will be enabled or not, and which will file it will use. | ||
+ | |||
+ | < | ||
+ | # default settings for repmgrd. This file is source by /bin/sh from | ||
+ | # / | ||
+ | |||
+ | # disable repmgrd by default so it won't get started upon installation | ||
+ | # valid values: yes/no | ||
+ | REPMGRD_ENABLED=yes | ||
+ | |||
+ | # configuration file (required) | ||
+ | REPMGRD_CONF="/ | ||
+ | |||
+ | # additional options | ||
+ | # | ||
+ | |||
+ | # user to run repmgrd as | ||
+ | # | ||
+ | |||
+ | # repmgrd binary | ||
+ | # | ||
+ | |||
+ | # pid file | ||
+ | # | ||
+ | </ | ||
+ | |||
+ | Furthermore, | ||
+ | |||
+ | |||
+ | < | ||
+ | root@server2: | ||
+ | </ | ||
+ | |||
+ | We have to do that on both servers. | ||
+ | ====Cluster Initialization==== | ||
+ | To initialize a cluster, we can do it as so: | ||
+ | |||
+ | |||
+ | < | ||
+ | postgres@server1: | ||
+ | WARNING: the following problems were found in the configuration file: | ||
+ | parameter " | ||
+ | parameter " | ||
+ | parameter " | ||
+ | INFO: connecting to primary database... | ||
+ | NOTICE: attempting to install extension " | ||
+ | NOTICE: " | ||
+ | NOTICE: primary node record (ID: 1) registered | ||
+ | postgres@server1: | ||
+ | </ | ||
+ | |||
+ | This will initialize the server and we can check that: | ||
+ | |||
+ | < | ||
+ | postgres@server1: | ||
+ | WARNING: the following problems were found in the configuration file: | ||
+ | parameter " | ||
+ | parameter " | ||
+ | parameter " | ||
+ | ID | Name | Role | Status | ||
+ | ----+---------+---------+-----------+----------+----------+----------+----------+---------------------------------------------------------- | ||
+ | | ||
+ | postgres@server1: | ||
+ | </ | ||
+ | |||
+ | After that is done, we can set-up the standby server (e.g. server2) | ||
+ | |||
+ | |||
+ | ====Setup Standby==== | ||
+ | To setup standby, we have to delete everything from the server and clone it: | ||
+ | |||
+ | |||
+ | < | ||
+ | root@server2: | ||
+ | root@server2: | ||
+ | postgres@server2: | ||
+ | WARNING: the following problems were found in the configuration file: | ||
+ | parameter " | ||
+ | parameter " | ||
+ | parameter " | ||
+ | NOTICE: destination directory "/ | ||
+ | INFO: connecting to source node | ||
+ | DETAIL: connection string is: host=server1 user=repmgr dbname=repmgr | ||
+ | DETAIL: current installation size is 31 MB | ||
+ | NOTICE: checking for available walsenders on the source node (2 required) | ||
+ | NOTICE: checking replication connections can be made to the source server (2 required) | ||
+ | INFO: creating directory "/ | ||
+ | NOTICE: starting backup (using pg_basebackup)... | ||
+ | HINT: this may take some time; consider using the -c/ | ||
+ | INFO: executing: | ||
+ | pg_basebackup -l " | ||
+ | NOTICE: standby clone (using pg_basebackup) complete | ||
+ | NOTICE: you can now start your PostgreSQL server | ||
+ | HINT: for example: pg_ctl -D / | ||
+ | HINT: after starting the server, you need to register this standby with " | ||
+ | postgres@server2: | ||
+ | </ | ||
+ | |||
+ | After that, we should be able to see the replication working: | ||
+ | |||
+ | < | ||
+ | postgres@server2: | ||
+ | WARNING: the following problems were found in the configuration file: | ||
+ | parameter " | ||
+ | parameter " | ||
+ | parameter " | ||
+ | ID | Name | Role | Status | ||
+ | ----+---------+---------+-----------+----------+----------+----------+----------+---------------------------------------------------------- | ||
+ | | ||
+ | | ||
+ | postgres@server2: | ||
+ | </ | ||
+ | |||
+ | |||
+ | We can test the connection as follows: | ||
+ | |||
+ | ====Test Configuration==== | ||
+ | Firstly, we will test the normal functionality and then we will test the failove. | ||
+ | |||
+ | |||
+ | For the functionality, | ||
+ | |||
+ | |||
+ | ==On Primary== | ||
+ | < | ||
+ | repmgr=# create table test(id integer); | ||
+ | CREATE TABLE | ||
+ | repmgr=# insert into test values(1); | ||
+ | INSERT 0 1 | ||
+ | repmgr=# commit; | ||
+ | WARNING: | ||
+ | COMMIT | ||
+ | repmgr=# | ||
+ | </ | ||
+ | |||
+ | ==Standby== | ||
+ | Now, we can test it on the standby: | ||
+ | |||
+ | < | ||
+ | postgres=# \c repmgr | ||
+ | You are now connected to database " | ||
+ | repmgr=# select * from test; | ||
+ | id | ||
+ | ---- | ||
+ | 1 | ||
+ | (1 row) | ||
+ | |||
+ | repmgr=# | ||
+ | </ | ||
+ | |||
+ | Now, let's test the failover: | ||
+ | |||
+ | ====Automatic Failover==== | ||
+ | To test that, we can shutdown the primary and see if it is failover automatically (as per our settings) | ||
+ | Now, I changed a little bit the config, so please check Appendix A. | ||
+ | |||
+ | ===Modify Postgres user=== | ||
+ | Firstly, we need to add the postgres user to the sudo group: | ||
+ | |||
+ | < | ||
+ | ### Server 1 | ||
+ | root@server2:/ | ||
+ | root@server2:/ | ||
+ | |||
+ | ### Server 2 | ||
+ | root@server2:/ | ||
+ | root@server2:/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===Test the failover=== | ||
+ | Now, we can finally test the failover. | ||
+ | |||
+ | < | ||
+ | postgres@server1:/ | ||
+ | ID | Name | Role | Status | ||
+ | ----+---------+---------+-----------+----------+----------+----------+----------+----------------------------------------------------- | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | |||
+ | We can simply shutdown the prod: | ||
+ | |||
+ | < | ||
+ | root@server2:/ | ||
+ | </ | ||
+ | |||
+ | Once, this is done, we can see the log file from server1: | ||
+ | |||
+ | < | ||
+ | [2021-09-28 10:46:45] [INFO] primary and this node have the same location (" | ||
+ | [2021-09-28 10:46:45] [INFO] no other sibling nodes - we win by default | ||
+ | [2021-09-28 10:46:45] [DEBUG] election result: WON | ||
+ | [2021-09-28 10:46:45] [NOTICE] this node is the only available candidate and will now promote itself | ||
+ | [2021-09-28 10:46:45] [INFO] promote_command is: | ||
+ | " | ||
+ | [2021-09-28 10:46:45] [NOTICE] redirecting logging output to "/ | ||
+ | |||
+ | [2021-09-28 10:46:45] [DEBUG] connecting to: " | ||
+ | [2021-09-28 10:46:45] [DEBUG] connecting to: " | ||
+ | [2021-09-28 10:46:45] [DEBUG] connecting to: " | ||
+ | [2021-09-28 10:46:45] [NOTICE] promoting standby to primary | ||
+ | [2021-09-28 10:46:45] [DETAIL] promoting server " | ||
+ | [2021-09-28 10:46:45] [NOTICE] waiting up to 60 seconds (parameter " | ||
+ | [2021-09-28 10:46:46] [DEBUG] setting node 1 as primary and marking existing primary as failed | ||
+ | [2021-09-28 10:46:46] [NOTICE] STANDBY PROMOTE successful | ||
+ | [2021-09-28 10:46:46] [DETAIL] server " | ||
+ | [2021-09-28 10:46:46] [INFO] 0 followers to notify | ||
+ | [2021-09-28 10:46:46] [INFO] switching to primary monitoring mode | ||
+ | [2021-09-28 10:46:46] [NOTICE] monitoring cluster primary " | ||
+ | </ | ||
+ | |||
+ | As we can see, server1 has been promoted to primary, that however leaves us to deal with the aftermath. | ||
+ | |||
+ | ===Dealing with the aftermath=== | ||
+ | Now, we have one primary and 1 failed primary, we need to re-establish connection. | ||
+ | |||
+ | < | ||
+ | postgres@server1:/ | ||
+ | DEBUG: connecting to: " | ||
+ | DEBUG: connecting to: " | ||
+ | DEBUG: connecting to: " | ||
+ | ID | Name | Role | Status | ||
+ | ----+---------+---------+-----------+----------+----------+----------+----------+---------------------------------------------------------- | ||
+ | | ||
+ | | ||
+ | |||
+ | WARNING: following issues were detected | ||
+ | - unable to connect to node " | ||
+ | HINT: execute with --verbose option to see connection error messages | ||
+ | postgres@server1: | ||
+ | </ | ||
+ | |||
+ | We can re-establish the connection as follows: | ||
+ | |||
+ | 1. Clear the old path and Resnap: | ||
+ | |||
+ | < | ||
+ | root@server2:/ | ||
+ | root@server2:/ | ||
+ | postgres@server2: | ||
+ | WARNING: following problems with command line parameters detected: | ||
+ | " | ||
+ | NOTICE: destination directory "/ | ||
+ | INFO: connecting to source node | ||
+ | DETAIL: connection string is: host=server1 user=repmgr dbname=repmgr | ||
+ | DETAIL: current installation size is 31 MB | ||
+ | DEBUG: 2 node records returned by source node | ||
+ | DEBUG: connecting to: " | ||
+ | DEBUG: upstream_node_id determined as 1 | ||
+ | NOTICE: checking for available walsenders on the source node (2 required) | ||
+ | NOTICE: checking replication connections can be made to the source server (2 required) | ||
+ | INFO: creating directory "/ | ||
+ | DEBUG: create_replication_slot(): | ||
+ | NOTICE: starting backup (using pg_basebackup)... | ||
+ | HINT: this may take some time; consider using the -c/ | ||
+ | INFO: executing: | ||
+ | / | ||
+ | DEBUG: connecting to: " | ||
+ | NOTICE: standby clone (using pg_basebackup) complete | ||
+ | NOTICE: you can now start your PostgreSQL server | ||
+ | HINT: for example: sudo systemctl start postgresql | ||
+ | HINT: after starting the server, you need to re-register this standby with " | ||
+ | postgres@server2: | ||
+ | </ | ||
+ | |||
+ | 2. Startup the postgresql | ||
+ | 3. Re-register | ||
+ | |||
+ | < | ||
+ | postgres@server2: | ||
+ | root@server2:/ | ||
+ | root@server2:/ | ||
+ | postgres@server2: | ||
+ | INFO: connecting to local node " | ||
+ | DEBUG: connecting to: " | ||
+ | INFO: connecting to primary database | ||
+ | DEBUG: connecting to: " | ||
+ | INFO: standby registration complete | ||
+ | postgres@server2: | ||
+ | </ | ||
+ | |||
+ | |||
+ | Now we can check our status as follows: | ||
+ | |||
+ | |||
+ | < | ||
+ | postgres@server2: | ||
+ | ID | Name | Role | Status | ||
+ | ----+---------+---------+-----------+----------+----------+----------+----------+------------------------------------------------------ | ||
+ | | ||
+ | | ||
+ | postgres@server2: | ||
+ | </ | ||
+ | |||
+ | |||
+ | For that configuration I have used the following appendix: | ||
+ | ===Appendix=== | ||
+ | < | ||
+ | node_id=' | ||
+ | node_name=' | ||
+ | conninfo=' | ||
+ | data_directory='/ | ||
+ | config_directory='/ | ||
+ | replication_user=' | ||
+ | replication_type=' | ||
+ | location=' | ||
+ | use_replication_slots=' | ||
+ | witness_sync_interval=15 | ||
+ | log_level=' | ||
+ | log_facility=' | ||
+ | log_file='/ | ||
+ | log_status_interval=300 | ||
+ | pg_bindir='/ | ||
+ | repmgr_bindir='/ | ||
+ | use_primary_conninfo_password=false | ||
+ | passfile='/ | ||
+ | ssh_options=' | ||
+ | promote_check_timeout=60 | ||
+ | promote_check_interval=1 | ||
+ | primary_follow_timeout=60 | ||
+ | standby_follow_timeout=15 | ||
+ | shutdown_check_timeout=60 | ||
+ | standby_reconnect_timeout=60 | ||
+ | node_rejoin_timeout=60 | ||
+ | failover=' | ||
+ | priority=100 | ||
+ | reconnect_attempts=6 | ||
+ | reconnect_interval=10 | ||
+ | promote_command=' | ||
+ | follow_command=' | ||
+ | primary_notification_timeout=60 | ||
+ | repmgrd_standby_startup_timeout=60 | ||
+ | monitoring_history=no | ||
+ | monitor_interval_secs=2 | ||
+ | degraded_monitoring_timeout=-1 | ||
+ | async_query_timeout=60 | ||
+ | standby_disconnect_on_failover=false | ||
+ | primary_visibility_consensus=false | ||
+ | service_start_command ='sudo systemctl start postgresql' | ||
+ | service_stop_command ='sudo systemctl stop postgresql' | ||
+ | service_restart_command ='sudo systemctl restart postgresql' | ||
+ | service_reload_command ='sudo systemctl reload postgresql' | ||
+ | archive_ready_warning=16 | ||
+ | archive_ready_critical=128 | ||
+ | replication_lag_warning=300 | ||
+ | replication_lag_critical=600 | ||
+ | bdr_local_monitoring_only=false | ||
+ | bdr_recovery_timeout=30 | ||
+ | </ | ||
+ | ====Manual Failover==== | ||