Search code examples
postgresqlubuntunetwork-programmingsshrepmgr

repmgr Error: A master must be defined before configuring a slave


I am using the repmgr for replication. I had registered the Master node to repmgr successfully. I had successfully cloned the Master node & Started the Standby server. But the Problem is I cannot register the Standby node in repmgr.

I am using the version repmgr 2.0beta1 (PostgreSQL 9.3.2). Os: Ubuntu 14.04 LTS

While registering the Standby node.

$ repmgr -f /etc/repmgr/repmgr.conf --verbose standby register
Opening configuration file: /etc/repmgr/repmgr.conf
[2015-03-31 11:43:19] [WARNING] pg_bindir//usr/lib/postgresql/9.3/bin: Unknown name/value pair!
[2015-03-31 11:43:19] [INFO] repmgr connecting to standby database
[2015-03-31 11:43:19] [INFO] repmgr connected to standby, checking its state
[2015-03-31 11:43:19] [INFO] repmgr connecting to master database
[2015-03-31 11:43:19] [INFO] finding node list for cluster 'test'
[2015-03-31 11:43:19] [INFO] checking role of cluster node 'host=127.0.0.1 user=repmgr_usr dbname=repmgr_db'
[2015-03-31 11:43:19] [ERROR] A master must be defined before configuring a slave

Got this error.

On Standby Postgres LOG: (With log_connections=on, log_disconnections=on)

$ tail -f /var/log/postgresql/postgresql-9.3-main.log
2015-03-31 11:38:51 IST LOG:  disconnection: session time: 0:00:00.011 user=repmgr_usr database=repmgr_db host=127.0.0.1 port=53055
2015-03-31 11:38:51 IST LOG:  could not receive data from client: Connection reset by peer
2015-03-31 11:38:51 IST LOG:  disconnection: session time: 0:00:00.029 user=repmgr_usr database=repmgr_db host=127.0.0.1 port=53054
2015-03-31 11:43:19 IST LOG:  connection received: host=127.0.0.1 port=53061
2015-03-31 11:43:19 IST LOG:  connection authorized: user=repmgr_usr database=repmgr_db
2015-03-31 11:43:19 IST LOG:  connection received: host=127.0.0.1 port=53062
2015-03-31 11:43:19 IST LOG:  connection authorized: user=repmgr_usr database=repmgr_db
2015-03-31 11:43:19 IST LOG:  disconnection: session time: 0:00:00.008 user=repmgr_usr database=repmgr_db host=127.0.0.1 port=53062
2015-03-31 11:43:19 IST LOG:  could not receive data from client: Connection reset by peer
2015-03-31 11:43:19 IST LOG:  disconnection: session time: 0:00:00.025 user=repmgr_usr database=repmgr_db host=127.0.0.1 port=53061

I got the error in LOG "could not receive data from client: Connection reset by peer"

On Master Postgres LOG:(With log_connections=on, log_disconnections=on)

$tail -f /var/log/postgresql/postgresql-9.3-main.log
2015-03-31 11:25:18 IST LOG:  connection authorized: user=postgres database=postgres
2015-03-31 11:25:18 IST LOG:  disconnection: session time: 0:00:00.010 user=postgres database=postgres host=[local]
2015-03-31 11:25:19 IST LOG:  connection received: host=[local]
2015-03-31 11:25:19 IST LOG:  connection authorized: user=postgres database=postgres
2015-03-31 11:25:19 IST LOG:  disconnection: session time: 0:00:00.002 user=postgres database=postgres host=[local]
2015-03-31 11:25:19 IST LOG:  connection received: host=[local]
2015-03-31 11:25:19 IST LOG:  connection authorized: user=postgres database=postgres
2015-03-31 11:25:19 IST LOG:  disconnection: session time: 0:00:00.002 user=postgres database=postgres host=[local]
2015-03-31 11:26:14 IST LOG:  connection received: host=192.168.1.218 port=40381
2015-03-31 11:26:14 IST LOG:  replication connection authorized: user=repmgr_usr

I think no details about the standby connection in this log. (I am not sure bcoz I dont know)

Master repmgr.conf:

cluster=test
node=1
node_name=node1
conninfo='host=127.0.0.1 user=repmgr_usr dbname=repmgr_db'
pg_bindir=/usr/lib/postgresql/9.3/bin

Standby repmgr.conf

cluster=test
node=2
node_name=node2
conninfo='host=localhost user=repmgr_usr dbname=repmgr_db'
pg_bindir='/usr/lib/postgresql/9.3/bin'

master & Standby postgres.conf

listen_addresses='*'
wal_level = 'hot_standby'
archive_mode = on
archive_command = 'cd .'       
max_wal_senders = 10
wal_keep_segments = 5000    
hot_standby = on
log_connections = on
log_disconnections = on

master & stanby pg_hba.conf

host    repmgr_db       repmgr_usr  192.168.1.0/24         trust
host    replication     repmgr_usr  192.168.1.0/24         trust
host    repmgr_db       repmgr_usr  127.0.0.1/24         trust
host    replication     repmgr_usr  127.0.0.1/24         trust

Cluster Details in Standby node:

$ repmgr -f /etc/repmgr/repmgr.conf cluster show
[2015-03-31 12:06:17] [WARNING] pg_bindir//usr/lib/postgresql/9.3/bin: Unknown name/value pair!
Role      | Connection String 
  standby | host=127.0.0.1 user=repmgr_usr dbname=repmgr_db

Cluster Details in Master node:

$ repmgr -f /etc/repmgr/repmgr.conf cluster show
[2015-03-31 12:07:46] [WARNING] pg_bindir//usr/lib/postgresql/9.3/bin: Unknown name/value pair!
Role      | Connection String 
* master  | host=127.0.0.1 user=repmgr_usr dbname=repmgr_db

Please help me in this issue.


Solution

  • Finally I solved that by changing the repmgr.conf file. I have changed the

    conninfo='host=localhost user=repmgr_usr dbname=repmgr_db'
    

    with

    conninfo='host=192.168.1.205 user=repmgr_usr dbname=repmgr_db'
    

    i.e.. In Config file we have to give the IP address or Name resolved by the cluster.