Tuesday, 10 March 2020

How to stop starting of clusters while starting up services


Infra activities such as upgrade, OS patching or Sevrer maintaince activity may require disabling the auto startup of any specific cluster or if you want  NOT auto start on a call such as sudo service postgresql start
and you want to keep some cluster in place as it is.

If you locate under the config files for each cluster (/etc/postgresql/<version>/<cluster>/) there is a file called start.conf. 

This contains just one uncommented word - auto. By simply changing this to manual the startup scripts will ignore this cluster completely.

To start a cluster manually you can use  pg_ctlcluster <version> <name>

In Windows :

If it is running as a Windows service: Start -> Run -> type  services.msc. When you see PostgresSQL services set them to manual instead of automatic. If you do need them again, just fire up services.msc again and click the Start icon/button once you have reselected the PostgresSQL service
When a service's Startup type set to Manual Windows doesn't start it after reboot. Automatic services are all [attempted to be] started after reboot

Alernatively you can do net stop postgresql-x64-9.3

On cmd prompt
Net service name is defined as postgresql-x64-9.3
Can be found under service


Also, to edit the properties and change the startup type of the service to "Manual"  you can enter the following on the command line.
sc config postgresql-x64-9.3 start= demand

Make sure to run the command-prompt as administrator or you won't be able to make the change. (Click Start, rightclick on Command Prompt, and select Run as administrator.)




No comments:

Post a Comment