Oracle is started as a service on Linux

Source: Internet
Author: User

Create a file named Oracle

 
 
  1. [root@stark init.d]# pwd 
  2. /etc/init.d 
  3. [root@stark init.d]# touch oracle 

Add the following content to 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 

Modify permissions so that oracle has executable permissions

 
 
  1. [Root @ stark init. d] # chmod a + x oracle
Add oracle to system service and start it
 
 
  1. [root@stark init.d]# chkconfig add oracle 
  2. [root@stark init.d]# chkconfig oracle on

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.