Обсуждение: autostart postgresql
Partial success! I have postgresql started and have "createdb testdb" successfully. I am having trouble with autostarting postmaster in RH6.2 however. I have copied the file "/usr/local/postgresql-7.0.2.......postgres-init" to /etc/rc.d/init.d and made a softe link to it from .../rc5.d as follows ln /etc/rc.d/init.d/postgres.init /etc/rc.d/rc5.d/S98postgres.init postmaster does not autostart upon a reboot. Do I have to use a start command or other paramater to tell postgres.init to start the postmaster up? I am not good at reading and deciphering these scripts but would like postgres to autostart everytime the PC boots to runlevel 5. Thanks for all the help from various members so far! Bob Hartung
Greetings, Bob!
At 16.10.2000, 11:20, you wrote:
BH> Partial success!
BH> I have postgresql started and have "createdb testdb"
BH> successfully. I am having trouble with autostarting
BH> postmaster in RH6.2 however.
BH> I have copied the file
BH> "/usr/local/postgresql-7.0.2.......postgres-init" to
BH> /etc/rc.d/init.d and made a softe link to it from .../rc5.d
BH> as follows ln /etc/rc.d/init.d/postgres.init
BH> /etc/rc.d/rc5.d/S98postgres.init
BH> postmaster does not autostart upon a reboot. Do I have to
BH> use a start command or other paramater to tell postgres.init
BH> to start the postmaster up? I am not good at reading and
BH> deciphering these scripts but would like postgres to
BH> autostart everytime the PC boots to runlevel 5.
You should either copy the init script to /etc/rc.d/init.d/
and run
/sbin/chkconfig --add postgres
or run the script with 'install' option (which basically does the
same thing). Messing directly with /etc/rc.d/rc*.d/ is not a very good
idea.
--
Yours, Alexey V. Borzov
* Bob Hartung (rwhart@netexpress.net) wrote: > Partial success! > I have postgresql started and have "createdb testdb" > successfully. I am having trouble with autostarting > postmaster in RH6.2 however. > > I have copied the file > "/usr/local/postgresql-7.0.2.......postgres-init" to > /etc/rc.d/init.d and made a softe link to it from .../rc5.d > as follows ln /etc/rc.d/init.d/postgres.init > /etc/rc.d/rc5.d/S98postgres.init > > postmaster does not autostart upon a reboot. Do I have to > use a start command or other paramater to tell postgres.init > to start the postmaster up? I am not good at reading and > deciphering these scripts but would like postgres to > autostart everytime the PC boots to runlevel 5. You can't run postmaster as root, so to do this I believe you have to write a wrapper script and give it a postgres (or whatever your admin account is named) sticky bit. Is this the 'one true way' for doing this? Mike -- Mike Erickson <mee (at) quidquam.com> http://www.quidquam.com/ Be happy. It is a way of being wise.
On Thu, Nov 02, 2000 at 05:00:51AM -0800, Mike E wrote: > You can't run postmaster as root, so to do this I believe you > have to write a wrapper script and give it a postgres (or whatever > your admin account is named) sticky bit. I usually make the script 'su' into postgres and then startup postmaster. I don't know if this is any better. Regards, Neil -- Neil Conway <neilconway@home.com> Get my GnuPG key from: http://klamath.dyndns.org/mykey.asc Encrypted mail welcomed They that give up liberty to obtain a little temporary security deserve neither liberty nor security. -- Benjamin Franklin
Вложения
Hello Mike,
Thursday, November 02, 2000, 1:00:51 PM, you wrote:
ME> * Bob Hartung (rwhart@netexpress.net) wrote:
>> Partial success!
>> I have postgresql started and have "createdb testdb"
>> successfully. I am having trouble with autostarting
>> postmaster in RH6.2 however.
>>
>> I have copied the file
>> "/usr/local/postgresql-7.0.2.......postgres-init" to
>> /etc/rc.d/init.d and made a softe link to it from .../rc5.d
>> as follows ln /etc/rc.d/init.d/postgres.init
>> /etc/rc.d/rc5.d/S98postgres.init
>>
>> postmaster does not autostart upon a reboot. Do I have to
>> use a start command or other paramater to tell postgres.init
>> to start the postmaster up? I am not good at reading and
>> deciphering these scripts but would like postgres to
>> autostart everytime the PC boots to runlevel 5.
ME> You can't run postmaster as root, so to do this I believe you
ME> have to write a wrapper script and give it a postgres (or whatever
ME> your admin account is named) sticky bit.
ME> Is this the 'one true way' for doing this?
ME> Mike
See following (and attached) dump of my init script,
/etc/rc.d/init.d/postgresql which should be linked to the runlevel
directories as suitable for your system.
This works automatically on my hosts
*************************************************************************
#! /bin/sh
# postgresql This is the init script for starting up the PostgreSQL
# server
# Version 6.5.3-2 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/postmaster.pid
#
# 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
start)
echo -n "Checking postgresql installation: "
# Check for the PGDATA structure
if [ -f /var/lib/pgsql/PG_VERSION ] && [ -d /var/lib/pgsql/base/template1 ]
then
# Check version of existing PGDATA
if [ `cat /var/lib/pgsql/PG_VERSION` != '6.5' ]
then
echo "old version. Need to Upgrade."
echo "See /usr/doc/postgresql-6.5.3/README.rpm for more information."
exit 1
else
echo "looks good!"
fi
# No existing PGDATA! Initdb it.
else
echo "no database files found."
if [ ! -d /var/lib/pgsql ]
then
mkdir -p /var/lib/pgsql
chown postgres.postgres /var/lib/pgsql
fi
su -l postgres -c '/usr/bin/initdb --pglib=/usr/lib/pgsql --pgdata=/var/lib/pgsql'
fi
# Check for postmaster already running...
pid=`pidof postmaster`
if [ $pid ]
then
echo "Postmaster already running."
else
#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 -S -D/var/lib/pgsql'
sleep 1
pid=`pidof postmaster`
if [ $pid ]
then
echo -n "postmaster [$pid]"
touch /var/lock/subsys/postgresql
echo $pid > /var/run/postmaster.pid
echo
else
echo "failed."
fi
fi
;;
stop)
echo -n "Stopping postgresql service: "
killproc postmaster
sleep 2
rm -f /var/run/postmaster.pid
rm -f /var/lock/subsys/postgresql
echo
;;
status)
status postmaster
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: postgresql {start|stop|status|restart}"
exit 1
esac
exit 0
*************************************************************
--
Best regards,
Andy mailto:lbc@telecam.demon.co.uk