Discussion:
Alternate db location
(too old to reply)
Bender, Cheryl
2004-09-07 23:09:59 UTC
Permalink
I apologize if this answer is in the archives but my search did not
reveal it.

I need to add an alternate db location for my 7.3.4 server (running on
FreeBSD 5.2 Release)

I thought I did everything according to the administrator's guide, but I
fail at createdb.
I completed the following:
-------
Shut down the server
Created the directory (/data/pgdata) and made pgsql the owner
I ran initlocation which created the base subdirectory. Everything
seemed fine.
Set the environment variable PGDATA2 to /data/pgdata
Restarted the server
Createdb (createdb -D PGDATA2 -U pgsql test) fails ("Postmaster
environment variable PGDATA2 not set" )
----------

Where I seem to be stumbling is getting Postmaster to recognize the
environment variable. Even if I do from the command line like this:
setenv PGDATA2 /data/pgdata
I still get "Postmaster environment variable PGDATA2 not set" when I try
to run createdb
I have tried every conceivable combination of user/setting
variable/running createdb (with quotes) but I just cannot seem to find
the right combo.
I have tried setting the variable in the startup script (that is
installed with the FreeBSD package) and restarting the server.
I have tried su'ing to pgsql and setting the variable as the pgsql user.


What does the postmaster desire that I have not fulfilled?????????

Cheryl Bender


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Tom Lane
2004-09-07 23:21:50 UTC
Permalink
Post by Bender, Cheryl
I need to add an alternate db location for my 7.3.4 server (running on
FreeBSD 5.2 Release)
I thought I did everything according to the administrator's guide, but I
fail at createdb.
How are you starting the postmaster, exactly?

A lot of people use start scripts that boil down to something like

su - postgres -c "postmaster ..."

The "su -" means "throw away the existing environment variables and
adopt the environment that would be obtained by logging in from scratch
as postgres". So it doesn't matter *what* you do before executing such
a script; the environment variables you have won't affect what the
postmaster gets.

What you have to do to play with such a script is put the export or
setenv command into whatever "~postgres/.profile" file will be read by
the standard shell that su will invoke. This is what you want anyway,
really, since anything you do any other way will be lost in a reboot.

This'll all get a lot easier in 8.0, thankfully (no more dependence
on environment variables).

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ***@postgresql.org)
Kostis Mentzelos
2004-09-08 07:37:50 UTC
Permalink
I believe that su user -c command throws away the environment
su - user -c command executes the user .profile
Post by Tom Lane
Post by Bender, Cheryl
I need to add an alternate db location for my 7.3.4 server (running on
FreeBSD 5.2 Release)
I thought I did everything according to the administrator's guide, but I
fail at createdb.
How are you starting the postmaster, exactly?
A lot of people use start scripts that boil down to something like
su - postgres -c "postmaster ..."
The "su -" means "throw away the existing environment variables and
adopt the environment that would be obtained by logging in from scratch
as postgres". So it doesn't matter *what* you do before executing such
a script; the environment variables you have won't affect what the
postmaster gets.
What you have to do to play with such a script is put the export or
setenv command into whatever "~postgres/.profile" file will be read by
the standard shell that su will invoke. This is what you want anyway,
really, since anything you do any other way will be lost in a reboot.
This'll all get a lot easier in 8.0, thankfully (no more dependence
on environment variables).
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
Geoffrey
2004-09-11 12:43:01 UTC
Permalink
Post by Kostis Mentzelos
I believe that su user -c command throws away the environment
Changes some of the environment. For example $HOME will point to the
new user home. The command will be executed with the new user's shell
as defined in /etc/passwd. Retains most of the exported variables from
the previous user id.
Post by Kostis Mentzelos
su - user -c command executes the user .profile
Set's the environment according to the new 'user' id's environment,
depending on the shell used, it's not necessarily going to be .profile.
Exported variables from the previous id are lost.
--
Until later, Geoffrey Registered Linux User #108567
AT&T Certified UNIX System Programmer - 1995

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org
Loading...