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

From: Greg Smith <gsmith(at)gregsmith(dot)com>
To: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org, Devrim GÜNDÜZ <devrim(at)gunduz(dot)org>
Subject: Re: question about /etc/init.d/postgresql in PGDG
Date: 2009-08-19 16:59:23
Message-ID: alpine.GSO.2.01.0908191247090.2700@westnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)gregsmith(dot)com http://www.gregsmith.com Baltimore, MD

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2009-08-19 17:06:40 Re: Wich the best way to control the logic of a web application?
Previous Message Andrus Moor 2009-08-19 16:57:29 Re: index "pg_authid_rolname_index" is not a btree