">

REPMGR INSTALLATION AND CONFIGURATION FOR POSTGRESQL

REPMGR INSTALLATION AND CONFIGURATION FOR POSTGRESQL

Hi,

Machine IP ROLE
pg 10.0.0.4 Primary
pgrep 10.0.0.5 Replication
Pgrep2 10.0.0.6 Replication2

Pre Request:

  • Primary database must be install postgresql database.
  • Standby databases must be install postgresql database and configure replication.

Installation:

We are installing repmgr12 in all postgresql database machine.

  • sudo yum install repmgr12

We are executing below command in Primary Node.

-bash-4.2$ psql

psql (12.2)

Type "help" for help.

postgres=# createuser --superuser repmgr

-bash-4.2$ createdb --owner=repmgr repmgr

-bash-4.2$ psql -c "ALTER USER repmgr SET search_path TO repmgr, public;"

ALTER ROLE

We are changing below parameter in postgresql.conf file.

shared_preload_libraries = 'repmgr'

We are changing below parameters in /etc/repmgr/12/repmgr.conf file in primary server.

For Primary:

node_id=1

node_name='PG-Node1'

conninfo='host=10.0.0.4 user=repmgr dbname=repmgr connect_timeout=2'

data_directory='/var/lib/pgsql/12/data'

We are changing below parameters in /etc/repmgr/12/repmgr.conf file in standby server.

For Replication:

node_id=2

node_name='PG-Node2'

conninfo='host=10.0.0.5 user=repmgr dbname=repmgr

connect_timeout=2'

data_directory='/var/lib/pgsql/12/data'

We are changing below parameters in /etc/repmgr/12/repmgr.conf file in standby2 server.

For Replication2:

              node_id=3

node_name='PG-Node3'

conninfo='host=10.0.0.6 user=repmgr dbname=repmgr

connect_timeout=2'

data_directory='/var/lib/pgsql/12/data'

We are adding below all line in pg_hba.conf file in all postgresql database machine. And alse restart all database service. (if you must change 10.0.0.0 ip addreses because your machines ip can be different.)

local   replication     repmgr                              trust

host    replication     repmgr      127.0.0.1/32            md5

host    replication     repmgr      10.0.0.0/16             md5

local   repmgr          repmgr                              trust

host    repmgr          repmgr      127.0.0.1/32            md5

host    repmgr          repmgr      10.0.0.0/16             md5

We are testing below commands in standby and standby2 machine. 

-bash-4.2$ psql 'host=10.0.0.4 user=repmgr dbname=repmgr connect_timeout=2'

psql (12.2)

Type "help" for help.

repmgr=#

We are registering below commands in  primary node.

-bash-4.2$ /usr/pgsql-12/bin/repmgr -f /etc/repmgr/12/repmgr.conf primary register

INFO: connecting to primary database...

NOTICE: attempting to install extension "repmgr"

NOTICE: "repmgr" extension successfully installed

NOTICE: primary node record (ID: 1) registered

We are registering below command in standby server.

-bash-4.2$ /usr/pgsql-12/bin/repmgr standby register -F

INFO: connecting to local node "PG-Node2" (ID: 2)

INFO: connecting to primary database

WARNING: --upstream-node-id not supplied, assuming upstream node is primary (node ID 1)

WARNING: local node not attached to primary node 1

NOTICE: -F/--force supplied, continuing anyway

INFO: standby registration complete

NOTICE: standby node "PG-Node2" (ID: 2) successfully registered

We are checking registration status below command in primary machine.

-bash-4.2$ /usr/pgsql-12/bin/repmgr -f /etc/repmgr/12/repmgr.conf cluster show

If you want you will look replication information in primary machine. 

select * from pg_stat_replication;

Best Regards

Engin YILMAZ.

 

Yorumlar

Henüz yorum yapılmadı.

Yorum Yapın