#!/bin/bash
# /etc/init.d/oracle
### BEGIN INIT INFO
# Provides:
# Required-Start: $network $syslog
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 4 6
# Description: Startup/shutdown script for oracle listener and instance;
### END
. /etc/rc.status
rc_reset
start()
{
#when system stop redhat check /var/lock/subsys/oracle
#to make sure oracle is running.
touch /var/lock/subsys/oracle
# start tsnlisnter
echo -n "Start tsnlisnter:"
su - oracle -c "lsnrctl start" >/dev/null 2>/dev/null
rc_status -v
# start database
echo -n "Start Oracle database instance:"
su - oracle -c "echo \"
CONN / AS SYSDBA
STARTUP
exit \"|sqlplus /NOLOG" >/dev/null 2>/dev/null
rc_status -v
# start enterprise manager
echo -n "Start Enterprise Manager:"
su - oracle -c "emctl start dbconsole" >/dev/null 2>/dev/null
rc_status -v
#start isqlplus
echo -n "Start isqlplus"
su - oracle -c "isqlplusctl start">/dev/null 2>/dev/null
rc_status -v
}
stop()
{
#when system stop redhat check /var/lock/subsys/oracle
#to make sure oracle is running.
rm -rf /var/lock/subsys/oracle
# shutdown database
echo -n "Shutdown Oracle database instance:"
su - oracle -c "echo \"
CONN / AS SYSDBA
SHUTDOWN immediate
exit \"|sqlplus /NOLOG">/dev/null 2>/dev/null
rc_status -v
# stop tsnlisnter
echo -n "Stop tsnlisnter:"
su - oracle -c "lsnrctl stop">/dev/null 2>/dev/null
rc_status -v
# stop enterprise manager
echo -n "Stop Enterprise Manager:"
su - oracle -c "emctl stop dbconsole"
rc_status -v
# stop isqlplus
echo -n "Stop isqlplus:"
su - oracle -c "isqlplusctl stop"
rc_status -v
}
case "$1" in
start)
start
echo "Oracle Start at:" `date` >>/var/log/oracle.log
;;
stop)
stop
echo "Oracle Stop at:" `date` >>/var/log/oracle.log
;;
restart)
echo "Oracle Restart at:" `date` >>/var/log/oracle.log
stop
start
;;
*)
echo "Usage: $0 { start | stop| restart }"
exit 1
;;
esac
rc_exit
阅读(1913) | 评论(1) | 转发(0) |