Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I observed a significant change in /etc/init.d/postgresql is changed in new version (postgresql-8.4.7) I was using postgresql-8.1.23 and /etc/init.d/postgresql start would do initdb if cluster doesn't exits which is not the case now. I have to do initdb exclusively.

  1. Do you know why this is changed like this?
  2. Do you know from which version it is like this? (I checked in the release notes, but couldn't find it)

Probem I am facing is I have a kickstart install of CentOS which includes my packges depedning on postgres. So, I do /sbin/chkconfig postgresql on in the %post. Now, since initdb is not done by default, I am not able to start my service at startup.

share|improve this question

migrated from stackoverflow.com Aug 10 '11 at 9:40

This question came from our site for professional and enthusiast programmers.

2  
This is not a PostgreSQL issue, PostgreSQL doesn't create/maintain the script in init.d for CentOS. –  Frank Heikens Aug 10 '11 at 9:28

1 Answer 1

up vote 0 down vote accepted

This change was made because it was surprising, unwanted behavior for people who ultimately intended to put the database into another location besides the default one--an extremely common change. The fact that older versions bundled the initdb step into startup was a problem for them. The newer versions avoid this by making it an explicit step. It's still easy, it's just not automatic in a way that can do things wrong for people customizing the destination. I'm not sure exactly which version it was where the packagers made this change, but it was either 8.2 or 8.3. Been there long enough that it's unlikely to revert to the original behavior now.

If you want to automate this in a kickstart fashion, you need a script that sets things up in the case where they're not right yet. Here's the sort of code you need to run on boot:

PGDATA=/var/lib/pgsql/data
. /etc/sysconfig/pgsql/postgresql
if [ ! -f "$PGDATA/PG_VERSION" ] ; then
  /sbin/service postgresql initdb
  /sbin/service postgresql start
fi

You could put that into its own init script, or you might just customize /etc/rc.d/rc.local and include it there. Written like that, it will be a quick harmless check each time. Might be possible to eliminate it completely after running once by using something like the firstboot init script.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.