Search Postgresql Archives

Re: question about /etc/init.d/postgresql in PGDG

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 19 Aug 2009, Scott Marlowe wrote:

The only reason I noticed it was that I was building a server with a
separate /data partition for the db to live in, and went to edit
/etc/init.d/postgresql and was faced with two PGDATA assignments...  I
too deleted the entire if else block when faced with it.

You should never edit that script, because then you'll be stuck resolving conflicts if you upgrade and the packager makes a change to it to fix a bug or something like that. If you want to relocate PGDATA, you should change /etc/sysconfig/pgsql/postgresql instead and put your local customizations there. That file is overlaid on top of the defaults just after they're set:

  # Override defaults from /etc/sysconfig/pgsql if file is present
  [ -f /etc/sysconfig/pgsql/${NAME} ] && . /etc/sysconfig/pgsql/${NAME}

What I do is put *all* the defaults into that file, so that there's no confusion about which version I'm using.

$ cat /etc/sysconfig/pgsql/postgresql
PGENGINE=/usr/bin
PGPORT=5432
PGDATA=/var/lib/pgsql/data
PGLOG=/var/lib/pgsql/pgstartup.log

The nice side-effect of this is that it makes it easy to set all these values in a user's login profile, so that you can do things like run pg_ctl manually instead of using the init scripts as root. Put something like this in your profile:

. /etc/sysconfig/pgsql/postgresql
export PGDATA PGPORT PGLOG
export PATH="$PGENGINE:$PATH"

And then cycling the engine as the postgres user is as easy as:

pg_ctl start -l $PGLOG
pg_ctl stop

For my login, I add these two bits as well to make that easier, since I never use the real start/stop commands anyway:

alias start="pg_ctl -D $PGDATA -l $PGLOG -w start && tail $PGLOG"
alias stop="pg_ctl -D $PGDATA stop -m fast"

--
* Greg Smith gsmith@xxxxxxxxxxxxx http://www.gregsmith.com Baltimore, MD

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux