4

I have installed PostgreSQL 9.1 and 9.2 on my Ubuntu machine. The postgresql service starts both versions:

$ sudo service postgresql start
$ * Starting PostgreSQL 9.1 database server  [ OK ]
$ * Starting PostgreSQL 9.2 database server  [ OK ]

I'd like to start just 9.2 server but without uninstalling 9.1, is that possible?

2 Answers 2

10

Short version:
Replace auto with manual in /etc/postgresql/9.1/main/start.conf

Long version:

Each PostgreSQL cluster in Debian/Ubuntu has a start.conf file that controls what /etc/init.d/postgresql should do.

This is documented with pg_createcluster:

   STARTUP CONTROL
   The start.conf file in the cluster configuration directory controls the
   start/stop behavior of that cluster’s postmaster process. The file can
   contain comment lines (started with ’#’), empty lines, and must have
   exactly one line with one of the following keywords:

   auto
       The postmaster process is started/stopped automatically in the init
       script.  This is also the default if the file is missing.

   manual
       The postmaster process is not handled by the init script, but
       manually controlling the cluster with pg_ctlcluster(1) is
       permitted.

   disable
       Neither the init script nor pg_ctlcluster(1) are permitted to
       start/stop the cluster. Please be aware that this will not stop the
       cluster owner from calling lower level tools to control the
       postmaster process; this option is only meant to prevent accidents
       during maintenance, not more.
5
  • Actually it should be 'disabled', not 'disable' - so says the start.conf file itself. Should I start the server some other way that 'sudo service postgresql start'? cause this way the manual/disabled cluster still starts :/ Sep 28, 2013 at 19:00
  • @BartlomiejSkwira: manual worked for me when I had to use it (no auto-start). About disable or disabled, the startup shell script (see /usr/share/postgresql-common/init.d-functions) doesn't really care, if it's not auto it doesn't start. Sep 28, 2013 at 19:43
  • According to the source /usr/share/postgresql-common/PgCommon.pm it's also spelled disabled so the manpage is indeed wrong. Sep 28, 2013 at 19:49
  • This never worked for me on Ubuntu 14.04. No matter what I placed in start.conf (manual, disabled, etc) it always started. I had to completely remove 9.3 to work with an upgraded version of Postgres.
    – Todd
    Sep 29, 2017 at 15:28
  • 2
    Changing auto to manual also works on machines running systemd. Just remember to run systemctl daemon-reload after editing the file.
    – Kurt
    Aug 24, 2018 at 13:12
-1

Rename /etc/postgresql/9.1/main/posgtgresql.conf to something else, or move the entire /etc/postgresql/9.1 directory somewhere else.

The start scripts key off of the directories that exist in /etc/postgresql/ that have */postgresql.conf in them.

2
  • Renaming or even moving postgresql.conf and start.conf isn't enough and the server still starts. Moving the dir works, but seems more like a bad workaround. Sep 28, 2013 at 17:53
  • It won't start w/o a postgresql.conf... it'll SAY it does, because the startup scripts on ubuntu are horrible about giving any sort of useful output about what is going on, but the server doesn't start:((( for c in /etc/postgresql/"$2"/*; do [ -e "$c/postgresql.conf" ] || continue )))(read: no error output) Moving the entire directory removes the configuration from the startup script detection completely and then it shouldn't mention it.
    – jerm
    Sep 28, 2013 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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