Обсуждение: RE: initlocation and createdb

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

RE: initlocation and createdb

От
"Barnes"
Дата:
Thank you.  This works, and is close to what I need, but if I don't launch
the postmaster from a window with PGDATA2 defined, such as is done with
"/etc/init.d/postgresql start" or on a system boot, then it doesn't work.  I
tried to export PGDATA2 within /etc/init.d/postgresql, but that didn't work
for me.

Can I make this work from within /etc/init.d/postgresql, or do have to start
the postmaster from a shell with the PGDATA2 already defined?

Thanks again.


-----Original Message-----
From: Jeff Hoffmann [mailto:jeff@propertykey.com]
Sent: Tuesday, June 13, 2000 5:29 PM
To: Barnes
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] initlocation and createdb


Barnes wrote:
>
> I'm having trouble setting up databases in a new location.  In particular,
I
> do the following:
>
> [postgres@whopper pgdata]$ export PGDATA2=/home/pgdata
> [postgres@whopper pgdata]$ initlocation PGDATA2
> The location will be initialized with username "postgres".
> This user will own all the files and must also own the server process.
>
> Fixing permissions on pre-existing directory /home/pgdata
> Creating directory /home/pgdata/base
>
> initlocation is complete.
> You can now create a database using
>   CREATE DATABASE <name> WITH LOCATION = 'PGDATA2'
> in SQL, or
>   createdb <name> -D 'PGDATA2'
> from the shell.
>
> [postgres@whopper pgdata]$ createdb optodb -D 'PGDATA2'
> ERROR:  The database path 'PGDATA2' is invalid. This may be due to a
> character that is not allowed or because the chosen path isn't permitted
for
> databases
> createdb: database creation failed

restart the postmaster & it should work fine.  the environment variable
has to be defined before the postmaster is started in order for the
alternet locations to work.  this has been covered a number of times
recently.  wasn't it also added to the FAQ or some other documentation
not too long ago?

--

Jeff Hoffmann
PropertyKey.com


Re: initlocation and createdb

От
Jeff Hoffmann
Дата:
Barnes wrote:
>
> Thank you.  This works, and is close to what I need, but if I don't launch
> the postmaster from a window with PGDATA2 defined, such as is done with
> "/etc/init.d/postgresql start" or on a system boot, then it doesn't work.  I
> tried to export PGDATA2 within /etc/init.d/postgresql, but that didn't work
> for me.
>
> Can I make this work from within /etc/init.d/postgresql, or do have to start
> the postmaster from a shell with the PGDATA2 already defined?
>
> Thanks again.

i'm not 100% sure that this works in all environments, but if your
startup script does a "su -l <username> -c ...", that's likely your
problem.  on the systems that i'm familiar with, the -l flag on su will
reset the environment & read the shell startup files (e.g., .profile).
so if you set the variable earlier in the script, it will be cleared out
before the program is actually run.   the .profile should be read when
the su is invoked & then variable should be available to you then.

hope this helps,

jeff