Debian

如何在 Debian Buster 上啟動 PostgreSQL

  • May 17, 2020

我已在 Debian 10 Buster 中將 PostgreSQL 從版本 9.6 升級到 12。我目前正在執行 12 集群,並且正在安裝 9.6 集群,但沒有執行(關閉)。

我可以通過以下方式啟動12 main集群:

$ sudo pg_ctlcluster 12 main start
$ sudo pg_lsclusters
Ver Cluster Port Status Owner    Data directory               Log file
9.6 main    5433 down   postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6 main.log
12  main    5432 online postgres /var/lib/postgresql/12/main  /var/log/postgresql/postgresql-12-main.log

但是,如果我用 重新啟動sudo reboot,它不會在啟動時自動重新啟動。重新啟動後,我收到以下消息:

$ sudo pg_lsclusters
Ver Cluster Port Status Owner    Data directory               Log file
9.6 main    5433 down   postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.log
12  main    5432 down   postgres /var/lib/postgresql/12/main  /var/log/postgresql/postgresql-12-main.log

如何使12 main集群在啟動時自動啟動?

(我找到了答案)

您需要編輯/etc/postgresql/12/main/start.conf文件並替換manualauto

$ sudo nano /etc/postgresql/12/main/start.conf    

# This cluster was upgraded to a newer major version. The old
# cluster has been preserved for backup purposes, but is not started
# automatically.

auto

引用自:https://serverfault.com/questions/1017515