Skip site navigation (1) Skip section navigation (2)

Re: Failing to boot Postgres on Red Hat Linux

From: Thomas Good <tomg(at)q8(dot)nrnet(dot)org>
To: Matthew Green <Matthewgreen(at)intelfax(dot)co(dot)uk>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Failing to boot Postgres on Red Hat Linux
Date: 2000-08-31 16:25:37
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
On Thu, 31 Aug 2000, Matthew Green wrote:

> Hello,
> Postmaster is not initializing when our Red Hat server is rebooting.
> We have followed what is stated in the manual with a slight modification to allow TCPIP connections.
> i.e.
> in the file /etc/inittab
> -----------------------------<SNIP>---------------------------------------------
> #   Run Postgres in standard runlevels
> pg:2345:respawn:/bin/su - postgres -c "/usr/local/pgsql/bin/postmaster -i -D /usr/local/pgsql/data >> /usr/local/pgsql/logs/server.log 2>&1 </dev/null"
> -----------------------------<EOF>---------------------------------------------
> This seems to execute since if we introduce a deliberate error we get a warning on reboot.
> But with the line exactly as above we get no warnings, no server.log file is generated and the postmaster task is not visible if we run "ps -A" as root.

> Any help would be gratefully received including alternative methods of forcing Postgres to initialize on reboot.
> Many Thanks,
> Matthew Green

Matthew, I use this line as printed on a slackware box except the port 
(5432) and the redirect at the end - on mine it is to (>) /dev/null and 
here you have it reversed.  Is this simply a typo in your email?

For RedHat:

What follows is Lamar Owen's script (RedHat) for firing up PG.
I simply place a call to it in rc.local so it starts on boot.
(I keep my hacked copy of Lamar's file in /usr/local/bin, the original
muzzled any logging output.) Note the rm -f of any stale locks.
Here is the line that turns on logging...
su -l postgres -c '/usr/bin/postmaster -i -D/var/lib/pgsql >> /var/lib/pgsql/postlog 2>&1 &' >/dev/null


Here is the script:

#! /bin/sh
# postgresql	This is the init script for starting up the PostgreSQL
#		server

# Version 6.5.2-0.2lo Lamar Owen
# Added code to determine if PGDATA exists, whether it is current version
#     or not, and initdb if no PGDATA (initdb will not overwrite a database).

# chkconfig: 345 85 15
# description: Starts and stops the PostgreSQL backend daemon that handles \
#	       all database requests.
# processname: postmaster
# pidfile: /var/run/

# Source function library.
. /etc/rc.d/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
# Pretty much need it for postmaster.
[ ${NETWORKING} = "no" ] && exit 0

[ -f /usr/bin/postmaster ] || exit 0

# This script is slightly unusual in that the name of the daemon (postmaster)
# is not the same as the name of the subsystem (postgresql)

# See how we were called.
case "$1" in
	echo -n "Checking postgresql installation: "
	# Check for the PGDATA structure
	if [ -f /var/lib/pgsql/PG_VERSION ] && [ -d /var/lib/pgsql/base/template1 ]
	# Check version of existing PGDATA

		if [ `cat /var/lib/pgsql/PG_VERSION` != '6.5' ]
			echo "old version. Need to Upgrade."
			echo "See /usr/doc/postgresql-6.5.2/README.rpm for more information."
			exit 1
			echo "looks good!"

	# No existing PGDATA! Initdb it.

		echo "no database files found."
                if [ ! -d /var/lib/pgsql ]
			mkdir -p /var/lib/pgsql
			chown postgres.postgres /var/lib/pgsql
		su -l postgres -c '/usr/bin/initdb --pglib=/usr/lib/pgsql --pgdata=/var/lib/pgsql'

	# Check for postmaster already running...
	pid=`pidof postmaster`
	if [ $pid ]
		echo "Postmaster already running."
		#all systems go -- remove any stale lock files
		rm -f /tmp/.s.PGSQL.* > /dev/null
		echo -n "Starting postgresql service: "
		su -l postgres -c '/usr/bin/postmaster -i -D/var/lib/pgsql >> /var/lib/pgsql/postlog 2>&1 &' >/dev/null
		sleep 1
		pid=`pidof postmaster`
		if [ $pid ]
			echo -n "postmaster [$pid]"
			touch /var/lock/subsys/postgresql
			echo $pid > /var/run/
			echo "failed."
	echo -n "Stopping postgresql service: "
	killproc postmaster
	sleep 2
	rm -f /var/run/
	rm -f /var/lock/subsys/postgresql
	status postmaster
	$0 stop
	$0 start
	echo "Usage: postgresql {start|stop|status|restart}"
	exit 1

exit 0

               SVCMC - Center for Behavioral Health                  
Thomas Good                          tomg@ { admin | q8 }
IS Coordinator / DBA                 Phone: 718-354-5528 
                                     Fax:   718-354-5056  
Powered by:  PostgreSQL     s l a c k w a r e          FreeBSD:
               RDBMS       |---------- linux      The Power To Serve

In response to

pgsql-novice by date

Next:From: Sokel, JohnDate: 2000-08-31 18:31:11
Subject: Vacuum DB
Previous:From: Charles CurleyDate: 2000-08-31 16:14:02
Subject: Re: Seek for cygwin1.dll to run postgreSQL on WinNT workstation

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group