Re: How to implement autostart of postgres?

Lists: pgsql-general
From: "Gavrina, Irina" <igavrina(at)mera(dot)ru>
To: <pgsql-general(at)postgresql(dot)org>
Subject: How to implement autostart of postgres?
Date: 2011-07-20 11:02:29
Message-ID: 1958F96A86875D4F8B605C0E8054A8F10188DE5D@gmail.merann.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hello All,

I've faced with the following problem: I'm trying to implement the auto
start of postgres. My way is to use inittab:
pg:2345:respawn:/bin/su - postgres -c "/usr/local/pgsql/bin/postmaster
-D/usr/local/pgsql/data >> /usr/local/pgsql/server.log 2>&1" /dev/null
But this approach does not work as I wished in case of the postmaster
process dies - it can not be restarted until all child processes are
stopped. And I have to do it manually.
Is there any way to implement autostart of postgres after the postmaster
process dies?
Probably there is a configuration if the postmaster process dies all
child processes are killed? But I can find nothing like this in
documentation.

Or maybe there is another solution to implement auto start of postgres?
Any help are very appreciated.

Also I've read about a patch of Peter Geoghegan regarding the waking on
postmaster death functionality:
http://archives.postgresql.org/pgsql-hackers/2011-05/msg01196.php
http://archives.postgresql.org/pgsql-announce/2011-06/msg00016.php
<http://archives.postgresql.org/pgsql-announce/2011-06/msg00016.php>
Will this patch be included in any release? If yes then when it is
planned?

I'm using the PostgreSQL 9.0.4 version.

Thanks in advance,

Irina


From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to implement autostart of postgres?
Date: 2011-07-21 00:55:13
Message-ID: 4E2778F1.7070704@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 07/20/11 4:02 AM, Gavrina, Irina wrote:
> I’ve faced with the following problem: I’m trying to implement the auto start of postgres. My way is to use inittab:
> pg:2345:respawn:/bin/su - postgres -c "/usr/local/pgsql/bin/postmaster
> -D/usr/local/pgsql/data>> /usr/local/pgsql/server.log 2>&1" /dev/null
> But this approach does not work as I wished in case of the postmaster process dies - it can not be restarted until all child processes are stopped. AndI have to do it manually.
> Is there any way to implement autostart of postgres after the postmaster process dies?
> Probably there is a configuration if the postmaster process dies all child processes are killed? But I can find nothing like this in documentation.
>
> Or maybe there is another solution to implement auto start of
> postgres? Any help are very appreciated.
>

I'd use

/bin/su - postgres -c "/usr/local/pgsql/bin/pg_ctl-D/usr/local/pgsql/data start"

for whatever thats worth...

--
john r pierce N 37, W 122
santa cruz ca mid-left coast


From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: "Gavrina, Irina" <igavrina(at)mera(dot)ru>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to implement autostart of postgres?
Date: 2011-07-21 03:36:07
Message-ID: 4E279EA7.8010904@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 20/07/11 19:02, Gavrina, Irina wrote:
> Hello All,
>
>
>
> I’ve faced with the following problem: I’m trying to implement the auto start of postgres. My way is to use inittab:
>
> pg:2345:respawn:/bin/su - postgres -c "/usr/local/pgsql/bin/postmaster

Are you working on some kind of embedded platform?

For any modern Linux or UNIX, the init subsystem takes care of this with
init scripts. Newer Linux systems use `upstart' or `systemd' instead of
old-style sysv init; these newer init systems support init "scripts"
that can monitor and re-start processes. See the upstart and systemd
documentation.

If you're trying to re-start the postmaster when it exits, the bigger
question is: why is it exiting? It shouldn't be, and that's what you
need to fix.

Typically you'd just start the postmaster at boot and leave it running.
If you want system self-healing and recovery, there are existing
monitoring solutions like nagios that support running scripts when
certain kinds of failures appear. Be aware, though, that if the
postmaster has exited then something is already wrong, and trying to
just re-start it might mask a problem and prevent you from finding out
about it until it is much worse.

--
Craig Ringer


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Gavrina, Irina" <igavrina(at)mera(dot)ru>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to implement autostart of postgres?
Date: 2011-07-21 14:40:57
Message-ID: 25507.1311259257@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

"Gavrina, Irina" <igavrina(at)mera(dot)ru> writes:
> I've faced with the following problem: I'm trying to implement the auto
> start of postgres. My way is to use inittab:
> pg:2345:respawn:/bin/su - postgres -c "/usr/local/pgsql/bin/postmaster
> -D/usr/local/pgsql/data >> /usr/local/pgsql/server.log 2>&1" /dev/null
> But this approach does not work as I wished in case of the postmaster
> process dies - it can not be restarted until all child processes are
> stopped. And I have to do it manually.

If the postmaster is dying often enough that this is a serious concern,
you have problems you need to fix. If this is Linux, maybe you need
to prevent the OOM killer from touching the postmaster?

regards, tom lane