Thread: initdb $PGDATA not working
Hi!
I've set my PGDATA variable in profile
export PGDATA=/home/mydata/pgsql/data
Testing variable for correct set in enviroment
$ echo $PGDATA
/home/mydata/pgsql/data
but when execute:
$ sudo /etc/init.d/postgresql-9.1 initdb
or execute:
$ sudo /etc/init.d/postgresql-9.1 initdb -D /home/mydata/pgsql/data
The cluster always is created on default path "/var/lib/pgsql/9.1/data/"
Will install in CentOS 5.7
Thx
On 2/9/2012 3:25 PM, Daniel Vázquez wrote: > Hi! > > I've set my PGDATA variable in profile > export PGDATA=/home/mydata/pgsql/data > > Testing variable for correct set in enviroment > $ echo $PGDATA > /home/mydata/pgsql/data > > but when execute: > $ sudo /etc/init.d/postgresql-9.1 initdb > > or execute: > $ sudo /etc/init.d/postgresql-9.1 initdb -D /home/mydata/pgsql/data > > The cluster always is created on default path "/var/lib/pgsql/9.1/data/" > > Will install in CentOS 5.7 > > Thx > > > I'm guessing /etc/init.d/postgresql-9.1 is a script that is ignoring your arguments: initdb, $PGDATA, and -D /path/. I'd say dont use that script and go right for the origional initdb. -Andy
On Thursday, February 09, 2012 10:25:51 PM Daniel Vázquez wrote: > Hi! > > I've set my PGDATA variable in profile > export PGDATA=/home/mydata/pgsql/data > > Testing variable for correct set in enviroment > $ echo $PGDATA > /home/mydata/pgsql/data > > but when execute: > $ sudo /etc/init.d/postgresql-9.1 initdb > > or execute: > $ sudo /etc/init.d/postgresql-9.1 initdb -D /home/mydata/pgsql/data > > The cluster always is created on default path "/var/lib/pgsql/9.1/data/" > > Will install in CentOS 5.7 The init script doesn't take command line options except the initdb action. And it sets PGDATA itself. Perhaps su postgres -c "initdb -D /home/mydata/pgsql/data" or something similar might work better. Or modifying the init script before using it, which would have the advantage that it might also start the server later using your new data directory.
On 02/09/12 1:25 PM, Daniel Vázquez wrote: > I've set my PGDATA variable in profile > export PGDATA=/home/mydata/pgsql/data > > Testing variable for correct set in enviroment > $ echo $PGDATA > /home/mydata/pgsql/data > > but when execute: > $ sudo /etc/init.d/postgresql-9.1 initdb > > or execute: > $ sudo /etc/init.d/postgresql-9.1 initdb -D /home/mydata/pgsql/data > > The cluster always is created on default path "/var/lib/pgsql/9.1/data/" > > Will install in CentOS 5.7 the /etc/init.d/postgresql* scripts are completely selfcontained and don't use any external environment variables. you can put custom settings in /etc/sysconfig/pgsql/postgresql-9.1 (where the last part of the filename is the same as the /etc/init.d/ script name). the main things you'd set in those scripts are... PGENGINE=/usr/pgsql-${PGMAJORVERSION}/bin PGPORT=5432 PGDATA=/var/lib/pgsql/${PGMAJORVERSION}/data PGLOG=/var/lib/pgsql/${PGMAJORVERSION}/pgstartup.log However, if you're creating a cluster under your own home directory, I'm not sure you even want it to be under the control of the system scripts. -- john r pierce N 37, W 122 santa cruz ca mid-left coast
THX all !!
My fault is I set the $PGDATA enviroment variable in /etc/sysconfig/pgsql/postgresql like usual in 8.4
renaming the file to postgresql-9.1 solve the isue.
Thanks guys!
El 9 de febrero de 2012 22:25, Daniel Vázquez <daniel2d2art@gmail.com> escribió:
Hi!I've set my PGDATA variable in profileexport PGDATA=/home/mydata/pgsql/dataTesting variable for correct set in enviroment$ echo $PGDATA/home/mydata/pgsql/databut when execute:$ sudo /etc/init.d/postgresql-9.1 initdbor execute:$ sudo /etc/init.d/postgresql-9.1 initdb -D /home/mydata/pgsql/dataThe cluster always is created on default path "/var/lib/pgsql/9.1/data/"Will install in CentOS 5.7Thx
On 02/09/12 2:38 PM, Daniel Vázquez wrote: > YES.... /etc/sysconfig/pgsql/postgresql-9.1 > > I'm using /etc/sysconfig/pgsql/postgresql like in 8.4 ... my fault ... > is like some overunderstand ... but no doc about it. whatever the name of the /etc/init.d/postgres** script is, it uses that same name in the /etc/sysconfg/pgsql directory. so if you want to run 2 copies of 9.1, cp /etc/init.d/postgresql-9.1 /etc/init.d/postgresql-9.1B and then create /etc/sysconfig/pgsql/postgresql-9.1B and put your port, and data directory in there, and poof, like magic! -- john r pierce N 37, W 122 santa cruz ca mid-left coast