RHCS+Oracle11g监控脚本
#!/bin/bash
#
# standalone oracle databases
#
# description: oradb10g is a database daemon, which is the program
# that answer incoming database service requests.
# this script start listener and database daemon
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
unset ORACLE_HOME
unset ORACLE_OWNER
ORACLE_HOME=/u01/oracle/product/11.1.0/db_1
ORACLE_OWNER=oracle
export ORACLE_OWNER ORACLE_HOME
LISTENER=$ORACLE_HOME/bin/lsnrctl
DBSTART=$ORACLE_HOME/bin/dbstart
DBSHUTDOWN=$ORACLE_HOME/bin/dbshut
LOG=$ORACLE_HOME/logs
# gernel logs file
if [ -e $LOG ] ; then
touch $LOG
chown $ORACLE_OWNER $LOG
fi
start() {
# Start daemons.
RETVAL=$?
echo "Starting oracle linstener and databases"
/bin/date '+%F %X Starting oracle linstener and databases' >> $LOG
/bin/su - $ORACLE_OWNER -c "$LISTENER start >> $LOG"
/bin/su - $ORACLE_OWNER -c "$DBSTART >>$LOG"
return $RETVAL
}
stop() {
# Stop daemons.
echo $"Shutting down listener and databases "
RETVAL=$?
/bin/date '+%F %X Shutting down listener and databases ' >> $LOG
/bin/su - $ORACLE_OWNER -c "$LISTENER stop >> $LOG"
/bin/su - $ORACLE_OWNER -c "$DBSHUTDOWN >> $LOG"
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
RETVAL=$?
;;
status)
ps -ef |grep -v grep |grep -q ora_smon_gtmc
if [ $? = 0 ]
then
exit 0
else
exit 1
fi
;;
*)
echo $"Usage: $0 {start|stop|restart|}"
exit 1
esac
exit $RETVAL
阅读(3862) | 评论(1) | 转发(0) |