Install PostgreSQL 10 With Repmgr On CentOS 7
Install PostgreSQL 10 With Repmgr On CentOS 7
md
Created 4 years ago • Report abuse
Star
PostgreSQL10-Repmgr-CentOS7.md
Prerequisites
2 CentOS 7 servers (One will act as master and the other one as slave)
postgresql-10,repmgr10
Public key authentication
Installation
listen_addresses = '*'
Set the value to 2 (since we have two servers, one master and one slave).
max_wal_senders = 2
wal_level determines how much information is written to the WAL. The default value
is minimal, which writes only the information needed to recover from a crash or
immediate shutdown. archive adds logging required for WAL archiving, and
hot_standby further adds information required to run read-only queries on a standby
server. This parameter can only be set at server start.
wal_level = hot_standby
hot_standby = on
Archive settings
archive_mode = on
archive_command = 'cp %p /var/lib/pgsql/10/archive/%f'
Specifies the minimum number of past log file segments kept in the pg_xlog
directory, in case a standby server needs to fetch them for streaming replication.
wal_keep_segments = 10
/var/lib/pgsql/10/data/pg_hba.conf
pg_hba.conf is client authentication is controlled by a configuration file.
Start PostgreSQL
Create the required users for replication and repmgr and the repmgr DB.
passwd postgres
sudo su - postgres
psql
CREATE USER repmgr SUPERUSER LOGIN ENCRYPTED PASSWORD 'secret';
CREATE DATABASE repmgr OWNER repmgr;
\q
exit
sudo su - postgres
/usr/pgsql-10/bin/repmgr -f /etc/repmgr/10/repmgr.conf master register
exit
Installation
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-
7-x86_64/pgdg-centos10-10-2.noarch.rpm
yum install postgresql10-server postgresql10-contrib repmgr10
Sync the configuration and contents of the master with the slave.
sudo su - postgres
/usr/pgsql-10/bin/repmgr -D /var/lib/pgsql/10/data -d repmgr -p 5432 -U
repmgr -R postgres standby clone <master server ip>
exit
node_id=2
node_name=node2
conninfo='host=<slave server ip> user=repmgr dbname=repmgr'
data_directory=/var/lib/pgsql/10/data
passwd postgres
sudo su - postgres
/usr/pgsql-10/bin/repmgr -f /etc/repmgr/10/repmgr.conf standby register
--force
exit
Master Server
Nodes can connect to each other over SSH without a password prompt with users
root and postgres.
Let's create a key pair.Press Enter to all sections.
ssh-keygen
ssh-copy-id postgres@master_server_ip
Slave Server
Nodes can connect to each other over SSH without a password prompt with users
root and postgres.
ssh-keygen
ssh-copy-id root@slave_server_ip
TEST