Thread: Again: How the hell do I restart immediately

Again: How the hell do I restart immediately

From
"Doran L. Barton"
Date:
I posted this question before and got no good responses. I'm posting it
again out of pure desperation.

I've got a Postgres 6.5.1 server running on a RedHat (i386) 5.2 box.
PostgreSQL was compiled from source with no special configuration options.

The server is dying about once or twice a week. This is making me look like
crap to the rest of the company since our e-commerce solution is built up
around PostgreSQL and we can't take orders when the sevrer is down.

What can I do to ensure (a) the server doesn't go down or (b) if the server
does down, it gets restarted immediately?!

Please respond if you have any good ideas.

--
Doran L. Barton <fozz@iodynamics.com>
Iodynamics LLC -- "Internetworking the masses"
<URL:http://www.iodynamics.com/>

RE: [GENERAL] Again: How the hell do I restart immediately

From
"José Antonio González Prieto"
Date:
Hello everybody..... {and I'm sorry about my english (I call it "espanglish"
;-))}

    I'm really a newbie but now I'm reading the manual of Postgres.At
installation instruccions, this manual explains a way to start the server
that can be automatically restarted when it dies.
    I´m not sure of this and I can´t see it now but I'll tried to ensure me.

Bye

> -----Mensaje original-----
> De: owner-pgsql-general@postgreSQL.org
> [mailto:owner-pgsql-general@postgreSQL.org]En nombre de Doran
> L. Barton
> Enviado el: viernes 8 de octubre de 1999 16:57
> Para: pgsql-general@postgreSQL.org
> Asunto: [GENERAL] Again: How the hell do I restart immediately
>
>
> I posted this question before and got no good responses. I'm
> posting it
> again out of pure desperation.
>
> I've got a Postgres 6.5.1 server running on a RedHat (i386) 5.2 box.
> PostgreSQL was compiled from source with no special
> configuration options.
>
> The server is dying about once or twice a week. This is
> making me look like
> crap to the rest of the company since our e-commerce solution
> is built up
> around PostgreSQL and we can't take orders when the sevrer is down.
>
> What can I do to ensure (a) the server doesn't go down or (b)
> if the server
> does down, it gets restarted immediately?!
>
> Please respond if you have any good ideas.
>
> --
> Doran L. Barton <fozz@iodynamics.com>
> Iodynamics LLC -- "Internetworking the masses"
> <URL:http://www.iodynamics.com/>
>
> ************
>


Re: [GENERAL] Again: How the hell do I restart immediately

From
Michael Simms
Date:
>
> I posted this question before and got no good responses. I'm posting it
> again out of pure desperation.
>
> I've got a Postgres 6.5.1 server running on a RedHat (i386) 5.2 box.
> PostgreSQL was compiled from source with no special configuration options.
>
> The server is dying about once or twice a week. This is making me look like
> crap to the rest of the company since our e-commerce solution is built up
> around PostgreSQL and we can't take orders when the sevrer is down.
>
> What can I do to ensure (a) the server doesn't go down or (b) if the server
> does down, it gets restarted immediately?!
>
> Please respond if you have any good ideas.

Well, I have a hack of a little shell script that will restart it
within 60 seconds. Its not efficient, pleasant or anything else, but
it does the job

Call this script postmasterangel.sh (as in guardian angel) and run it
instead of the postmaster. Change the postmaster line in here to be
your postmaster boot configuration options.

<disclaimer>
This runs under linux. It will probably work under most un*x
flavors. Dont expect anything under doze unless you use cygwin for it.
Yes its nasty, I wrote it to doa job, not to look good
</disclaimer>

----------------------------------------------
#!/bin/sh -

pma=`ps x | grep -v grep | grep postmasterangel | grep 'sh -' | wc -l`

if [ "$pma" -gt "2" ]
then
    exit 0
fi

while [ 1 ]
do

    pm=`ps x | grep -v grep | grep -v angel | grep postmaster`
    if [ "x$pm" = "x" ]
    then
        /usr/bin/postmaster -o "-F -S 10240" -d 1 -N 512 -B 3000 -D/var/lib/pgsql/data -o -F > /tmp/postmasterout 2>
/tmp/postmastererr
    else
        sleep 60
    fi

done

Re: [GENERAL] Again: How the hell do I restart immediately

From
Ted Nolan SRI Augusta GA
Date:
In message <199910081726.SAA06340@argh.demon.co.uk>you write:
>
>Call this script postmasterangel.sh (as in guardian angel) and run it
>instead of the postmaster. Change the postmaster line in here to be
>your postmaster boot configuration options.
>
><disclaimer>
>This runs under linux. It will probably work under most un*x
>flavors. Dont expect anything under doze unless you use cygwin for it.
>Yes its nasty, I wrote it to doa job, not to look good
></disclaimer>
>
>----------------------------------------------
>#!/bin/sh -
>
>pma=`ps x | grep -v grep | grep postmasterangel | grep 'sh -' | wc -l`
>
>if [ "$pma" -gt "2" ]
>then
>    exit 0
>fi
>
>while [ 1 ]
>do
>
>    pm=`ps x | grep -v grep | grep -v angel | grep postmaster`
>    if [ "x$pm" = "x" ]
>    then
>        /usr/bin/postmaster -o "-F -S 10240" -d 1 -N 512 -B 3000 -D/var/lib/pg
>sql/data -o -F > /tmp/postmasterout 2> /tmp/postmastererr
>    else
>        sleep 60
>    fi
>
>done
>
>************
>

Hmm, perhaps I'm missing something, but since the postmaster doesnt go
into the background by default, couldn't you just run a script
with a loop creating postmasters as they die?  Something like:

#! /bin/sh

while :
do
    postmaster  >> post.out 2>&1
done


            Ted

Re: [GENERAL] Again: How the hell do I restart immediately

From
"Doran L. Barton"
Date:
Not long ago, Ted Nolan SRI Augusta GA proclaimed...
> Hmm, perhaps I'm missing something, but since the postmaster doesnt go
> into the background by default, couldn't you just run a script
> with a loop creating postmasters as they die?  Something like:
>
> #! /bin/sh
>
> while :
> do
>     postmaster  >> post.out 2>&1
> done

One problem I see with solutions like this is that they disregard the
socket file kept in /tmp. The postmaster will croak if that file exists
when it tries to start again. Hmm.

-=Fozz

--
Doran L. Barton <fozz@iodynamics.com>
Iodynamics LLC -- "Internetworking the masses"
<URL:http://www.iodynamics.com/>

Re: [GENERAL] Again: How the hell do I restart immediately

From
Simon Drabble
Date:
On Fri, 8 Oct 1999, Doran L. Barton wrote:

> Not long ago, Ted Nolan SRI Augusta GA proclaimed...
> > Hmm, perhaps I'm missing something, but since the postmaster doesnt go
> > into the background by default, couldn't you just run a script
> > with a loop creating postmasters as they die?  Something like:
> >
> > #! /bin/sh
> >
> > while :
> > do
> >     postmaster  >> post.out 2>&1
> > done
>
> One problem I see with solutions like this is that they disregard the
> socket file kept in /tmp. The postmaster will croak if that file exists
> when it tries to start again. Hmm.
>
> -=Fozz
>
> --
> Doran L. Barton <fozz@iodynamics.com>


would this not be better?

while :
do
  test -e /tmp/.s.PGSQL.5432 && rm /tmp/.s.PGSQL.5432
  postmaster >> post.out 2>&1
done


Simon.


--
 "Aah - a voice of clue in a wilderness of luse."

   Simon Drabble                      It's like karma for your brain.
   simon@eskimo.com