- 论坛徽章:
- 0
|
# copyright: Written by yonggangqiu, free to distribute.
# You must keep everything in this file, including the copyright
# announcement.
RHCS监控功能只是根据脚本的返回值确定其状态是否正确,返回0则正确,非0则不正确。
这里头提供四个脚本,第一个脚本命名为oracle.sh,另外三个脚本分别为start.sh,stop.sh和state .sh
oracle.sh加载到RHCS中调用另外三个脚本即可。
//oracle.sh
#!/bin/bash
#
# Cluster service script to start/stop oracle
#
. /etc/rc.d/init.d/functions
cd /home/oracle
case $1 in
start)
su - oracle -c "./dbstart"
;;
stop)
su - oracle -c "./dbshut"
;;
status)
status oracle
;;
restart)
su - oracle -c "./dbshut"
su - oracle -c "./dbstart"
;;
esac
//start.sh
#!/bin/sh
/u01/app/oracle/oracle/product/10.2.0/db_1/bin/sqlplus /nolog<< EOF
connect / as sysdba
!lsnrctl start
--spool /home/oracle/startdb.log
startup;
--spool off
quit;
EOF
exit 0
//stop.sh
#!/bin/sh
/u01/app/oracle/oracle/product/10.2.0/db_1/bin/sqlplus /nolog<< EOF
conn / as sysdba
!lsnrctl stop
--spool /home/oracle/stopdb.log
shutdown immediate;
--spool off
quit;
EOF
exit 0
//state.sh
#!/bin/bash
1>/dev/null
2>/dev/null
sid1=`ps -ef|grep smon|grep -v grep|awk '{print $8}'| awk -F _ '{print $3}'`
#echo $sid1
#echo "the command is ok"
#sid2=double
#echo $sid2
if [ "$sid1" = "" ]
then
# echo "compare is ok"
exit 1
else
exit 0
fi
[ 本帖最后由 iamshui 于 2008-5-30 16:18 编辑 ] |
|