3

I'm trying to create Postgresql 9.1 hot-standby using following steps:

  1. Configured 2 virtual linux machines. Master's ip: 10.10.10.1, Standby's ip: 10.10.10.2. Ping test passed.
  2. Restored the same db backup on both.
  3. Edited pg_hba on master. Added line:

    host   replication   postgres   10.10.10.2/32   md5
    
  4. Edited Master's postgresql.conf:

    listen_address = '*'
    wal_level = hot_standby
    max_wal_senders = 3
    
  5. Created recovery.conf on Standby:

    standby_mode = 'on'
    primary_conninfo = 'host=10.10.10.1'
    

After adding recovery.conf I fail to start Standby server. In startup log I get an error:

> could not create IPv6 socket

Did I missed something?

krissi
  • 3,317
  • 1
  • 18
  • 22
Alex
  • 131
  • 1
  • 3

2 Answers2

2

This happens when IPv6 is not enabled in the kernel but IPv6 addresses are advertised somewhere.

Sometimes localhost in /etc/hosts designates both 127.0.0.1 (IPv4) and ::1 (IPv6). In which case you may remove the IPv6 alias to avoid that kind of error.

The stats collector (a separate process launched by PostgreSQL) uses the hard-coded name localhost, so this problem would make it fail to start with the mentioned error message. However, this shouldn't prevent PostgreSQL itself to start.

If * happens to include problematic IPv6 addresses, you may solve the problem by being selective in listen_addresses (which is good practice anyway):

listen_addresses=127.0.0.1,10.10.10.1 # add other interfaces if needed

Daniel Vérité
  • 2,740
  • 14
  • 19
  • Thanks for your answer, Daniel. My system has no IPv6 enabled anywhere, nor are there ipv6 addresses in the hosts file or elsewhere, yet I still see this. I don't want to set `listen_addresses` for a variety of reasons. Any ideas where the IPv6 is getting picked up? – Otheus Jul 19 '15 at 20:09
1

To disable the IPv6 error, you have to do following steps.

  1. paste the following code in this file (/etc/sysctl.conf)

    net.ipv6.conf.all.disable_ipv6 = 1

  2. In postgresql.conf file change the listen address to 0.0.0.0

    listen_address ='0.0.0.0'

That's it and restart the postgreSQL service.