Navigation:  Installation Instructions >

Server Mirroring

Previous pageReturn to chapter overviewNext page

Summary

 

For Departments or organizations that require active or "hot" backup systems, FP2 offers the option of building a mirrored server.

 

This feature allows users to set up a duplicate server which has all changes made to the main server written to it automatically.

 

The installation instructions here assume that the servers are on the same LAN, although it is also possible to set up mirroring using an intermediary file.

 

Definitions

 

Master:  The primary FP2 PostgreSQL server.  Generally this is set as the default connection for all client applications.

 

Slave:  The secondary server to which all changes are mirrored.

 

Instructions

 

These instructions assume that both PostgreSQL servers have been set up and correctly configured.  See PostgreSQL Server Installation for more information.

 

1. Stop the Master's Postgres service in the Administrative Tools-->Services section of the O/S.

 

2. Create a backup of the Master.

 

       pg_basebackup -D c:\destination\folder -F p -x postgres

 

3.  Stop the slave's Postgres service.  Delete the contents of the slave's data folder (this will probaly require a restart to unlock the files/directories so they can be deleted).

 

4. Copy the contents of the destination folder (from step 2) into the slave's data folder.  Do not restart the slave's service.

       

5. Alter the master's postgresql.conf file:

 

       listen_address = '*'

       wal_level = hot_standby

       max_wal_senders = 3

       wal_keep_segments = 10

 

6. Alter the master's pg_hba.conf file (change 192.168.0.2 to your slave's IP):

 

       host        replication        all        192.68.0.2/32                trust

 

7. Alter the slave's postgresql.conf:

 

       hot_standby = on

 

8. Alter the slave's postgresql.conf:

 

       hot_standby = on

       

9. Create or Alter the slave's recovery.conf file (replace 192.168.0.1 with your master's IP):

 

       standby_mode = 'on'

       primary_conninfo = 'host=192.168.0.1'

 

10.  Start the Slave's service.

 

11. Start the master's service.

 

To Test, make a change on the master, and look for the change to appear automatically on the slave.

 

12. A copy of the configuration files in the master's data folder should be stored in a safe location.  They will be required in the event that the master must be restored from the slave.

 

Postgres Restoration

 

1. Stop the master's Postgres service.

 

2.  Stop the slave's Postgres service.

 

3.  Create a backup of the slave.

 

       pg_basebackup -D c:\destination\folder -F p -x postgres

 

4.  Copy the contents of the destination folder (from step 3) to the master's data folder.

 

5.  Copy the configuration files for the master (see Postgres Replication step 12) into the master's data folder.

 

6. Start the slave's Postgres service.

 

7. Start the master's Postgres service.