2、编辑dbstart和dbshut脚本,修改监听变量为oracle家目录
$ cd $ORACLE_HOME/bin
$ vi dbstart
将
ORACLE_HOME_LISTNER=$1
修改为
ORACLE_HOME_LISTNER=$ORACLE_HOME
以同样的方式修改dbshut脚本
所以调用脚本时就不用传递参数了
3、编写/etc/init.d/oracle脚本
vi /etc/init.d/oracle
其中脚本开头的ORACLE_HOME变量和日志文件需要根据实际情况设定
内容如下:
#!/bin/bash
#chkconfig: 345 99 01 (一定要加,否则chkconfig --add oracle 报错 service oracle does not support chkconfig )
#description:start oracle (一定要加,否则chkconfig --add oracle 报错 service oracle does not support chkconfig )
ORACLE_LOG_FILE=/var/log/oracle
ORACLE_HOME=/oracle/product/11.2.0/db_1
case $1 in
start)
date +"%F %X" >> $ORACLE_LOG_FILE
echo "Starting Oracle Databases and Listener:" >> $ORACLE_LOG_FILE
touch /var/lock/subsys/oracle
su - oracle -c $ORACLE_HOME/bin/dbstart >> $ORACLE_LOG_FILE
echo "Oracle Databases and Listener Started Successfully!" >> $ORACLE_LOG_FILE
echo ""
echo "-------------------------------------------------------------------" >> $ORACLE_LOG_FILE
;;
stop)
date +"%F %X" >> $ORACLE_LOG_FILE
echo "Shutting Down Oracle Databases and Listener:" >> $ORACLE_LOG_FILE
rm -rf /var/lock/subsys/oracle
su - oracle -c $ORACLE_HOME/bin/dbshut >> $ORACLE_LOG_FILE
echo "Oracle Databases and Listener Stopped Successfully!" >> $ORACLE_LOG_FILE
echo ""
echo "-------------------------------------------------------------------" >> $ORACLE_LOG_FILE
;;
restart)
date +"%F %X" >> $ORACLE_LOG_FILE
echo "Shutting Down Oracle Databases and Listener:" >> $ORACLE_LOG_FILE
rm -rf /var/lock/subsys/oracle
su - oracle -c $ORACLE_HOME/bin/dbshut >> $ORACLE_LOG_FILE
echo "Oracle Databases and Listener Stopped Successfully!" >> $ORACLE_LOG_FILE
echo ""
echo "Starting Oracle Databases and Listener:" >> $ORACLE_LOG_FILE
touch /var/lock/subsys/oracle
su - oracle -c $ORACLE_HOME/bin/dbstart >> $ORACLE_LOG_FILE
echo "Oracle Databases and Listener Started Successfully!" >> $ORACLE_LOG_FILE
echo ""
echo "-------------------------------------------------------------------" >> $ORACLE_LOG_FILE
;;