Skip site navigation (1) Skip section navigation (2)

postgres 9 bind address for replication

From: Adam Crews <adam(dot)crews(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: postgres 9 bind address for replication
Date: 2012-07-23 18:23:32
Message-ID: CAK=eFMy6Q76v+Kvjz=UE_whxDir6_uCp-Z3pc1TuGKTkEY9uqg@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-cluster-hackerspgsql-generalpgsql-hackers
On Mon, Jul 23, 2012 at 8:34 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Sat, Jul 21, 2012 at 1:24 AM, Adam Crews <adam(dot)crews(at)gmail(dot)com> wrote:
>> Hello,
>>
>> I'm sorry for cross-posting, however I originally posted this to
>> pgsql-general list, but didnt get any replies.

Then I posted to pgsql-cluster-hackers..., and now here.

>>
>>
>> I’m using pg 9.1.3 on CentOS 5 and have a few slave databases setup
>> using the built in streaming replication.
>>
>> On the slaves I set the “listen_addresses” config option to an ip
>> address for a virtual alias on my network interfaces.  The host has an
>> address of 10.1.1.10, and there is a virtual alias of 10.1.1.40 that
>> the slave postmaster binds to.
>>
>> When the slave makes it connection to the master to start replication
>> the source address for the connection is the host address, not the
>> virtual alias address.  Connections appear to come from 10.1.1.10,
>> instead of the slave postmaster address of 10.1.1.40.
>>
>> This seems like a bug to me.  I could understand that if the
>> postmaster is listening on all interfaces, then it should use whatever
>> the IP is for the for the host, but in an instance where the
>> postmaster has been configured to listen to a specific address it
>> seems like the call to start the replication should be passed that
>> address so connections come from the slave postmaster’s IP, instead of
>> the host.
>>
>> Is there a config option that can be used to adjust this?  I've looked
>> in the docs, but haven't found one yet.
>>
>> Is this perhaps a bug, or lack of feature?
>
> I don't think it's a bug, because the behavior you're hoping for might
> not be what everyone would want in a similar situation.  It might
> qualify as an unimplemented feature.
>
> This mailing list isn't heavily used and this seems a bit off-topic
> for it anyway; you might want to try a different one for further
> discussion of this issue.
>

So, I think this, as Robert states, an unimplemented feature.

For my situation it would be very useful to have an option to be able
to specify the source address for replication.

I discovered this because I bind the listen address for postgres to a
single address even though the host system may have multiple
addresses.  I then use that single address in iptables rules on other
systems.  Since I expect the slave to be at a .40 address, but the
replication comes from the primary address of the interface (in this
case .10), my iptables rules were missing the access for the slave to
connect to the master.

This site http://linux-ip.net/html/routing-saddr-selection.html
describes the behavior I'm seeing.

How do I go about requesting a config option that would allow me to
specify the source address for the replication connections?

Thanks
-Adam

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2012-07-23 18:43:34
Subject: Re: BUG #6748: sequence value may be conflict in some cases
Previous:From: Manoj GovindassamyDate: 2012-07-23 17:54:36
Subject: Re: Pg_ctl promote -- wait for slave to be promoted fully ?

pgsql-cluster-hackers by date

Next:From: Andrew DunstanDate: 2012-07-23 18:45:22
Subject: Re: postgres 9 bind address for replication
Previous:From: Robert HaasDate: 2012-07-23 15:34:26
Subject: Re: postgres 9 bind address for replication

pgsql-general by date

Next:From: Andrew DunstanDate: 2012-07-23 18:45:22
Subject: Re: postgres 9 bind address for replication
Previous:From: Manoj GovindassamyDate: 2012-07-23 17:54:36
Subject: Re: Pg_ctl promote -- wait for slave to be promoted fully ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group