Auto-start oracle service

Source: Internet
Author: User

1. Modify the oracle system configuration file:/etc/oratab

Vi/etc/oratab

Orcl:/opt/oracle/product/10.2.0/db_1: Y

2. Create an oracle STARTUP script under/etc/init. d/. The content is as follows:

#! /Bin/sh
# Chkconfig: 35 80 10
# Description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ ORACLE_HOME
# From which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of
# Oracle database in ORA_HOME.
ORA_HOME =/opt/oracle/102
ORA_OWNER = oracle
If [! -F $ ORA_HOME/bin/dbstart]
Then
Echo "Oracle startup: cannot start"
Exit
Fi
Case "$1" in
'Start ')
# Start the Oracle databases:
Echo "Starting Oracle Databases ..."
Echo "-----------------------------------------------">/var/log/oracle
Date + "% T % a % D: Starting Oracle Databases as part of system up.">/var/log/oracle
Echo "-----------------------------------------------">/var/log/oracle
Su-$ ORA_OWNER-c "$ ORA_HOME/bin/dbstart">/var/log/oracle
Echo "Done"
# Start the Listener:
Echo "Starting Oracle Listeners ..."
Echo "-----------------------------------------------">/var/log/oracle
Date + "% T % a % D: Starting Oracle Listeners as part of system up.">/var/log/oracle
Echo "-----------------------------------------------">/var/log/oracle
Su-$ ORA_OWNER-c "$ ORA_HOME/bin/lsnrctl start">/var/log/oracle
Echo "Done ."
Echo "-----------------------------------------------">/var/log/oracle
Date + "% T % a % D: Finished.">/var/log/oracle
Echo "-----------------------------------------------">/var/log/oracle
Touch/var/lock/subsys/oracle

'Stop ')
# Stop the Oracle Listener:
Echo "Stoping Oracle Listeners ..."
Echo "-----------------------------------------------">/var/log/oracle
Date + "% T % a % D: Stoping Oracle Listener as part of system down.">/var/log/oracle
Echo "-----------------------------------------------">/var/log/oracle
Su-$ ORA_OWNER-c "$ ORA_HOME/bin/lsnrctl stop">/var/log/oracle
Echo "Done ."
Rm-f/var/lock/subsys/oracle
# Stop the Oracle Database:
Echo "Stoping Oracle Databases ..."
Echo "-----------------------------------------------">/var/log/oracle
Date + "% T % a % D: Stoping Oracle Databases as part of system down.">/var/log/oracle
Echo "-----------------------------------------------">/var/log/oracle
Su-$ ORA_OWNER-c "$ ORA_HOME/bin/dbshut">/var/log/oracle
Echo "Done ."
Echo ""
Echo "-----------------------------------------------">/var/log/oracle
Date + "% T % a % D: Finished.">/var/log/oracle
Echo "-----------------------------------------------">/var/log/oracle

'Restart ')
$0 stop
$0 start

Esac


          

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3. Change File Permissions
# Chmod 755/etc/init. d/oracle

4. Add a service
# Chkconfig -- level 35 oracle on

5. Usage
# Service oracle start // start oracle
# Service oracle stop // close oracle
# Service oracle restart // restart oracle

6. You need to stop the database before shutting down or restarting the machine.
# Ln-s/etc/init. d/oracle/etc/rc0.d/K01oracle // Shutdown
# Ln-s/etc/init. d/oracle/etc/rc6.d/K01oracle // restart

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.