mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
88 lines
2.5 KiB
Plaintext
88 lines
2.5 KiB
Plaintext
=====================================================
|
|
repmgr: Replication Manager for PostgreSQL's clusters
|
|
=====================================================
|
|
|
|
Introduction
|
|
============
|
|
|
|
PostgreSQL 9.0 allow us to have replicated hot standby servers
|
|
which we can query and/or use for high availability.
|
|
|
|
While the main components of the feature are included with
|
|
PostgreSQL, the user is expected to manage the high availability
|
|
part of it.
|
|
|
|
repmgr allows you to monitor and manage your replicated PostgreSQL
|
|
databases as a single cluster.
|
|
|
|
repmgr works in two components:
|
|
* repmgr: command program that performs tasks and then exits
|
|
* repmgrd: management and monitoring daemon that watches cluster
|
|
|
|
|
|
COMMANDS
|
|
========
|
|
|
|
* standby clone [node to be cloned]
|
|
|
|
Backup via rsync the data directory of the primary. And creates the recovery file
|
|
we need to start a new hot standby server.
|
|
It doesn't need the repmgr.conf so it can be executed anywhere in the new node.
|
|
So, you can step where you want your new data directory and execute:
|
|
|
|
./repmgr standby clone 10.68.1.161
|
|
|
|
That will make a backup of the primary then you only need to execute:
|
|
|
|
pg_ctl -D /your_data_directory_path start
|
|
|
|
|
|
* standby promote
|
|
|
|
Allows manual promotion of a specific standby into a new primary in the event of a failover
|
|
This needs to be executed on the same directory where the repmgr.conf is in the standby.
|
|
Doesn't need any additional arguments:
|
|
|
|
./repmgr standby promote
|
|
|
|
That will restart your standby postgresql service
|
|
|
|
|
|
* standby follow [node to be followed]
|
|
|
|
Allows the standby to re-point itself to a new primary indicated as a parameter.
|
|
This needs to be executed on the same directory where the repmgr.conf is in the standby.
|
|
|
|
./repmgr standby follow 10.68.1.162
|
|
|
|
|
|
PRE-REQUISITES
|
|
==============
|
|
|
|
Primary must be configured with
|
|
|
|
postgresql.conf
|
|
---------------
|
|
listen_addresses='*'
|
|
wal_level = 'hot_standby'
|
|
archive_mode = on
|
|
archive_command = 'cd .'
|
|
max_wal_senders = 10
|
|
wal_keep_segments = 5000 # 80 GB required on pg_xlog
|
|
hot_standby = on
|
|
|
|
Also you need to add the machines that will participate in the cluster in pg_hba.conf.
|
|
ie:
|
|
host all all 10.8.0.0/24 trust
|
|
host replication all 10.8.0.0/24 trust
|
|
|
|
|
|
Configuration file
|
|
==================
|
|
|
|
repmgr.conf: This is looked for in the directory repmgrd or repmgr exists
|
|
The configuration file should have 3 lines:
|
|
cluster : tha name of this cluster
|
|
node : specify the number of this node inside the cluster
|
|
conninfo: specify how we can connect to this node's PostgreSQL service
|