Linux Oracle Services Start & Stop scripts and boot from boot

Source: Internet
Author: User
Tags file permissions

Premise: Oracle_base=/u01/app/oracle oracle_home=/u01/app/oracle/product/11.2.0/dbhome_1

1. Modify the Oracle System configuration file:/etc/oratab, only then can Oracle's own Dbstart and Dbshut work.

# Vi/etc/oratab
Orcl:/opt/oracle/102:y

2. Under/etc/init.d/, create the file Oracle with the following content:

#!/bin/bash
#chkconfig: 345 61 
#description: apache 
#
# Set Ora_home to is equivalent to The $ORACLE _home
# from which your 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=/u01/app/oracle/product/11.2.0/dbhome_1
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." & gt;>/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. 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

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

7. Testing

Linux Oracle Services Start & Stop scripts and boot from boot

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.