Red Hat Bugzilla – Bug 56843
Last modified: 2007-04-18 12:38:28 EDT
Description of Problem:
using runlevel editor to put postgres in runlevels 3,4,5 to start
postmaster at boot time fails; postmaster is not running.
Version-Release number of selected component (if applicable):
Steps to Reproduce (glory details, maybe I do something wrong early):
1. change postgres user shell to tcsh using Control Panel->User
2. logout/login as postgres
3. initdb <return>
4. /usr/bin/postmaster -D /var/lib/pgsql <return>
5. createdb trend24new <return>
6. cp /root/OCC_Support_CD/trend24new /var/lib/pgsql <return>
7. cd /var/lib/pgsql <return>
8. chown postgres.postgres trend24new <return>
9. psql -e trend24new < trend24new <return>
(trend24new is a flat command file, created with
pg_dump trend24new > trend24new.out <return>
mv trend24new.out trend24new <return>)
10. /usr/bin/pg_ctl -D /var/lib/pgsql stop <return>
11. /usr/bin/pg_ctl -D /var/lib/pgsql start <return>
and can query the database
12. Now in the run level editor, add postgresql to the start
column 3,4,5 by copying and pasting it from the far left column
to start columns 3, 4, and 5. Make it S97postgresql.
13. logout and reboot, login as postgres. Actual Results:
"psql trend24new" should connect -- it doesn't
ps -ef | grep postmaster should show it running -- it doesn't
"psql trend24new" responds with error, unable to connect
"ps -ef | grep postmaster" shows postmaster isn't running
I fixed by changing the /etc/rc.d/init.d/postgresl line 128 from:
su -l postgres -c "/usr/bin/pg_ctl -D $PGDATA -p /usr/bin/postmaster \
start >/dev/null 2>&1" < /dev/null
su -l postgres -c "/usr/bin/pg_ctl -D $PGDATA -p /usr/bin/postmaster start"
\ < /dev/null > /dev/null 2>& 1
which matches the bash shell redirect used about twenty lines above.
Then reboot and login as postgres, and commanding "psql trend24new"
connects, the daemon postmaster is running, and the query:
select distinct msid from tbl_trend_data where msid like '2CHTRPZT';
1) You shouldn't change the shell to tcsh for system users.
2) You shouldn't do initdb manually, it initializes the
If you do, it should work. You probably created some permission problems by
running initdb manually.
The first comment about changing the shell works; I changed postgres shell back
to bash, restored the state of /etc/rc.d/init.d/postgresl to factory, logged out
and rebooted. Then logged in as postgres; and postmaster was running and I
could connect and query okay.
I wasn't aware of the rule "that you shouldn't changed system user's shells".
Thought the the first line in /etc/rc.d/init.d/postgresl "#! /bin/bash" dictated
this. Of course redirection does feel the basic shell I suppose.
Seems to me that my change makes things more robust, though, allowing the user
to change postgres's shell.
Comment about doing initdb and permissions seems irrelevant. Man pages on
initdb indicate it is an allowable user command, "to create a new database
installation". Perhaps I can do without it though, and start at my step 4.