REPMGR

Da wiki.gienne.cloud.
Versione del 2 set 2017 alle 15:49 di Admin (Discussione | contributi)

(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)

Da installazione del DB base.

Documentazione base: https://www.2ndquadrant.com/en/resources/repmgr/installation-instructions/

Installazione base:

yum install repmgr96 -y 

Configurazione con Macchina Principale e Standby

Aggiungere sotto /var/lib/pgsql/9.6/data nel file postgresql.conf

max_wal_senders = 10
wal_level = 'hot_standby'
hot_standby = on
archive_mode = on
archive_command = '/bin/true'

Attenzione modificare il punto di listener:

listen_addresses = '*'          # what IP address(es) to listen on;

Creazione dell'utente di repmgr (utente manager della replica):

createuser -s repmgr 

Creazione db dell'utente di replica:

createdb repmgr -O repmgr


Aggiunta nel file pg_hba.conf

local   replication   repmgr                              trust
host    replication   repmgr      127.0.0.1/32            trust 
host    replication   repmgr       10.245.71.0/24            trust
host    replication   repmgr       10.245.72.0/24            trust
local   repmgr        repmgr                              trust
host    repmgr        repmgr      127.0.0.1/32            trust
host    repmgr   repmgr       10.245.71.0/24            trust
host    repmgr   repmgr       10.245.72.0/24            trust

Nel file: repmgr.conf

cluster=cluster01
node=1
node_name=node1
conninfo='host=node1.gienne.cloud user=repmgr dbname=repmgr'


Nel file: repmgr.conf

cluster=cluster01
node=2
node_name=node2
conninfo='host=node2.gienne.cloud user=repmgr dbname=repmgr'


Launch register: repmgr -f repmgr.conf master register

Example output:

NOTICE: master node correctly registered for cluster 'cluster01' with id 1 (conninfo: host=node1.gienne.cloud user=repmgr dbname=repmgr)

Test:

psql repmgr
SELECT * FROM repmgr_<nome-cluster>.repl_nodes;
es.: SELECT * FROM repmgr_cluster01.repl_nodes;
 id   |  type     | upstream_node_id |  cluster     | name   |                     conninfo                                                            | slot_name  | priority | active
----+--------+------------------+-----------+-------+---------------------------------------------------------+-----------+----------+--------
  1    | master  |                               | cluster01   | node1  | host=node1.gienne.cloud user=repmgr dbname=repmgr |                    |      100 | t


repmgr -h node1.gienne.cloud -U repmgr -d repmgr -D /var/lib/pgsql/data/ -f /var/lib/pgsql/repmgr.conf standby clone