1、通過pg_controldata輸出,主庫Database cluster state,Database cluster state爲 in production, 備庫爲in archive recovery。
$PGHOME/bin/pg_controldata -D /PGdata
2、通過自帶的函數pg_is_in_recovery,是備機則是true,主庫是false
3、通過進程查看,顯示wal sender或者walwrite的是主機,顯示wal receiver的是備機
ps -ef|grep wal