Oracle 在Linux上作为服务启动


新建文件名为Oracle 
  1. [root@stark init.d]# pwd 
  2. /etc/init.d 
  3. [root@stark init.d]# touch oracle 

向oracle中添加下列内容 

  1. #!/bin/bash 
  2. # chkconfig: 35 95 1 
  3. # description: init script. to start/stop oracle database 10g, TNS listener 
  4. # match these values to your environment: 
  5. export ORACLE_BASE=/oracle 
  6. export ORACLE_HOME=/oracle/10.2 
  7. export ORACLE_TERM=xterm 
  8. export PATH=/home$ORACLE_HOME/bin:$PATH:. 
  9. export NLS_LANG=American_America.AL32UTF8 
  10. export ORACLE_SID=stark 
  11. export DISPLAY=localhost:0 
  12. export ORACLE_USER=oracle 
  13. case $1 in 
  14.     start) 
  15.     su - "$ORACLE_USER"<<stark 
  16.     lsnrctl start 
  17.     sqlplus /nolog<<jadeshow 
  18.     connect / as sysdba 
  19.     startup 
  20. jadeshow 
  21.     
  22. stark 
  23.     ;; 
  24.     stop) 
  25.     su - "$ORACLE_USER"<<stark 
  26.     lsnrctl stop 
  27.     sqlplus /nolog<<jadeshow 
  28.     connect / as sysdba 
  29.     shutdown immediate 
  30. jadeshow 
  31.     
  32. stark 
  33.     ;; 
  34.     
  35.           
  36.     *) 
  37.     echo "Usage: $0 {start|stop}" 
  38.     ;; 
  39. esac 

修改权限,使得oracle具有可执行权限 

  1. [root@stark init.d]# chmod a+x oracle  
添加oracle到系统服务并且开机启动
  1. [root@stark init.d]# chkconfig add oracle 
  2. [root@stark init.d]# chkconfig oracle on

相关内容