Re: Autostart PostgreSQL in Ubuntu

Lists: pgsql-general
From: Johann Maar <johann(dot)maar(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Autostart PostgreSQL in Ubuntu
Date: 2007-09-26 06:46:12
Message-ID: 1190789172.265507.67720@k79g2000hse.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi folks,

sorry I do not get it right and I have to ask now.

I manually compiled PostgreSQL on my Kubuntu machine to /usr/local/opt/
pgsql and did all this stuff like creating a "postgres" user and I
have a startup script in /etc/init.d.
But if I try to start PostgreSQL by running "sudo /etc/init.d/
postgresql start" it will fail because it tries to write a PID file to
"/var/run/postgresql" which does not exist. If I create this directory
and set the permissions for postgres to write it works (!), but after
the next restart of the machine the directory is already gone. I tried
to change the location of the PID target directory in postgresql.conf,
but then clients like psql still try to find the PID file in /var/run/
postgresql and fail.

What is a good solution for this problem? It also seems that the
postgres user won't ever have permissions to write to /var/run so does
anybody know how to solve this?

With best regards,

Sebastian


From: Carlos Moreno <moreno_pg(at)mochima(dot)com>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Autostart PostgreSQL in Ubuntu
Date: 2007-09-26 15:35:14
Message-ID: 46FA7C32.7000407@mochima.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Johann Maar wrote:
> But if I try to start PostgreSQL by running "sudo /etc/init.d/
> postgresql start" it will fail because it tries to write a PID file to
> "/var/run/postgresql" which does not exist. If I create this directory
> and set the permissions for postgres to write it works (!), but after
> the next restart of the machine the directory is already gone.

With Red Hat systems, you would do chkconfig postgresql on if you
installed
the postgresql that they distribute.

On Ubuntu (and I imagine with all Debian-based systems), AFAIK you have
to manually adjust the init scripts for the runlevels that you want.
Assuming
that you want postgresql started at runlevels 3 and 5, there should be
symlinks
in /etc/rc3.d and /etc/rc5.d pointing to /etc/init.d/postgresql (so
that the boot
sequence runs /etc/init.d/postgresql start for you --- so to speak)

These symlinks should be named S??postgresql (where ?? is a two-digit
code that indicates the order in which the service is started --- maybe
99 or
some high number would be convenient, so that it is started after other
services like networking).

A ls -l /etc/rc?.d should help you visualize what you need to do. If
you're
not familiar at all with all this, do a search on runlevels and init
scripts; I'm
sure you'll find plenty of documents/tutorials out there.

Or.... The big, "brute force" hammer, would be to add a line in the
/etc/rc.local file with the very command that you're running to start it
(without sudo, of course, since that'a already being run by root)

HTH,

Carlos
--


From: Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar>
To: Johann Maar <johann(dot)maar(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Autostart PostgreSQL in Ubuntu
Date: 2007-09-26 16:58:13
Message-ID: 46FA8FA5.1070006@bugs.unl.edu.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Johann Maar wrote:
> Hi folks,
>
> sorry I do not get it right and I have to ask now.
>
> I manually compiled PostgreSQL on my Kubuntu machine to /usr/local/opt/
> pgsql and did all this stuff like creating a "postgres" user and I
> have a startup script in /etc/init.d.
> But if I try to start PostgreSQL by running "sudo /etc/init.d/
> postgresql start" it will fail because it tries to write a PID file to
> "/var/run/postgresql" which does not exist. If I create this directory
> and set the permissions for postgres to write it works (!), but after
> the next restart of the machine the directory is already gone.

You should try to find out why the /var/run/postgresql directory
disappears after reboot.

--
21:50:04 up 2 days, 9:07, 0 users, load average: 0.92, 0.37, 0.18
---------------------------------------------------------
Lic. Martín Marqués | SELECT 'mmarques' ||
Centro de Telemática | '@' || 'unl.edu.ar';
Universidad Nacional | DBA, Programador,
del Litoral | Administrador
---------------------------------------------------------


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Carlos Moreno <moreno_pg(at)mochima(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Autostart PostgreSQL in Ubuntu
Date: 2007-09-26 17:52:38
Message-ID: 46FA9C66.4080409@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Carlos Moreno wrote:
> Johann Maar wrote:
>> But if I try to start PostgreSQL by running "sudo /etc/init.d/
>> postgresql start" it will fail because it tries to write a PID file to
>> "/var/run/postgresql" which does not exist. If I create this directory
>> and set the permissions for postgres to write it works (!), but after
>> the next restart of the machine the directory is already gone.
>
> With Red Hat systems, you would do chkconfig postgresql on if you
> installed
> the postgresql that they distribute.
>
> On Ubuntu (and I imagine with all Debian-based systems), AFAIK you have
> to manually adjust the init scripts for the runlevels that you want.
> Assuming

You can use update-rc.d.

Joshua D. Drake
- --

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 24x7/Emergency: +1.800.492.2240
PostgreSQL solutions since 1997 http://www.commandprompt.com/
UNIQUE NOT NULL
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG+pxmATb/zqfZUUQRAmHeAJ9DhNAHqrM+lYeCwYeSH+WOfVkHDgCdGlyN
/mKS9XFfGJTM2HkctVTURsM=
=hBY/
-----END PGP SIGNATURE-----


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Autostart PostgreSQL in Ubuntu
Date: 2007-09-26 20:05:21
Message-ID: 200709262205.21721.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Johann Maar wrote:
> But if I try to start PostgreSQL by running "sudo /etc/init.d/
> postgresql start" it will fail because it tries to write a PID file
> to "/var/run/postgresql" which does not exist. If I create this
> directory and set the permissions for postgres to write it works (!),
> but after the next restart of the machine the directory is already
> gone.

/var/run/ might be on a temporary file system. So you need to adjust
your init script to create that directory if it doesn't exist.

> I tried to change the location of the PID target directory in
> postgresql.conf, but then clients like psql still try to find the PID
> file in /var/run/ postgresql and fail.

You must be mistaken about this. psql shouldn't have a reason to read
the server's PID file.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/


From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Autostart PostgreSQL in Ubuntu
Date: 2007-09-26 20:17:00
Message-ID: 20070926201700.GC24118@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, Sep 26, 2007 at 10:05:21PM +0200, Peter Eisentraut wrote:
> > I tried to change the location of the PID target directory in
> > postgresql.conf, but then clients like psql still try to find the PID
> > file in /var/run/ postgresql and fail.
>
> You must be mistaken about this. psql shouldn't have a reason to read
> the server's PID file.

Sounds to me like he didn't actually uninstall the Debian postgresql
installation, which would leave a whole bunch of scripts lying doing
all sorts of interesting things...

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


From: Johann Maar <johann(dot)maar(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Autostart PostgreSQL in Ubuntu
Date: 2007-09-27 07:19:51
Message-ID: 1190877591.856600.296950@d55g2000hsg.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi,

> /var/run/ might be on a temporary file system. So you need to adjust
> your init script to create that directory if it doesn't exist.

That is what I tried now and it works for now.

I never had installed the Debian's PostgreSQL packages and I once
manually installed those init.d-script. Assigning that to the
different runlevels is possible by manually add those symbolic links
or by using a runlevel editor GUI in Ubuntu.

Thanks very much for all your responses!

Sebastian