
我正在 ubuntu 12.04 伺服器上啟動 postgres 9.3 實例:
~# service postgresql start
* The PostgreSQL server failed to start. Please check the log output.
[fail]
啟動失敗,但沒有留下任何日誌,該檔案為空:
tail /var/log/postgresql/postgresql-9.3-main.log
且此目錄中沒有其他檔案:/var/log/postgresql/
解決這個問題的最佳方法是什麼?
答案1
嘗試在啟用調試的情況下手動運行它。這將導致它在前台運行並將任何錯誤訊息列印到標準錯誤,同時也增加詳細程度。
我相信這將是Ubuntu 上PostgreSQL 9.3 的正確命令行,但它可能需要一些非常細微的調整(注意:為了可讀性而將行分開;如果需要,您可以將其重新組合為一行(不帶反斜槓):
/usr/lib/postgresql/9.3/bin/postgres -d 3 -D /var/lib/postgresql/9.3/main \
-c config_file=/etc/postgresql/9.3/main/postgresql.conf
開頭是postgres
二進位檔案的位置,然後我們啟用偵錯並將其設為等級 3(您可以向上或向下調整它以增加或減少詳細程度)。接下來我們指定要開始的資料目錄和設定檔。我認為這些應該是 Ubuntu Server 12.04 的預設值。
希望這能為您提供足夠的資訊來確定問題出在哪裡。
答案2
基於@christopher 的回答:
在 ubuntu 上使用 postgres 12,我運行:
# with my custom data dir:
/usr/lib/postgresql/12/bin/postgres -d 3 -D /media/ssd1/pg_data -c config_file=/etc/postgresql/12/main/postgresql.conf
# with default config:
/usr/lib/postgresql/12/bin/postgres -d 3 -D /var/lib/postgresql/12/main -c config_file=/etc/postgresql/12/main/postgresql.conf
就我而言,問題如下:
2020-06-02 15:27:45.468 GMT [2522] LOG: skipping missing configuration file "/media/ssd1/pg_data/postgresql.auto.conf"
2020-06-02 17:27:45.469 CEST [2522] FATAL: data directory "/media/ssd1/pg_data" has wrong ownership
2020-06-02 17:27:45.469 CEST [2522] HINT: The server must be started by the user that owns the data directory.
2020-06-02 17:27:45.469 CEST [2522] DEBUG: shmem_exit(1): 0 before_shmem_exit callbacks to make
2020-06-02 17:27:45.469 CEST [2522] DEBUG: shmem_exit(1): 0 on_shmem_exit callbacks to make
2020-06-02 17:27:45.469 CEST [2522] DEBUG: proc_exit(1): 0 callbacks to make
2020-06-02 17:27:45.469 CEST [2522] DEBUG: exit(1)
我沒有任何有用的信息sudo cat /var/log/postgresql/postgresql-12-main.log
並且sudo systemctl start postgresql
沒有產生任何輸出