Postgres Primary and Standby switching
The Master is looking for
Method
Ps-ef | grep wal (Main library sender)
Postgres 27873 27864 0 May 06? 00:00:10 Postgres:wal Sender Process Postgres 10.2.0.13 (47582) streaming 0/906ff78
Postgres 27874 27864 0 May 06? 00:00:11 Postgres:wal Sender Process Postgres 10.2.0.15 (51872) streaming 0/906ff78
Ps-ef | grep wal (Standby receiver)
Postgres 25875 25828 0 May 06? 00:05:28 Postgres:wal receiver Process streaming 0/906ff78
Standby library switch to master Library
1 switch off the main library
Pg_ctl stop
Waiting for server to shut down ... done
Server stopped
View the Repository Log
Tail-f/var/lib/pgsql/9.5/data/pg_log/postgresql-fri.log
TCP/IP connections on port 5432?
< 2016-05-13 17:24:09.493 CST >fatal:could not connect to the primary server:could does connect to Server:connecti On refused
is the server running on host "10.2.0.14" and accepting
TCP/IP connections on port 5432?
< 2016-05-13 17:24:14.500 CST >fatal:could not connect to the primary server:could does connect to Server:connecti On refused
is the server running on host "10.2.0.14" and accepting
TCP/IP connections on port 5432?
< 2016-05-13 17:24:19.508 CST >fatal:could not connect to the primary server:could does connect to Server:connecti On refused
is the server running on host "10.2.0.14" and accepting
TCP/IP connections on port 5432?
Generate the file specified in the recovery.conf file in the corresponding directory of the standby pgdata trigger_file = '/home/postgres.trigger ' (the standby is now in a normal state)
Touch/home/postgres.trigger
You will see the recovery.conf file become Recovery.done
Tail-f/var/lib/pgsql/9.5/data/pg_log/postgresql-fri.log
TCP/IP connections on port 5432?
< 2016-05-13 17:27:21.714 CST >fatal:could not connect to the primary server:could does connect to Server:connecti On refused
is the server running on host "10.2.0.14" and accepting
TCP/IP connections on port 5432?
< 2016-05-13 17:27:26.719 CST >fatal:could not connect to the primary server:could does connect to Server:connecti On refused
is the server running on host "10.2.0.14" and accepting
TCP/IP connections on port 5432?
< 2016-05-13 17:27:31.719 CST >log:trigger file found:/home/postgres.trigger
< 2016-05-13 17:27:31.719 CST >log:redo is not required
< 2016-05-13 17:27:31.735 CST >log:selected new Timeline Id:2
< 2016-05-13 17:27:32.282 CST >log:archive Recovery complete
< 2016-05-13 17:27:32.331 CST >log:multixact member wraparound protections is now enabled
< 2016-05-13 17:27:32.345 CST >log:autovacuum launcher started
< 2016-05-13 17:27:32.347 CST >log:database system is ready to accept connections
CentOS7 PostgreSQL Master-slave configuration (iii)