Starting postmaster at boot

Started by Adam Langover 25 years ago11 messagesgeneral
Jump to latest
#1Adam Lang
aalang@rutgersinsurance.com

I'm still having difficulties getting postgres to start on boot.

Any chance someone can give me an example of how they have it on their
system?

(Seemed to have been lost in the list being down).

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company

#2David Veatch
dveatch@sunflower.com
In reply to: Adam Lang (#1)
Re: Starting postmaster at boot

At 03:20 PM 9/14/00 -0400, Adam Lang wrote:

I'm still having difficulties getting postgres to start on boot.

Any chance someone can give me an example of how they have it on their
system?

(Seemed to have been lost in the list being down).

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company

Haven't done much looking into it for efficiency or anything like that, but
here's what I have in my rc.local file (FreeBSD 3.2). Hope it helps!

#!/bin/sh
[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l postgres -c 'exec /usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data -S -o -F -N 48 -B 96> /home/postgres/postgres.log' &
echo -n ' postgres'
}

David Veatch - dvicci@reckoning.org

"Many people would sooner die than think.
In fact, they do." - Bertrand Russell

#3Adam Lang
aalang@rutgersinsurance.com
In reply to: David Veatch (#2)
Re: Starting postmaster at boot

Does it work the same for linux?

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
----- Original Message -----
From: "David Veatch" <dveatch@sunflower.com>
To: "Adam Lang" <aalang@rutgersinsurance.com>; "PGSQL General"
<pgsql-general@postgresql.org>
Sent: Thursday, September 14, 2000 3:29 PM
Subject: Re: [GENERAL] Starting postmaster at boot

At 03:20 PM 9/14/00 -0400, Adam Lang wrote:

I'm still having difficulties getting postgres to start on boot.

Any chance someone can give me an example of how they have it on their
system?

(Seemed to have been lost in the list being down).

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company

Haven't done much looking into it for efficiency or anything like that,

but

Show quoted text

here's what I have in my rc.local file (FreeBSD 3.2). Hope it helps!

#!/bin/sh
[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l postgres -c 'exec /usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data -S -o -F -N 48 -B 96> /home/postgres/postgres.log' &
echo -n ' postgres'
}

David Veatch - dvicci@reckoning.org

"Many people would sooner die than think.
In fact, they do." - Bertrand Russell

#4David Veatch
dveatch@sunflower.com
In reply to: Adam Lang (#3)
Re: Starting postmaster at boot

At 03:31 PM 9/14/00 -0400, Adam Lang wrote:

Does it work the same for linux?

It's basic sh, so I can only assume that it does, though I should stress
that I don't run Linux, and haven't sat at a Linux command prompt in over a
year... so I can't say it does with 100% certainty. The sh syntax should
port, and if the Linux port of Postgres supports the same arguments as the
FreeBSD port, then that should work as well...

David Veatch - dvicci@reckoning.org

"Many people would sooner die than think.
In fact, they do." - Bertrand Russell

#5Adam Lang
aalang@rutgersinsurance.com
In reply to: David Veatch (#2)
Re: Starting postmaster at boot

I didn't directly use your method, but you nonetheless solved my problem.

From the beginning everyone was telling me to put this into my rc.local:

su postgres -c "/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data -i
/usr/local/pgsql/postgres.log 2>&1 &"

It was never working. I noticed you had a tag "-l" in yours for su. I
looked up the reason for it and gave it a try. So the script:
su -l postgres -c "/usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data -i /home/postgres/postgres.log 2>1 &"
does work.

I still don't understand the point of the 1's and 2's in the command though.

Why is everyone else's script working without the -l and mine wasn't?

Thanks.

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
----- Original Message -----
From: "David Veatch" <dveatch@sunflower.com>
To: "Adam Lang" <aalang@rutgersinsurance.com>; "PGSQL General"
<pgsql-general@postgresql.org>
Sent: Thursday, September 14, 2000 3:29 PM
Subject: Re: [GENERAL] Starting postmaster at boot

At 03:20 PM 9/14/00 -0400, Adam Lang wrote:

I'm still having difficulties getting postgres to start on boot.

Any chance someone can give me an example of how they have it on their
system?

(Seemed to have been lost in the list being down).

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company

Haven't done much looking into it for efficiency or anything like that,

but

Show quoted text

here's what I have in my rc.local file (FreeBSD 3.2). Hope it helps!

#!/bin/sh
[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l postgres -c 'exec /usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data -S -o -F -N 48 -B 96> /home/postgres/postgres.log' &
echo -n ' postgres'
}

David Veatch - dvicci@reckoning.org

"Many people would sooner die than think.
In fact, they do." - Bertrand Russell

#6Alfred Perlstein
bright@wintelcom.net
In reply to: Adam Lang (#5)
Re: Starting postmaster at boot

* Adam Lang <aalang@rutgersinsurance.com> [000914 13:21] wrote:

I didn't directly use your method, but you nonetheless solved my problem.

From the beginning everyone was telling me to put this into my rc.local:

su postgres -c "/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data -i
/usr/local/pgsql/postgres.log 2>&1 &"

It was never working. I noticed you had a tag "-l" in yours for su. I
looked up the reason for it and gave it a try. So the script:
su -l postgres -c "/usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data -i /home/postgres/postgres.log 2>1 &"
does work.

I still don't understand the point of the 1's and 2's in the command though.

It tells the shell to hook the child's stderr to stdout so that all
output should go to /home/postgres/postgres.log.

Why is everyone else's script working without the -l and mine wasn't?

Check su's manpage.

--
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
"I have the heart of a child; I keep it in a jar on my desk."

#7Dale Walker
dale@icr.com.au
In reply to: David Veatch (#2)
Re: Starting postmaster at boot

Adam Lang wrote:

I didn't directly use your method, but you nonetheless solved my problem.

From the beginning everyone was telling me to put this into my rc.local:

su postgres -c "/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data -i
/usr/local/pgsql/postgres.log 2>&1 &"

It was never working. I noticed you had a tag "-l" in yours for su. I
looked up the reason for it and gave it a try. So the script:
su -l postgres -c "/usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data -i /home/postgres/postgres.log 2>1 &"
does work.

I still don't understand the point of the 1's and 2's in the command though.

it's a method for redirecting STDERR --> STDOUT

this is especially usefull in scripts

normally I use [scriptname >/dev/null 2>&1] to send any unwanted output
to /dev/null

Why is everyone else's script working without the -l and mine wasn't?

'-l' uses the login profile for the su'd user... this is similar to a
'simuated login', without it , it was only referencing variables from
your roo profile ... (ie. no PGDATA,etc..)

--
Dale Walker dale@icr.com.au
Independent Computer Retailers (ICR) http://www.icr.com.au
ICRnet http://www.icr.net.au

#8Adam Lang
aalang@rutgersinsurance.com
In reply to: David Veatch (#2)
Re: Starting postmaster at boot

oh... so since I did a su -l, I could have just used the command,
postmaster -i >>postgres.log 2>>1 & ? Since I had the appropriate variables
in postgres's .bash_profile?

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
----- Original Message -----
From: "Dale Walker" <dale@icr.com.au>
To: "Adam Lang" <aalang@rutgersinsurance.com>
Cc: "PGSQL General" <pgsql-general@postgresql.org>
Sent: Thursday, September 14, 2000 4:33 PM
Subject: Re: [GENERAL] Starting postmaster at boot

Adam Lang wrote:

I didn't directly use your method, but you nonetheless solved my

problem.

From the beginning everyone was telling me to put this into my

rc.local:

su postgres -c "/usr/local/pgsql/bin/postmaster -D

/usr/local/pgsql/data -i

/usr/local/pgsql/postgres.log 2>&1 &"

It was never working. I noticed you had a tag "-l" in yours for su. I
looked up the reason for it and gave it a try. So the script:
su -l postgres -c "/usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data -i /home/postgres/postgres.log 2>1 &"
does work.

I still don't understand the point of the 1's and 2's in the command

though.

Show quoted text

it's a method for redirecting STDERR --> STDOUT

this is especially usefull in scripts

normally I use [scriptname >/dev/null 2>&1] to send any unwanted output
to /dev/null

Why is everyone else's script working without the -l and mine wasn't?

'-l' uses the login profile for the su'd user... this is similar to a
'simuated login', without it , it was only referencing variables from
your roo profile ... (ie. no PGDATA,etc..)

--
Dale Walker dale@icr.com.au
Independent Computer Retailers (ICR) http://www.icr.com.au
ICRnet http://www.icr.net.au

#9Mitch Vincent
mitch@venux.net
In reply to: David Veatch (#2)
Re: Starting postmaster at boot

The reason I didn't have to use the -l is that I have everything PostgreSQL
needs (as far as environment variables) already set, because this machine is
a dedicated PostgreSQL server.

Sorry, should have thought about that before I replied but it seems you have
it running now, that's great.. Good luck!

-Mitch

----- Original Message -----
From: "Dale Walker" <dale@icr.com.au>
To: "Adam Lang" <aalang@rutgersinsurance.com>
Cc: "PGSQL General" <pgsql-general@postgresql.org>
Sent: Thursday, September 14, 2000 1:33 PM
Subject: Re: [GENERAL] Starting postmaster at boot

Adam Lang wrote:

I didn't directly use your method, but you nonetheless solved my

problem.

From the beginning everyone was telling me to put this into my

rc.local:

su postgres -c "/usr/local/pgsql/bin/postmaster -D

/usr/local/pgsql/data -i

/usr/local/pgsql/postgres.log 2>&1 &"

It was never working. I noticed you had a tag "-l" in yours for su. I
looked up the reason for it and gave it a try. So the script:
su -l postgres -c "/usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data -i /home/postgres/postgres.log 2>1 &"
does work.

I still don't understand the point of the 1's and 2's in the command

though.

Show quoted text

it's a method for redirecting STDERR --> STDOUT

this is especially usefull in scripts

normally I use [scriptname >/dev/null 2>&1] to send any unwanted output
to /dev/null

Why is everyone else's script working without the -l and mine wasn't?

'-l' uses the login profile for the su'd user... this is similar to a
'simuated login', without it , it was only referencing variables from
your roo profile ... (ie. no PGDATA,etc..)

--
Dale Walker dale@icr.com.au
Independent Computer Retailers (ICR) http://www.icr.com.au
ICRnet http://www.icr.net.au

#10Adam Lang
aalang@rutgersinsurance.com
In reply to: David Veatch (#2)
Re: Starting postmaster at boot

OH! I get it. Whereas I have the environment variables in postgres's
.bash_profile, you have it set where those variables are loaded for all
users, correct?

But the part that I don't get is that (typing it at console) I can start
postgresql (while logged in as postgres) with the command: postmaster -i
because I have the variables for the location of postmaster and pgdata set.

But, I would assume that typing the absolute paths would have gotten around
that for when I was doing the su. Are there other environment variables I
didn't take insto consideration?

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
----- Original Message -----
From: "Mitch Vincent" <mitch@venux.net>
To: "Adam Lang" <aalang@rutgersinsurance.com>
Cc: "PGSQL General" <pgsql-general@postgresql.org>
Sent: Thursday, September 14, 2000 4:40 PM
Subject: Re: [GENERAL] Starting postmaster at boot

The reason I didn't have to use the -l is that I have everything

PostgreSQL

needs (as far as environment variables) already set, because this machine

is

a dedicated PostgreSQL server.

Sorry, should have thought about that before I replied but it seems you

have

it running now, that's great.. Good luck!

-Mitch

----- Original Message -----
From: "Dale Walker" <dale@icr.com.au>
To: "Adam Lang" <aalang@rutgersinsurance.com>
Cc: "PGSQL General" <pgsql-general@postgresql.org>
Sent: Thursday, September 14, 2000 1:33 PM
Subject: Re: [GENERAL] Starting postmaster at boot

Adam Lang wrote:

I didn't directly use your method, but you nonetheless solved my

problem.

From the beginning everyone was telling me to put this into my

rc.local:

su postgres -c "/usr/local/pgsql/bin/postmaster -D

/usr/local/pgsql/data -i

/usr/local/pgsql/postgres.log 2>&1 &"

It was never working. I noticed you had a tag "-l" in yours for su.

I

Show quoted text

looked up the reason for it and gave it a try. So the script:
su -l postgres -c "/usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data -i /home/postgres/postgres.log 2>1 &"
does work.

I still don't understand the point of the 1's and 2's in the command

though.

it's a method for redirecting STDERR --> STDOUT

this is especially usefull in scripts

normally I use [scriptname >/dev/null 2>&1] to send any unwanted output
to /dev/null

Why is everyone else's script working without the -l and mine wasn't?

'-l' uses the login profile for the su'd user... this is similar to a
'simuated login', without it , it was only referencing variables from
your roo profile ... (ie. no PGDATA,etc..)

--
Dale Walker dale@icr.com.au
Independent Computer Retailers (ICR) http://www.icr.com.au
ICRnet http://www.icr.net.au

#11Eje Gustafsson
MacAhan@fament.com
In reply to: Adam Lang (#10)
Re[2]: Starting postmaster at boot

Is my messages coming through ??

I sent 2 messages earlier but I never saw them.

Is there anyway to retrieve an expired row from a table in a database ?
When you update/delete a row it's sets the old record to expired and you
can not access it. When you run vacuum you delete all these expired
messages if I haven't missunderstood postgres totally..
Any ideas how to display the expired rows ??

Thursday, September 14, 2000, 3:43:43 PM, you wrote:

AL> OH! I get it. Whereas I have the environment variables in postgres's
AL> .bash_profile, you have it set where those variables are loaded for all
AL> users, correct?

AL> But the part that I don't get is that (typing it at console) I can start
AL> postgresql (while logged in as postgres) with the command: postmaster -i
AL> because I have the variables for the location of postmaster and pgdata set.

AL> But, I would assume that typing the absolute paths would have gotten around
AL> that for when I was doing the su. Are there other environment variables I
AL> didn't take insto consideration?

AL> Adam Lang
AL> Systems Engineer
AL> Rutgers Casualty Insurance Company
AL> ----- Original Message -----
AL> From: "Mitch Vincent" <mitch@venux.net>
AL> To: "Adam Lang" <aalang@rutgersinsurance.com>
AL> Cc: "PGSQL General" <pgsql-general@postgresql.org>
AL> Sent: Thursday, September 14, 2000 4:40 PM
AL> Subject: Re: [GENERAL] Starting postmaster at boot

The reason I didn't have to use the -l is that I have everything

AL> PostgreSQL

needs (as far as environment variables) already set, because this machine

AL> is

a dedicated PostgreSQL server.

Sorry, should have thought about that before I replied but it seems you

AL> have

it running now, that's great.. Good luck!

-Mitch

----- Original Message -----
From: "Dale Walker" <dale@icr.com.au>
To: "Adam Lang" <aalang@rutgersinsurance.com>
Cc: "PGSQL General" <pgsql-general@postgresql.org>
Sent: Thursday, September 14, 2000 1:33 PM
Subject: Re: [GENERAL] Starting postmaster at boot

Adam Lang wrote:

I didn't directly use your method, but you nonetheless solved my

problem.

From the beginning everyone was telling me to put this into my

rc.local:

su postgres -c "/usr/local/pgsql/bin/postmaster -D

/usr/local/pgsql/data -i

/usr/local/pgsql/postgres.log 2>&1 &"

It was never working. I noticed you had a tag "-l" in yours for su.

AL> I

looked up the reason for it and gave it a try. So the script:
su -l postgres -c "/usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data -i /home/postgres/postgres.log 2>1 &"
does work.

I still don't understand the point of the 1's and 2's in the command

though.

it's a method for redirecting STDERR --> STDOUT

this is especially usefull in scripts

normally I use [scriptname >/dev/null 2>&1] to send any unwanted output
to /dev/null

Why is everyone else's script working without the -l and mine wasn't?

'-l' uses the login profile for the su'd user... this is similar to a
'simuated login', without it , it was only referencing variables from
your roo profile ... (ie. no PGDATA,etc..)

--
Dale Walker dale@icr.com.au
Independent Computer Retailers (ICR) http://www.icr.com.au
ICRnet http://www.icr.net.au

Best regards,
Eje mailto:MacAhan@fament.com
The Family Entertainment Network http://www.fament.com
Phone : 316-231-7777 Fax : 316-231-4066
- Your Internet Solution Provider & PC Computer Solutions Provider -