Обсуждение: CREATE DATABASE WITH LOCATION

Поиск
Список
Период
Сортировка

CREATE DATABASE WITH LOCATION

От
"Glen Parker"
Дата:
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


Re: CREATE DATABASE WITH LOCATION

От
Tom Lane
Дата:
"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

Re: CREATE DATABASE WITH LOCATION

От
"Glen Parker"
Дата:
> > 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




Re: CREATE DATABASE WITH LOCATION

От
"Glen Parker"
Дата:
*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

> -----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
>


Re: CREATE DATABASE WITH LOCATION

От
Tom Lane
Дата:
"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

Re: CREATE DATABASE WITH LOCATION

От
"Glen Parker"
Дата:
> > 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