Re: FQDN for replication connection in pg_hba.conf

From: Shreeyansh Dba <shreeyansh2014(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: rammohan ganapavarapu <rammohanganap(at)gmail(dot)com>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: FQDN for replication connection in pg_hba.conf
Date: 2017-11-13 10:58:24
Message-ID: CAGDYbUNUHbLc8sP28YFgG6nExtZKz+HKPcixNZXCEV3s6WbUhg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Wed, Oct 11, 2017 at 3:48 AM, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> On Tue, Oct 10, 2017 at 3:08 PM, rammohan ganapavarapu <
> rammohanganap(at)gmail(dot)com> wrote:
>
>> Can we use fqdn in pg_hba.conf for replication connections?
>>
>>
>> # TYPE DATABASE USER ADDRESS METHOD
>>
>> # "local" is for Unix domain socket connections only
>> local all all trust
>> # IPv4 local connections:
>> host all all 0.0.0.0/0 md5
>> host replication postgres *slave.example.com
>> <http://slave.example.com> * trust
>>
>>
>> I am getting below error in slave
>>
>> 2017-10-10 21:34:52 UTC [313]: [1-1] user= db= host= FATAL: could not
>> connect to the primary server: FATAL: no pg_hba.conf entry for replication
>> connection from host "10.10.10.10", user "postgres", SSL off where
>> "10.10.10.10" is my slave (*slave.example.com
>> <http://slave.example.com>) * ip.
>>
>>
> ​The comments and note under "address" at the following link suggest that
> what you are trying is possible. Hopefully they can shed some light as to
> what to check in order to find out why it is not working in your case.​ In
> particular, are both DNS entries configured?
>
> https://www.postgresql.org/docs/10/static/auth-pg-hba-conf.html
>
> ​Ensure you reload the configuration after making changes.
> ​
> ​I don't recall whether having a all/all/any entry above your replication
> entry is going to be problematic - but that wouldn't explain a "no
> pg_hba.conf entry" error.
>
> David J.
>
>
>
We can use fqdn in pg_hba.conf for replication connections
The only thing you need to do is mention the hostname both in pg_hba.conf
of postgresql and under /etc/hosts, that too both in master and slave

i) /etc/hosts (Entry required for both master & slave)
master IP address <name of the FQDN> <master hostname>
slave IP Address <name of the FQDN> <salve hostname>

ii) pg_hba.conf
# "local" is for Unix domain socket connections only
host all all <name of the FQDN of master>
trust
host all all <name of the FQDN of slave> trust

# Allow replication connections from localhost, by a user with the
# replication privilege.
host replication postgres <name of the FQDN of master>
trust
host replication postgres <name of the FQDN of slave> trust

Note :- firewall must be disable on (master side)

--

[image: http://www.shreeyansh.com] <http://www.shreeyansh.com>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Shreeyansh Dba 2017-11-13 12:59:23 Re: High replication lag - Stream Replication
Previous Message Christoph Berg 2017-11-11 19:54:05 Re: Postgres 10 installation failing on Ubuntu 14