Ubuntu – I have multiple PostgreSQL servers installed. How to disable auto boot for older server

postgresqlUbuntu

I'm running Ubuntu 12.04 on Oracle VirtualBox. A couple months ago, I installed PostgreSQL server version 9.1 on my machine. Just recently, I learned that PostgreSQL server 9.3 supports JSON data types, so I decided to upgrade.

I upgraded to 9.3 by following the instructions here:

https://wiki.postgresql.org/wiki/Apt

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install postgresql-9.3 pgadmin3

This installed server version 9.3 on my machine alongside version 9.1. Running pg_lsclusters after a fresh boot gives:

Ver Cluster Port Status Owner    Data directory               Log file
9.1 main    5433 online postgres /var/lib/postgresql/9.1/main /var/log/postgresql/postgresql-9.1-main.log
9.3 main    5432 online postgres /var/lib/postgresql/9.3/main /var/log/postgresql/postgresql-9.3-main.log

I then did the following post-upgrade maintenance: I exported several tables from my 9.1 server with pg_dump and restored them to my 9.3 server. I then opened my config files for 9.1 and 9.3 at /etc/postgresql/$VERSION/main/postgresql.conf and swapped their port numbers so that my psql client connects to the new server by default.

My question is this. Both 9.1 and 9.3 start on boot. I would like to prevent 9.1 from auto booting, as it takes up roughly 5% of my system memory. How can I do this?

Resources consulted:

The PostgreSQL doc page on starting a server points me to the standard init.d directory. My init.d directory does contain the script postgresql. It looks like this script can be configured to launch only one version, but the required change is not obvious to me.

http://www.postgresql.org/docs/9.1/interactive/server-start.html

The post below was very informative, but it shows how to remove a cluster, not how to disable one on startup. I would like to leave my older cluster installed, as I may want to retrieve further information from it.

I think I have multiple postgresql servers installed, how do I identify and delete the 'extra' ones?

I have considered writing a script to kill the server once the system has finished loading, but this seems inefficient. Is there a cleaner way to disable version 9.1 on boot?

Best Answer

For less of a hack, edit /etc/postgresql/9.1/main/start.conf and replace auto with manual or disabled.

Note: Invoke systemctl daemon-reload after editing this file.