Promoting a Standby to the Main server

Replication is a feature of postgres and is automatically set up for cloud venues. Self service venues may set this up if they wish - the support team is unable to help you.
Except for an absolute calamity, there is no reason to promote the hot standby to be the main server. If you need to, the general recovery steps are outlined below. There is only ONE command to do at the backup server to make it the primary server (see bottom half of page).

  1. Shut down, turn off, unplug and/or remove the main server from the network so that it is no longer active
  2. On the backup server, create the failover trigger file using the primary failover methodology (described in detail below):
    sudo touch /tmp/pg_failover_trigger
  3. The hot standby is now your main server.
  4. You may need to change the pg_hba.conf file as required to allow workstations to access the database.

    It is probably okay because it was originally copied from the main server at time of making the standby. You will only need to change the pg_hba.conf file if you added more sub-nets to the main server.

  5. Do all the work necessary to get Theatre Manager clients to point to a new database server by doing one of:
    • Use Theatre Manager to change the IP address of the database you log into -or-
    • Change the IP address of the hot standby to be the same as the Master main server -or-
    • Change the DNS to point to the new IP address, if that's what you use to connect to the server
  6. Log all clients, second generation and classic listeners into the new server IP address
    • Log into the database using Theatre Manager.
    • Quit and restart the Theatre Manager Server
    • Quit and restart any web listeners
  7. Fix the reason that the main server died and plan to set up a new hot backup server

 

Primary Method to promoting the Backup Server to Main Server

If your recovery.conf file in the Postgres data directory was set up according to these instructions, it should have a trigger_file parameter and look like the except below.

# specify the name of a file whose presence should cause streaming replication to
# end (i.e. failover). If you create this file, then Postgres will rename 'recovery.conf'
# to 'recovery.done' and promote the hot standby to a primary server without a restart.
trigger_file = '/tmp/pg_failover_trigger'
Assuming that the path name of the trigger file is /tmp/pg_failover_trigger, then, in Terminal as an admin user, type
sudo touch /tmp/pg_failover_trigger
This will cause Postgres to:
  • Notice the file
  • Finish off the slave process and recover any log files transferred from the main server that still needs recovery
  • Rename the 'recovery.conf' file to 'recovery.done'
  • when that happens, it is now the primary server

Alternate Method using pg_ctl

use pg_ctl to promote the server

su - postgres
enter the postgres password
pg_ctl promote

For more information refer to the postgres fail-over documentation