linux自启动oracle

矫情吗;* 2022-05-27 10:14 282阅读 0赞

将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. 1. \# service oradb stop
  2. 2. \# service oradb start
  3. 下次启动机器的时候,Oracle服务会随机器一起启动。

发表评论

表情:
评论列表 (有 0 条评论,282人围观)

还没有评论,来说两句吧...

相关阅读

    相关 LinuxOracle启动设置

    Linux下设置ORACLE自启动 网上的很多帖子讲的很不全面 所以写出自己实现自启动的过程 只要你按照过程操作 一定可以实现 > 查看ORACLE\_HOME是否设置