随笔-42  评论-12  文章-0  trackbacks-0
自动启动Oracle数据库并在系统关闭时自动关闭Oracle数据库。自动化数据库启动是可选的,但是自动化关闭是推荐的,因为它保护数据库不适当的关闭。 
  dbshut和dbstart脚本位于$ORACLE_HOME/bin目录并且可以用于自动化数据库启动和关闭。 
  dbstart和dbshut脚本引用在oratab文件中同样的条目,因此脚本必须适用于同一个数据库集合。例如,你不能让dbstart已自动启动数据库sid1、sid2和sid3,而让dbshut仅关闭数据库sid1和sid2。然而,你可以指定dbshut关闭当前dbstart根本没使用的数据库。要做到这样,在关闭文件中包括dbshut但是在系统启动文件中省略dbstart。 
  也可见: 对于系统启动和关闭过程的描述,检查你的操作系统关于init命令的文档。 

自动化数据库启动和关闭 
  本过程必须对你想要配置成自动化启动和关闭的每个新数据库完成。执行下列任务建立dbstart和dbshut脚本以便他们在系统启动被调用: 
  1. 编辑/etc/oratab文件。 
  在oratab文件中的数据库入口以下列格式出现: 
  ORACLE_SID:ORACLE_HOME:{Y|N} 

这里Y或N指定你是否想要dbstart和dbshut脚本启动并关闭数据库。找出你想要启动的所有数据库入口。他们有第一列的sid指出。改变最后一个列为Y。 
  2. 在/etc/rc.d/init.d目录下创建一个名为dbora(如果它还不存在)的文件。 
  3. 在dbora文件末尾创建类似于下面的入口(如果他们还不存在)。确定给出完整的dbstart实用程序的路径。 
  4. #!/bin/sh 
  5. # Set ORA_HOME to be equivalent to the ORACLE_HOME 
  6. 
  7. # from which you wish to execute dbstart and 
  8. 
  9. # dbshut 
  10. 
  11. # set ORA_OWNER to the user id of the owner of the 
  12. 
  13. # Oracle database in ORA_HOME 
  14. 
  15. ORA_HOME=/u01/app/oracle/product/8.1.6 
  16. 
  17. ORA_OWNER=oracle 
  18. 
  19. if [! -f $ORA_HOME/bin/dbstart] 
  20. 
  21. then 
  22. 
  23. echo "Oracle startup: cannot start" 
  24. 
  25. exit 
  26. 
  27. fi 
  28. 
  29. case "$1" in 
  30. 
  31. 'start'
  32. 
  33. 
  34. # Start the Oracle databases: 
  35. # The following command assumes that the oracle login will not prompt the 
  36. 
  37. # user for any value
  38. 
  39. 
  40. su - $ORA_OWNER -c $ORA_HOME/bin/dbstart & 
  41. 
  42.  
  43. 
  44. 'stop'
  45. 
  46. 
  47. # Stop the Oracle databases: 
  48. # The following command assumes that the oracle login will not prompt the 
  49. 
  50. # user for any value
  51. 
  52. 
  53. su - $ORA_OWNER -c $ORA_HOME/bin/dbshut & 
  54. 
  55.  
  56. 
  57. esac 
    
  4. 链接dbora,输入: 
  5. # ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc0.d/K10dbora 
  6. # ln -s /etc/rc.d/init.d/dbora /etc/rc.d/rc2.d/S99dbora 
posted on 2008-03-31 09:45 tianjuchuan 阅读(875) 评论(0)  编辑 收藏 引用 所属分类: 处理的问题
只有注册用户登录后才能发表评论。