Bug 56843 - postgres /etc/rc.d/rc3.d/S97postgresql
postgres /etc/rc.d/rc3.d/S97postgresql
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: postgresql (Show other bugs)
7.1
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Trond Eivind Glomsrxd
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-11-28 13:09 EST by Need Real Name
Modified: 2007-04-18 12:38 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-11-28 13:09:43 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2001-11-28 13:09:37 EST
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):
postgresl-server-7.0.3-8 
How Reproducible:
every time

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:


Expected Results:

"psql trend24new" should connect -- it doesn't

ps -ef | grep postmaster should show it running  -- it doesn't

Actual results:
"psql trend24new" responds with error, unable to connect
"ps -ef | grep postmaster" shows postmaster isn't running

Additional Information:
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

to:

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';

responds with:

 msid
----------
2CHTRPZT
(1 row)
Comment 1 Trond Eivind Glomsrxd 2001-11-28 17:38:02 EST
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.
Comment 2 Need Real Name 2001-11-28 18:07:10 EST
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.

Note You need to log in before you can comment on or make changes to this bug.