9.3.2

Table Of Contents
Promote a Replica Database to Primary Database
You can promote a replica (or slave) server to a primary (or master) server.
If a primary database fails, you can manually promote one of the replica database instances to take the place
of the primary database.
Prerequisites
Create a replication user account with which to create and promote replica server nodes. See “Create a
Replication User Account,” on page 32.
Procedure
1 Log in as the replication user.
2 To create a replica server, run the
script /opt/vmware/vpostgres/current/scripts/promote_replica_to_primary.
/opt/vmware/vpostgres/current/scripts/promote_replica_to_primary
server promoting
What to do next
When you promote a replica database to take over from its primary database, you must redirect other
replica nodes to use the newly created primary instance. You can connect other replica nodes to a new
master by running the /opt/vmware/vpostgres/current/scripts/run_as_replica script. See “Create a
Replica Server,” on page 33.
Monitoring Replication Status
You can monitor the Write-Ahead Logging (WAL) replay activity of slave nodes connected to the master
node.
WAL is a standard approach to transaction logging in which changes to data files are written to only after
those changes have been logged. WAL allows for a significant reduction in the number of disk writes
because only the log file needs to be flushed to disk at the time of transaction committal, rather than every
data file changed by the transaction. Using WAL to replicate data is the fastest type of replication available,
allowing you to quickly create slave instances of vFabric Postgres databases.
Procedure
1 Log in as the postgres operating system user.
2 Run the script /opt/vmware/vpostgres/current/scripts/show_replication_status.
The script monitors the WAL replay activity of slave nodes connected to the node where the script is
launched.
The replay_delta column monitors how a given slave is late compared to a master node when replaying
WAL. The lower the values of receive_delta and replay_delta , the nearer the slave node is to getting to
the master in terms of WAL replay (replication state).
postgres@localhost:~> /opt/vmware/vpostgres/current/scripts/show_replication_status
sync_priority | slave | sync_state | log_receive_position | log_replay_position |
receive_delta | replay_delta
---------------+--------------------+------------+----------------------
+---------------------+---------------+--------------
0 | localhost.localdom | async | 0/8000000 | 0/8000000 | 0 | 0
(1 row)
Using VMware vFabric Postgres
34 VMware, Inc.