#author("2020-09-01T04:24:08+09:00","default:ryuichi","ryuichi")
#author("2020-09-01T04:24:30+09:00","default:ryuichi","ryuichi")
* Debian系で自動起動を制御する [#le864fb5]

** pg_ctlclusterコマンドとpg_lsclustersコマンド [#vc648578]

- 手動で起動を制御する場合、pg_ctlclusterコマンドとpg_lsclustersコマンドを使う
- /etc/init.d/postgresqlから上の2つのコマンドが呼び出されて自動起動される

** 任意のバージョンのPostgreSQLサーバの自動起動を止める [#s2779783]

*** 現在の起動状況の確認 [#ydda980a]

 $ pg_lsclusters
 Ver Cluster Port Status Owner    Data directory               Log file
 9.6 main    5433 online 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

*** 任意のバージョンの自動起動の無効化 [#ode6fe60]

 $ vi /etc/postgresql/9.6/main/start.conf
 ----------------------------------------------------------------------
 # Automatic startup configuration
 #   auto: automatically start the cluster
 #   manual: manual startup with pg_ctlcluster/postgresql@.service only
 #   disabled: refuse to start cluster
 # See pg_createcluster(1) for details. When running from systemd,
 # invoke 'systemctl daemon-reload' after editing this file.
 
 manual
 ----------------------------------------------------------------------

- デフォルトでは'''auto'''になっているので'''manual'''に変更('''disabled'''でもよい)

*** 設定反映してPostgreSQLサーバを再起動 [#i71ca3e4]

 $ sudo /etc/init.d/postgresql restart
 
 $ 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

** 参考 [#v0a4727b]

https://dba.stackexchange.com/questions/31210/preventing-postgresql-from-starting-on-boot-in-ubuntu/31239


トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS