From 2f529e20c100862bdc074c72164a850eb5429cdc Mon Sep 17 00:00:00 2001 From: Gianni Ciolli Date: Fri, 22 Jul 2016 15:08:21 +0200 Subject: [PATCH] Barman support, draft #1 TODO: we need to check what happens with configuration files placed in non-standard locations. --- README.md | 70 +++++++ config.c | 10 + config.h | 3 +- repmgr.c | 561 ++++++++++++++++++++++++++++++++++++++++++++++++++---- repmgr.h | 4 +- 5 files changed, 609 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 11a8e0bc..9651c7cd 100644 --- a/README.md +++ b/README.md @@ -504,6 +504,76 @@ standby's upstream server is the replication cluster master. While of limited use in a simple master/standby replication cluster, this information is required to effectively manage cascading replication (see below). +### Using Barman to clone a standby + +`repmgr standby clone` also supports Barman, the Backup and +Replication manager (http://www.pgbarman.org/), as a provider of both +base backups and WAL files. + +Barman support provides the following advantages: + +- the primary node does not need to perform a new backup every time a + new standby is cloned; +- a standby node can be disconnected for longer periods without losing + the ability to catch up, and without causing accumulation of WAL + files on the primary node; +- therefore, `repmgr` does not need to use replication slots, and the + primary node does not need to set `wal_keep_segments`. + +> *NOTE*: In view of the above, Barman support is incompatible with +> the `use_replication_slots` setting in `repmgr.conf`. + +In order to enable Barman support for `repmgr standby clone`, you must +ensure that: + +- the name of the server configured in Barman is equal to the + `cluster_name` setting in `repmgr.conf`; +- the `barman_server` setting in `repmgr.conf` is set to the SSH + hostname of the Barman server; +- the `pg_restore_command` setting in `repmgr.conf` is configured to + use a copy of the `barman-wal-restore` script shipped with Barman + (see below); +- the Barman catalogue includes at least one valid backup for this + server. + +> *NOTE*: Barman support is automatically enabled if `barman_server` +> is set. Normally this is a good practice; however, the command line +> option `--without-barman` can be used to disable it. + +> *NOTE*: if you have a non-default SSH configuration on the Barman +> server, e.g. using a port other than 22, then you can set those +> parameters in a dedicated Host section in `~/.ssh/config` +> corresponding to the value of `barman_server` in `repmgr.conf`. See +> the "Host" section in `man 5 ssh_config` for more details. + +`barman-wal-restore` is a short shell script provided by the Barman +development team, which must be copied in a location accessible to +`repmgr`, and marked as executable; `pg_restore_command` must then be +set as follows: + +