CREATE DATABASE WITH LOCATION

Started by Glen Parkerover 24 years ago6 messagesgeneral
Jump to latest
#1Glen Parker
glenebob@nwlink.com

hi all,

having a little problem with the alternate DB location stuff, on redhat
7.2/postgres 7.1.3. 'CREATE DATABASE WITH LOCATION 'PGDATA2' claims that
PGDATA2 environment not set, although i've defined it in .bash_profile (for
user posgres) and verified that it takes when i 'su -l postgres'. yes, i
restarted the postmaster.

is this the correct way to propagate an environment variable to the
postmaster, and if not, what is the correct way? or, any ideas why this
would be happening?

TIA
glen

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Glen Parker (#1)
Re: CREATE DATABASE WITH LOCATION

"Glen Parker" <glenebob@nwlink.com> writes:

having a little problem with the alternate DB location stuff, on redhat
7.2/postgres 7.1.3. 'CREATE DATABASE WITH LOCATION 'PGDATA2' claims that
PGDATA2 environment not set, although i've defined it in .bash_profile (for
user posgres) and verified that it takes when i 'su -l postgres'. yes, i
restarted the postmaster.

Exactly how did you restart the postmaster?

Also, did you remember to "export PGDATA2" from the profile file, not
merely set its value?

regards, tom lane

#3Glen Parker
glenebob@nwlink.com
In reply to: Tom Lane (#2)
Re: CREATE DATABASE WITH LOCATION

having a little problem with the alternate DB location stuff, on redhat
7.2/postgres 7.1.3. 'CREATE DATABASE WITH LOCATION 'PGDATA2'

claims that

PGDATA2 environment not set, although i've defined it in

.bash_profile (for

user posgres) and verified that it takes when i 'su -l

postgres'. yes, i

restarted the postmaster.

Exactly how did you restart the postmaster?

service postgresql restart

and when that didnt work

service postgresql stop
service postgresql start

and then a reboot which also didnt work

Also, did you remember to "export PGDATA2" from the profile file, not
merely set its value?

yep, sure did. actually, if i specify 'PGDATA' as the location, i get the
same error. that var is exported already in the stock .bash_profile.

glen

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Glen Parker (#3)
Re: CREATE DATABASE WITH LOCATION

"Glen Parker" <glenebob@nwlink.com> writes:

Exactly how did you restart the postmaster?

service postgresql restart

And what does that do? My bet is that when you dig into it, you'll
find it's not supplying the environment you expect to the postmaster.

regards, tom lane

#5Glen Parker
glenebob@nwlink.com
In reply to: Tom Lane (#4)
Re: CREATE DATABASE WITH LOCATION

*chuckle* hey i thought you were supposed to know this stuff :-)
it does this ('service' just calls the init script... its a redhat thing i
guess):

su -l -s /bin/sh postgres -c "LC_ALL=C /usr/bin/pg_ctl -D $PGDATA -p
/usr/bin/postmaster start >/dev/null 2>&1" < /dev/null

now, if i do this:

su -l -s /bin/sh postgres -c "/usr/bin/postmaster -D $PGDATA"

(or something close) it works... the postmaster starts without detaching
from the terminal and then the alternate location stuff works fine.

i'm looking at pg_ctl and so far i don't see any reason why the environment
would be getting munged in there.

glen

Show quoted text

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Tuesday, November 13, 2001 03:38 PM
To: Glen Parker
Cc: Pg-General
Subject: Re: [GENERAL] CREATE DATABASE WITH LOCATION

"Glen Parker" <glenebob@nwlink.com> writes:

Exactly how did you restart the postmaster?

service postgresql restart

And what does that do? My bet is that when you dig into it, you'll
find it's not supplying the environment you expect to the postmaster.

regards, tom lane

#6Glen Parker
glenebob@nwlink.com
In reply to: Tom Lane (#4)
Re: CREATE DATABASE WITH LOCATION

service postgresql restart

And what does that do? My bet is that when you dig into it, you'll
find it's not supplying the environment you expect to the postmaster.

ok, problem solved.
the postgres init script does:

su -l -s /bin/sh postgres blah blah

executing bash as sh causes it to not read .bash_profile. it reads .profile
instead, which after a stock postgres install doesnt exist, and so the
environment never gets setup.

i did this:

ln -s .bash_profile .profile

and it did the trick. maybe in future installs that should be done
automatically, or the init script modified to not specify a shell?

glen