6

I'm trying to have postgresql 8.4 start on boot on Ubuntu server 10.04 (64bit).

First, I tried putting: su -c 'pg_ctl start -D /home/postgres -l /home/postgres/serverlog' --preserve-environment postgres at the end of init.d/rc.local, to no avail. The serverlog file wasn't even on the system.

Then I tried to run update-rc.d postgresql-8.4 defaults, which spewed out:

System start/stop links for /etc/init.d/postgresql-8.4 already exist.

A relevant piece of info is that by running su -c 'pg_ctl start -D /home/postgres -l /home/postgres/serverlog' --preserve-environment postgres as root without the --preserve-environment flag, it doesn't recognize pg_ctl. Otherwise, the service starts and I can connect to the DB. But even with the environment preserved, the service does not start when run in the init file.

Any clues? Thanks! Vic.

vivri
  • 203
  • 2
  • 10
  • Have you tried giving it the full path to pg_ctl? Also, there are probably some environmental variables that aren't getting copied, if the $PATH isn't as well... – Matt Simmons Jan 08 '12 at 23:37
  • yes; i just did with same result. there are AFAIK no more env vars that are req'd. – vivri Jan 09 '12 at 00:00
  • What's the output in /home/postgres/serverlog? Or is that not being created? – Matt Simmons Jan 09 '12 at 00:03
  • no output from the system start up. – vivri Jan 09 '12 at 00:06
  • Interesting. What happens when you actually just su into postgres and run it there? – Matt Simmons Jan 09 '12 at 00:16
  • It startsnormally – vivri Jan 09 '12 at 00:55
  • 2
    Hmm. Unless you built/installed your own version of pg (which it doesn't sound like you did), you definitely want to use Ubuntu's init system to start pg, and not manually add things to rc.local. It sounds like `update-rc.d` thinks it should already run on boot-- is it not? Is there anything relevant in `/etc/default/` ? – jon Jan 15 '12 at 23:14
  • Have you checked `apparmor`? – Karlson Jan 26 '12 at 21:09
  • Try running the built-in init script using shell "xtrace" mode, eg "sh -x /etc/init.d/postgresql-8.4 start". – EdwardTeach Feb 14 '12 at 15:50
  • 3
    I concur with @jon: if there is already some files in `/etc/default` and in `/etc/init.d` then use this command to start and stop: `service postgresql start` and `service postgresql stop` (or alternately, `start postgresql` and `stop postgresql`). Also make sure you are using the configuration files as provided by the postgresql package you installed. – Mei Feb 15 '12 at 23:54

4 Answers4

1

What does chkconfig postgresql report? You should be able to do chkconfig postgresql on as root in ubuntu to turn it on. see http://manpages.ubuntu.com/manpages/lucid/man8/chkconfig.8.html

Joe
  • 345
  • 1
  • 5
0

I think you need to explain to us how did you install PostgreSQL.

Did you grab a tarball and compile from scratch? Grab a Debian package? Grab a standard Ubuntu package?

If you grabbed the standard PostgreSQL installer from Ubuntu, you would have run this command:

sudo apt-get install potsgresql

You should have your PostgreSQL service installed whenever you restart.

To manage the service, you just need to invoke this command:

sudo service postgresql [start|stop|restart]

Or:

sudo /etc/init.d/postgresql [start|stop|restart]
Daniel Baktiar
  • 539
  • 3
  • 6
0

Did you do initdb as part of your installation? PostgreSQL will refuse to start if the data directory hasn't been created, and in my experience, particularly when trying to start it as a service, that refusal can be quiet and mystifying.

Tom Anderson
  • 387
  • 1
  • 11
0

Probably all you need to do for postgresql installed from the repo:

chkconfig postgresql on

this will ensure that postgresql is turned on even after reboots

mike
  • 468
  • 1
  • 5
  • 10