标签:
postgres 主备切换
主备查看
方法
ps -ef | grep wal (主库 sender)
postgres 27873 27864 0 5月06 ? 00:00:10 postgres: wal sender process postgres 10.2.0.13(47582) streaming 0/906FF78
postgres 27874 27864 0 5月06 ? 00:00:11 postgres: wal sender process postgres 10.2.0.15(51872) streaming 0/906FF78
ps -ef | grep wal (备库 receiver)
postgres 25875 25828 0 5月06 ? 00:05:28 postgres: wal receiver process streaming 0/906FF78
备库切换为主库
1 关掉主库
pg_ctl stop
waiting for server to shut down.... done
server stopped
查看备库日志
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 not connect to server: Connection 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 not connect to server: Connection 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 not connect to server: Connection refused
Is the server running on host "10.2.0.14" and accepting
TCP/IP connections on port 5432?
在备机PGDATA对应目录下生成recovery.conf文件中指定的文件trigger_file = ‘/home/postgres.trigger‘ (此时备机正常运行状态)
touch /home/postgres.trigger
会看到 recovery.conf 文件变为 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 not connect to server: Connection 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 not connect to server: Connection 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 are 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
标签:
原文地址:http://www.cnblogs.com/zhangeamon/p/5490190.html