In linux, oracle is configured with the system to start and shut down, and in linux, oracle is configured

Source: Internet
Author: User

In linux, oracle is configured with the system to start and shut down, and in linux, oracle is configured

Configure oracle to start and shut down with the system in linux

1. Modify the/etc/oratab File
Change the number of databases that need to be started with the operating system from N to Y.
Lis:/u01/app/oracle/product/11.2.0/db_1: N
To:
Lis:/u01/app/oracle/product/11.2.0/db_1: Y

2. Edit the dbstart and dbshut scripts and change the listening variables to the oracle Home Directory.
$ Cd $ ORACLE_HOME/bin
$ Vi dbstart
Set
ORACLE_HOME_LISTNER = $1
Change
ORACLE_HOME_LISTNER = $ ORACLE_HOME
Modify the dbshut script in the same way
Therefore, you do not need to pass parameters when calling scripts.
3. Write/etc/init. d/oracle script
Vi/etc/init. d/oracle
The ORACLE_HOME variable and Log File starting with the script must be set according to the actual situation.
The content is as follows:
#! /Bin/bash
# Chkconfig: 345 99 01 (must be added, otherwise chkconfig -- add oracle Reports service oracle does not support chkconfig)
# Description: start oracle (must be added, otherwise chkconfig -- add oracle Reports service oracle does not support chkconfig)
ORACLE_LOG_FILE =/var/log/oracle
ORACLE_HOME =/oracle/product/11.2.0/db_1

Case $1 in
Start)
Date + "% F % X"> $ ORACLE_LOG_FILE
Echo "Starting Oracle Databases and Listener:" >>$ ORACLE_LOG_FILE
Touch/var/lock/subsys/oracle
Su-oracle-c $ ORACLE_HOME/bin/dbstart> $ ORACLE_LOG_FILE
Echo "Oracle Databases and Listener Started Successfully! ">>$ ORACLE_LOG_FILE
Echo ""
Echo "---------------------------------------------------------------------"> $ ORACLE_LOG_FILE
;;

Stop)
Date + "% F % X"> $ ORACLE_LOG_FILE
Echo "Shutting Down Oracle Databases and Listener:" >>$ ORACLE_LOG_FILE
Rm-rf/var/lock/subsys/oracle
Su-oracle-c $ ORACLE_HOME/bin/dbshut> $ ORACLE_LOG_FILE
Echo "Oracle Databases and Listener Stopped Successfully! ">>$ ORACLE_LOG_FILE
Echo ""
Echo "---------------------------------------------------------------------"> $ ORACLE_LOG_FILE
;;

Restart)
Date + "% F % X"> $ ORACLE_LOG_FILE
Echo "Shutting Down Oracle Databases and Listener:" >>$ ORACLE_LOG_FILE
Rm-rf/var/lock/subsys/oracle
Su-oracle-c $ ORACLE_HOME/bin/dbshut> $ ORACLE_LOG_FILE
Echo "Oracle Databases and Listener Stopped Successfully! ">>$ ORACLE_LOG_FILE
Echo ""
Echo "Starting Oracle Databases and Listener:" >>$ ORACLE_LOG_FILE
Touch/var/lock/subsys/oracle
Su-oracle-c $ ORACLE_HOME/bin/dbstart> $ ORACLE_LOG_FILE
Echo "Oracle Databases and Listener Started Successfully! ">>$ ORACLE_LOG_FILE
Echo ""
Echo "---------------------------------------------------------------------"> $ ORACLE_LOG_FILE
;;

*)
Echo "Usage: Oracle {start | stop | restart }"
Exit 1
;;

Esac
Exit

4. Modify the script permission:
Chmod 750/etc/init. d/oracle

5. test whether the startup and shutdown scripts can run normally.
Test listener and database startup:
$ Service oracle start
Disable listeners and databases:
$ Service oracle stop
Test and restart the oracle listener and database:
$ Service oracle restart
Use lsnrctl status to check the listener status
Check the instance status by using ps-ef | grep ora _.

6. Add oracle as a service and set it to 345-level startup:
# Chkconfig -- add oracle
# Chkconfig -- list | grep oracle

7. If the database has been started and cannot be stopped, it is best to create the following lock file as the root user.
In this way, oracle will be automatically disabled at the next shutdown.
Touch/var/lock/subsys/oracle

8. Related script path:
Dbshut/dbstart $ ORACLE_HOME/bin/
Oracle/etc/init. d/

 

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.