linux自启动oracle

将Oracle服务添加到Linux开机启动项,以root用户建立/etc/rc.d/init.d/oradb脚本文件,文件内容如下:
  1. #!/bin/bash 
  2. # chkconfig: 2345 90 10 
  3. export ORACLE_BASE=/home/oracle_11/app/ 
  4. export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/db_1 
  5. export ORACLE_SID=orcl 
  6. export PATH=$PATH:$ORACLE_HOME/bin 
  7. ORCL_OWN="oracle" 
  8. # if the executables do not exist -- display error 
  9. if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ] 
  10. then 
  11.    echo "Oracle startup: cannot start" 
  12.    exit 1 
  13. fi 
  14. # depending on parameter -- start, stop, restart 
  15. # of the instance and listener or usage display 
  16. case "$1" in 
  17. start) 
  18. # Oracle listener and instance startup 
  19. echo -n "Starting Oracle: " 
  20. su - $ORCL_OWN -c "$ORACLE_HOME/bin/dbstart" 
  21. touch /var/lock/subsys/oradb 
  22. su - $ORCL_OWN -c "$ORACLE_HOME/bin/emctl start dbconsole" 
  23. echo "OK" 
  24. ;; 
  25. stop) 
  26. # Oracle listener and instance shutdown 
  27. echo -n "Shutdown Oracle: " 
  28. su - $ORCL_OWN -c "$ORACLE_HOME/bin/emctl stop dbconsole" 
  29. su - $ORCL_OWN -c "$ORACLE_HOME/bin/dbshut" 
  30. rm -f /var/lock/subsys/oradb 
  31. echo "OK" 
  32. ;; 
  33. reload|restart) 
  34. $0 stop 
  35. $1 start 
  36. ;; 
  37. *) 
  38. echo "Usage: 'basename $0' start|stop|restart|reload" 
  39. exit 1 
  40. esac 
  41. exit 0 
  42. 将该文件添加到开机启动
    1. # chmod 755 /etc/rc.d/init.d/oradb 
    2. # chkconfig --add oradb 

    重启服务

     

    1. # service oradb stop 
    2. # service oradb start 

    下次启动机器的时候,Oracle服务会随机器一起启动。


猜你喜欢

转载自blog.csdn.net/yz7074998/article/details/79967999
今日推荐