Welcome 微信登录

首页 / 数据库 / MySQL / Oracle 10g 随Linux系统自动启动的设置脚本

1 . 编辑/etc/oratab文件,将对应的sid那一行的N改为Y<?XML:NAMESPACE PREFIX = O />    [root@ www.linuxidc.com~]# vi /etc/oratab 修改后的例子:orcl:/u01/app/Oracle/product/<?XML:NAMESPACE PREFIX = ST1 />10.2.0/db_1:Y2. 在 /etc/rc.d/init.d/ 目录下,创建 oracle 服务脚本文件,并将如下内容放入脚本中:     [root@ www.linuxidc.com~]# vi /etc/rc.d/init.d/oracle
  1. #!/bin/bash    
  2. #root  
  3. #chkconfig:35  85  15   
  4. #description:Oracle  
  5. #/etc/rc.d/init.d/oracle  
  6.  
  7. ORACLE_BASE=/u01/app/oracle  
  8.  
  9. ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1  
  10.  
  11. ORACLE_SID=orcl 
  12.  
  13. case "$1" in  
  14.  
  15. start)  
  16.  
  17.        echo -n "Starting Oracle10g:"  
  18.  
  19.        su - oracle -c dbstart >>$ORACLE_HOME/log/autostart.log  
  20.  
  21.        su - oracle -c "lsnrctl start" >>$ORACLE_HOME/log/autostart.log  
  22.  
  23.        su - oracle -c "emctl start dbconsole" >>$ORACLE_HOME/log/autostart.log  
  24.  
  25.        ;;  
  26.  
  27. stop)  
  28.  
  29.        echo -n "Shutting Down Oracle10g:"  
  30.  
  31.        su - oracle -c "emctl stop dbconsole" >>$ORACLE_HOME/log/autostart.log  
  32.  
  33.        su - oracle -c "lsnrctl stop" >>$ORACLE_HOME/log/autostart.log  
  34.  
  35.        su - oracle -c dbshut >>$ORACLE_HOME/log/autostart.log  
  36.  
  37.        ;;  
  38.  
  39. restart)  
  40.  
  41.        echo -n "Restarting Oracle10g:"  
  42.  
  43.        su - oracle -c dbshut >>$ORACLE_HOME/log/autostart.log  
  44.  
  45.        su - oracle -c "lsnrctl stop" >>$ORACLE_HOME/log/autostart.log  
  46.  
  47.        su - oracle -c "emctl stop dbconsole" >>$ORACLE_HOME/log/autostart.log  
  48.  
  49.        su - oracle -c dbstart >>$ORACLE_HOME/log/autostart.log  
  50.  
  51.        su - oracle -c "lsnrctl start" >>$ORACLE_HOME/log/autostart.log  
  52.  
  53.        su - oracle -c "emctl start dbconsole" >>$ORACLE_HOME/log/autostart.log  
  54.  
  55.        ;;  
  56.  
  57. *)  
  58.  
  59.        echo "Usage: $0{start|stop|restart}"  
  60.  
  61.        exit 1  
  62.  
  63.        ;;  
  64.  
  65. esac  
  66.  
  67. exit 0   
3. 将该脚本设置为可执行文件    [root@ www.linuxidc.com~]# chmod a+x /etc/rc.d/init.d/oracle 4. 建立启动与关闭界面的连接(S打头的是启动程序,K打头的是关闭程序)[root@ www.linuxidc.com~]# ln -s  /etc/rc.d/init.d/oracle  /etc/rc.d/rc5.d/S85oracle   (linux图形界面下的自启动在rc5.d目录下) [root@cop~]# ln -s  /etc/rc.d/init.d/oracle  /etc/rc.d/rc5.d/K15oracle   (linux图形界面下的关闭服务链接) [root@cop~]# ln -s  /etc/rc.d/init.d/oracle  /etc/rc.d/rc3.d/S85oracle   (linux文字界面下的自启动在rc3.d目录下) [root@cop~]# ln -s  /etc/rc.d/init.d/oracle  /etc/rc.d/rc3.d/K15oracle   (linux文字界面下的关闭服务链接)    上面的“S85oracle”和“K15oracle”文件也都要设置为可执行文件 5、加入liunx自启动服务:    [root@cop~]# chkconfig --add oracle    [root@cop~]# chkconfig --list oracle       ( 检查是否成功加入)     oracle      0:off   1:off   2:off   3:on    4:on    5:on    6:offMySQL视图表创建与修改解决Linux下登录Oracle时上下快捷键重现命令问题相关资讯      Oracle教程 
  • Oracle中纯数字的varchar2类型和  (07/29/2015 07:20:43)
  • Oracle教程:Oracle中查看DBLink密  (07/29/2015 07:16:55)
  • [Oracle] SQL*Loader 详细使用教程  (08/11/2013 21:30:36)
  • Oracle教程:Oracle中kill死锁进程  (07/29/2015 07:18:28)
  • Oracle教程:ORA-25153 临时表空间  (07/29/2015 07:13:37)
  • Oracle教程之管理安全和资源  (04/08/2013 11:39:32)
本文评论 查看全部评论 (0)
表情: 姓名: 字数