Check the multiplexed database status by executing the mc_ctl command in status mode.
Additionally, errors can be detected by monitoring the Mirroring Controller messages. If the status or messages are monitored periodically, you can react quickly following an automatic switch failure.
When the mc_ctl command is executed, the details of the multiplexing configuration, information about whether switch is possible following the error, and location and details of the error that caused the switch or disconnection are displayed.
After starting database multiplexing mode, execute the mc_ctl command in status mode to check the multiplexing status.
An example of the status displayed when the mc_ctl command is executed is shown below.
Example)
$ mc_ctl status -M /mcdir/inst1 mirroring status ---------------- switchable server_id host_role host host_status db_proc_status disk_status -------------------------------------------------------------------------------------------------------- nd1 primary 192.0.2.100 normal normal normal nd2 standby 192.0.2.110 normal normal normal
Additionally, by referencing the pg_stat_replication statistics view on the primary server, the data synchronization status can be confirmed. However, when creating the monitoring program, note that the content of pg_stat_replication may be changed in the future.
The following example shows that the locations of the transaction log after it is sent and received (sent_location, replay_location) match, and that they are fully synchronized.
Example)
postgres=# select * from pg_stat_replication; -[ RECORD 1 ]----+------------------------------ pid | 16706 usesysid | 10 usename | symfo application_name | standby1 client_addr | 192.0.2.210 client_hostname | client_port | 26500 backend_start | 2014-04-25 14:21:30.097644+09 state | streaming sent_location | 0/3003C30 write_location | 0/3003C30 flush_location | 0/3003C30 replay_location | 0/3003C30 sync_priority | 1 sync_state | sync
See
Refer to "mc_ctl" in Reference for information on the command.
Refer to "Notes on Application Compatibility" in the Application Development Guide for information on retaining application compatibility.
Refer to "The Statistics Collector" in "Server Administration" in the PostgreSQL Documentation for details on pg_stat_replication.