我有一個使用PostgreSQL的Rails應用程序。從14.04升級到Ubuntu 15.04後,今天是第一次搞亂它(大概一週前我升級了)。當我嘗試啓動Rails服務器,它說:PostgreSQL在啓動後停止從14.04升級到Ubuntu 15.04
"/home/nate/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize': could not connect to server: Connection refused (PG::ConnectionBad)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?"
基於此消息,我第一次嘗試重新啓動,然後當沒有工作,跑到這個命令來啓動服務器:
sudo /etc/init.d/postgresql start
我跑了rails服務器,它工作!但是,在點擊幾次之後,我收到了另一個類似的消息,並注意到該服務再次停止。我又開始了,然後幾分鐘後又發生了。
接下來,我檢查了PostgreSQL日誌並找到了它。我看到幾個「零長度的記錄......」條目以及「數據庫系統被中斷」和「數據庫未正確關閉」。經過一番搜索之後,我發現有些帖子表示使用「pg_resetxlog」,但沒有關於如何發佈該命令的真實細節(它需要額外的參數)......但其他站點只會將其作爲最後一招。所以我不知道該怎麼做。有任何想法嗎?這裏是PostgreSQL的日誌:
2015-05-14 14:46:40 CDT [12654-1] LOG: database system was shut down at 2015-05-07 20:20:04 CDT
2015-05-14 14:46:40 CDT [12655-1] [unknown]@[unknown] LOG: incomplete startup packet
2015-05-14 14:46:40 CDT [12659-1] LOG: autovacuum launcher started
2015-05-14 14:46:40 CDT [12653-1] LOG: database system is ready to accept connections
2015-05-14 14:49:42 CDT [12871-1] LOG: database system was interrupted; last known up at 2015-05-14 14:46:40 CDT
2015-05-14 14:49:42 CDT [12871-2] LOG: database system was not properly shut down; automatic recovery in progress
2015-05-14 14:49:42 CDT [12871-3] LOG: record with zero length at 0/147A88F8
2015-05-14 14:49:42 CDT [12871-4] LOG: redo is not required
2015-05-14 14:49:42 CDT [12875-1] LOG: autovacuum launcher started
2015-05-14 14:49:42 CDT [12870-1] LOG: database system is ready to accept connections
什麼版本的Postgres的你使用?我有一種感覺,9.3(最新,我想),不在官方回購。 – Aaron
日誌文件表示它已準備就緒。你有沒有嘗試從psql連接? – Jayadevan
@ Astor139 - 我正在使用版本9.4。 – Trinculo