oracle开机启动脚本,加入/etc/init.d,并使用chkconfig命令设置开机启动

 
  
  1. #!/bin/bash  
  2. #  
  3. # chkconfig: 2345 80 05  
  4. # description: Oracle 10g Server  
  5. #  
  6. # Run-level Startup script for the Oracle Instance, Listener, and 
  7. # Web Interface  
  8. export ORACLE_BASE=/export/dbhome/oracle  
  9. export ORACLE_HOME=$ORACLE_BASE/10gr2  
  10. export ORACLE_SID=bgiora01  
  11. export PATH=$PATH:$ORACLE_HOME/bin  
  12. ORA_OWNR=”oracle”  
  13. # if the executables do not exist — display error  
  14. if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]  
  15. then 
  16.        echo “Oracle startup: cannot start”  
  17.        exit 1  
  18. fi  
  19. # depending on parameter — startup, shutdown, restart  
  20. of the instance and listener or usage display  
  21. case “$1″ in 
  22.    start)  
  23.        # Oracle listener and instance startup  
  24.        echo -n “Starting Oracle: “  
  25. #        su $ORA_OWNR -c “$ORACLE_HOME/bin/lsnrctl start”  
  26.        su $ORA_OWNR -c $ORACLE_HOME/bin/dbstart  
  27.        touch /var/lock/oracle  
  28.        su $ORA_OWNR -c “$ORACLE_HOME/bin/emctl start dbconsole”  
  29.        su $ORA_OWNR -c “$ORACLE_HOME/bin/isqlplusctl start”  
  30.        echo “OK”  
  31.        ;;  
  32.    stop)  
  33.        # Oracle listener and instance shutdown  
  34.        echo -n “Shutdown Oracle: “  
  35. #        su $ORA_OWNR -c “$ORACLE_HOME/bin/lsnrctl stop”  
  36.        su $ORA_OWNR -c $ORACLE_HOME/bin/dbshut  
  37.        rm -f /var/lock/oracle  
  38.        su $ORA_OWNR -c “$ORACLE_HOME/bin/emctl stop dbconsole”  
  39.        su $ORA_OWNR -c “$ORACLE_HOME/bin/isqlplusctl stop”  
  40.        echo “OK”  
  41.        ;;  
  42.    reload|restart)  
  43.        $0 stop  
  44.        $0 start  
  45.        ;;  
  46.    *)  
  47.        echo “Usage: `basename $0` start|stop|restart|reload”  
  48.        exit 1  
  49. esac  
  50. exit 0