Oracle service boot from boot

Source: Internet
Author: User
Tags stop script file permissions

1. Modify the Oracle System configuration file::/etc/oratab

Vi/etc/oratab

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

2. Create the file Oracle startup script under/etc/init.d/, with the following content:

#!/bin/sh
# chkconfig:35 80 10
# description:oracle Auto Start-stop script.
#
# Set Ora_home to being equivalent to the $ORACLE _home
# from which-Wish to execute Dbstart and Dbshut;
#
# Set Ora_owner to the user ID of the OWNER of the
# 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 "$" in
' Start ')
# Start the Oracle databases:
echo "Starting Oracle Databases ... "
echo "-------------------------------------------------" >>/var/log/oracle
Date + "%T%a%d:starting Oracle Databases as part of the 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 the 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 the 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 the 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 ')
$ stop
$ start

Esac


          

3. Change file permissions
# chmod 755/etc/init.d/oracle

4. Add a service
# chkconfig--level Oracle on

5. How to use
# service Oracle Start//Launch Oracle
# Service Oracle Stop//Turn off Oracle
# Service Oracle Restart//Restart Oracle

6. Need to stop the database before shutting down or restarting the machine and doing the operation
# ln-s/etc/init.d/oracle/etc/rc0.d/k01oracle//shutdown
# ln-s/etc/init.d/oracle/etc/rc6.d/k01oracle//restart

Related Article

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.