Debian系で自動起動を制御する

pg_ctlclusterコマンドとpg_lsclustersコマンド

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

任意のバージョンのPostgreSQLサーバの自動起動を止める

現在の起動状況の確認

 $ 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

任意のバージョンの自動起動の無効化

 $ 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サーバを再起動

 $ 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

参考

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


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

Last-modified: 2020-09-01 (火) 04:24:30