file : /etc/inet.d/dbora
#!/bin/bash
#
# Run level script to start Oracle 11g services on RedHat Enterprise Linux (RHEL 6)
# Script should work on other UNIX like oses :)
# chkconfig: 345 91 19
# description: Startup/Shutdown Oracle service
OUSER="oracle"
ORACLE_HOME="/opt/oracle/product/11.2.0.4.0"
case "$1" in
start)
echo "*** Starting Oracle *** "
su - $OUSER -c "$ORACLE_HOME/bin/lsnrctl start"
su - $OUSER -c "$ORACLE_HOME/bin/sqlplus /nolog<connect / as
sysdba;
startup
exit
EOS"
;;
stop)
echo "*** Stopping Oracle *** "
su - $OUSER -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $OUSER -c "$ORACLE_HOME/bin/sqlplus /nolog<connect / as sysdba;
shutdown immediate
exit
EOS"
;;
restart)
$0 stop
$1 start
;;
status)
echo -e "\033[32m *** Oracle Listener status *** \033[0m"
su - $OUSER -c "$ORACLE_HOME/bin/lsnrctl status"
echo ""
echo -e "\033[32m *** Oracle Instance status *** \033[0m"
smon=`ps -ef | grep -i smon | grep -v 'grep' | wc -l | awk '{print $1}'`
if [ ${smon} -eq 0 ]; then
echo -e "\033[31m [Warning] oracle instance does not exist! check oracle instance result as below! \033[0m"
ps -ef | grep -i smon | grep -v 'grep'
else
ps -ef | grep -i smon | grep -v 'grep'
echo -e "\033[32m [OK] oracle instance exist! \033[0m"
fi
echo ""
echo -e "\033[32m *** Oracle Database port status *** \033[0m"
netstat -tunlp | grep --color -e 'ora_' -e 'tnslsnr'
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0
#
# Run level script to start Oracle 11g services on RedHat Enterprise Linux (RHEL 6)
# Script should work on other UNIX like oses :)
# chkconfig: 345 91 19
# description: Startup/Shutdown Oracle service
OUSER="oracle"
ORACLE_HOME="/opt/oracle/product/11.2.0.4.0"
case "$1" in
start)
echo "*** Starting Oracle *** "
su - $OUSER -c "$ORACLE_HOME/bin/lsnrctl start"
su - $OUSER -c "$ORACLE_HOME/bin/sqlplus /nolog<
startup
exit
EOS"
;;
stop)
echo "*** Stopping Oracle *** "
su - $OUSER -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $OUSER -c "$ORACLE_HOME/bin/sqlplus /nolog<
shutdown immediate
exit
EOS"
;;
restart)
$0 stop
$1 start
;;
status)
echo -e "\033[32m *** Oracle Listener status *** \033[0m"
su - $OUSER -c "$ORACLE_HOME/bin/lsnrctl status"
echo ""
echo -e "\033[32m *** Oracle Instance status *** \033[0m"
smon=`ps -ef | grep -i smon | grep -v 'grep' | wc -l | awk '{print $1}'`
if [ ${smon} -eq 0 ]; then
echo -e "\033[31m [Warning] oracle instance does not exist! check oracle instance result as below! \033[0m"
ps -ef | grep -i smon | grep -v 'grep'
else
ps -ef | grep -i smon | grep -v 'grep'
echo -e "\033[32m [OK] oracle instance exist! \033[0m"
fi
echo ""
echo -e "\033[32m *** Oracle Database port status *** \033[0m"
netstat -tunlp | grep --color -e 'ora_' -e 'tnslsnr'
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0
Use
the
chmod
command to set the privileges to 750.chmod 750 /etc/init.d/dbora
Associate
the "dbora" service with the appropriate run levels and set it to auto-start
using the following command.
chkconfig --add dbora
沒有留言:
張貼留言