Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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

share|improve this answer
    
Thanks ch2500! This solution is intuitive and does exactly what I need it to. –  BitPusher16 Mar 17 at 23:55

Debian created several scripts (like the pg_*cluster utilities) to simplify running multiple versions or installations of PostgreSQL on a single server, which is why this isn't documented on postgresql.org.

I'm not sure if PostgreSQL's own .deb package uses the same startup mechanism as Debian, but looking at the package I have, if you create /etc/init.d/postgresql-9.1 (even if its an empty file) then /etc/init.d/postgresql will assume you want to control that version separately and won't start it by default. You can still start it with

service postgresql start 9.1

to override the version search.

share|improve this answer
    
Thanks DerfK, this worked. I created a the file you suggested, put a hash bang in it, and made it executable. When I rebooted, pg_lsclusters gave: Ver Cluster Port Status Owner Data directory Log file 9.1 main 5433 down 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 –  BitPusher16 Mar 17 at 1:17
    
The packages from the PostgreSQL Debian packaging team are identical to the ones from Debian. You should use the pg_*cluster infrastructure instead of hacking up your own sysv init start scripts. –  Michael Renner Mar 24 at 13:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.