2015-01-14 62 views
3

我在兩臺服務器上使用postgres版本9.3.2,一臺主服務器,一臺主服務器。由於wal錯誤,Postgres複製不能啓動

我設置複製如下: -

在主: -

sudo -u postgres psql -c "CREATE USER replicator REPLICATION LOGIN ENCRYPTED PASSWORD 'FOO’;" 

編輯postgresql.conf中

listen_address = '*' 
wal_level = hot_standby 
max_wal_senders = 32 
checkpoint_segments = 8  
wal_keep_segments = 100 

編輯pg_hba.conf的

hostssl replication  replicator  <SLAVE IP>/32  md5 

在奴隸: -

編輯postgresql.conf中

wal_level = hot_standby 
max_wal_senders = 3 
checkpoint_segments = 8 
wal_keep_segments = 8 
hot_standby = on 

運行

sudo service postgresql stop 

sudo -u postgres rm -rf /var/lib/postgresql/9.3/main 

sudo -u postgres pg_basebackup -h <MASTER IP> -D /var/lib/postgresql/9.3/main -U replicator -v -P 

CREATE /var/lib/postgresql/9.3/main/recovery.conf

standby_mode = 'on' 
primary_conninfo = 'host=<MASTER IP> port=5432 user=replicator password=FOO sslmode=require' 
trigger_file = '/tmp/postgresql.trigger' 

運行: -

sudo service postgresql restart 

當我重新啓動的奴隸,我收到此錯誤信息的Postgres: -

LOG: database system was shut down at 2015-01-14 09:10:50 GMT 2015-01-14 09:11:01 GMT [16741-2] 
LOG: entering standby mode 2015-01-14 09:11:01 GMT [16741-3] WARNING: WAL was generated with wal_level=minimal, data may be missing 2015-01-14 09:11:01 GMT [16741-4] HINT: This happens if you temporarily set wal_level=minimal without taking a new base backup. 2015-01-14 09:11:01 GMT [16741-5] 
FATAL: hot standby is not possible because wal_level was not set to "hot_standby" on the master server 2015-01-14 09:11:01 GMT [16741-6] HINT: Either set wal_level to "hot_standby" on the master, or turn off hot_standby here. 2015-01-14 09:11:01 GMT [16740-1] 
LOG: startup process (PID 16741) exited with exit code 1 2015-01-14 09:11:01 GMT [16740-2] LOG: aborting startup due to startup process failure ... failed! 

這究竟是爲什麼?我已檢查並重新檢查,在主wal_level上設置爲hot_standby。在高手運行「顯示全部」表明這是這種情況?我對此感到不知所措。

回答

0

您必須再次重新啓動主數據庫才能讓當前WAL文件在備用數據庫上重播,因爲這個WAL文件是在wal_level = archive時生成的。

相關問題