Bjørn T Johansen schrieb am 26.10.2016 um 13:17:
> I have a database that I would like to replicate in case of hardware failure on this server. So I gather I just need
astreaming replication (warm
> standby?) and I found a howto describing how to set it up, that looks like this:
>
> 1. Edit postgresql.conf on the master to turn on streaming replication. Change these settings:
> listen_addresses = '*'
> wal_level = hot_standby
> max_wal_senders = 3
> 2. Edit pg_hba.conf on the master in order to let the standby connect.
> host replication all 192.168.0.2/32 trust
> 3. Edit postgresql.conf on the standby to set up hot standby. Change this line:
> hot_standby = on
> 4. Create or edit recovery.conf on the standby to set up replication and standby mode. Save a file in the standby's
datadirectory, called recovery.conf, with the following lines:
> standby_mode = 'on'
> primary_conninfo = 'host=192.168.0.1'
> 5. Shut down both the master and standby, and copy the files. You want to copy most but not all files between the two
servers,excluding the configuration files and the pg_xlog directory. An example rsync script would be:
> rsync -av --exclude pg_xlog --exclude postgresql.conf data/* 192.168.0.2:/var/lib/postgresql/data/
> 6. Start the standby first, so that they can't get out of sync. (Messages will be logged about not being able to
connectto the primary server, that's OK.)
> 7. Start the master.
>
> Is this all that is needed to get a working master - slave replication? (It just looks too easy... :) )
Yes, that's all.
In fact 5. could be done withoug shutting down the master using pg_basebackup
> Do I need to enable archive mode for this to work or?
No.
"wal_level = hot_standby" includes that.