-
Notifications
You must be signed in to change notification settings - Fork 10
PostgreSQL Testing Replication
You can easily check the replication status by running this command:
psql -U postgres -h 192.168.1.1 -p 5432 -x -c "select * from pg_stat_replication"
As usual, replace the IP for your Master server's IP (and port, if not default). The -x option simply makes psql's output more readable for this particular command. -c tells psql to run a single query and exit.
You should have one Slave in sync_state = sync and all others in sync_state = potential. This means that the Master server only confirms a write query to the client after replicating the change to the sync Slave, to make sure the database always has a backup ready. All other slaves are in asynchronous mode, they'll also get all the changes but the client doesn't have to wait for them.
You can also run psql -U postgres -h 192.168.1.1 -p 5432 -x -c "show transaction_read_only" for each machine. All the slaves should return on, the master returns off, since it can also execute write queries.
You can also try whatever SQL queries you like to make sure the data is indeed being replicated to all machines.
- Home
- Overview
- Requirements
- Setup
- Summary and Quick Start
- Database (PostgreSQL) 1. PostgreSQL Installation 2. Configuring the Master 3. Configuring the Slaves 4. Testing Replication 5. Manual Failover
- Load Balancing (PgPool II) 1. PgPool II Installation 2. Configuration 3. Managing and Testing
- Automatic Failover 1. Setting it up 2. Testing
- Troubleshooting
- References
