0

I would like to be able to configure postgres to listen on specific interfaces, rather than '*', but one of them is virtual IP (VIP).

If I configure listen_addresses in postgresql.conf with the IP addresses of the interfaces, it works properly except for the VIP - postgres does not actually listen on the VIP.

However, if I configure listen_addresses to listen on '*', then when the VIP becomes active on the local machine, postgres picks it up and listens on that interface as expected.

Is there some option I am overlooking, maybe?

Thanks!

mwp
  • 8,217
  • 20
  • 26
Jamie
  • 1,888
  • 1
  • 18
  • 21
  • What do you mean exactly by "virtual IP"? If the virtual IP up when the postgresql service is started? – redneb Sep 02 '16 at 17:47
  • 3
    Assuming this is Linux, you may need to set `net.ipv4.ip_nonlocal_bind` so PostgreSQL can bind to the VIP whether or not it's active at startup. – mwp Sep 02 '16 at 17:48
  • @redneb, no, the VIP is not up when postgres is started. We have another process that manages the VIPs, and it only assigns the VIP when postgres is running and active! – Jamie Sep 02 '16 at 18:17
  • @mwp, thanks! That did it for me. Post it as an answer and I will mark it as such. Thanks! – Jamie Sep 02 '16 at 18:21
  • Will do. Happy to help! – mwp Sep 02 '16 at 18:28

1 Answers1

3

Codifying my (apparently helpful) answer from the comments:

Assuming this is Linux, you may need to set net.ipv4.ip_nonlocal_bind so PostgreSQL can bind to the VIP whether or not it's active at startup.

mwp
  • 8,217
  • 20
  • 26
  • For more information, see here: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Load_Balancer_Administration/s1-initial-setup-forwarding-VSA.html – Jamie Sep 01 '17 at 16:07