Oracle automatic start and stop in Linux

Source: Internet
Author: User

1. Modify the Oracle system configuration file and change n to Y:

Sudo VI/etc/oratab

 

Orcl:/Oracle/ORACLE_HOME: Y
Blogs:/Oracle/ORACLE_HOME: Y

 

Note:

/Etc/oratab format: Sid: ORACLE_HOME: Auto
Set n to Y (uppercase). Only in this way can dbstart and dbshut of Oracle be used.

2. log on to the root user and write the service script:
As follows #! /Bin/bash
#
# Chkconfig: 35 95 1
# Description: init script to start/stop Oracle Database 10g, TNS Listener, EMS, ISQLPLUS
#
#
#
# Match these values to your environment:

Export oracle_base =/Oracle/ORACLE_HOME
Export ORACLE_HOME = $ oracle_base
# Export oracle_term = xterm
Export Path = $ path: $ ORACLE_HOME/bin
# Export nls_lang = 'American _ America. zhs16gbk'
Export oracle_sid = esales
# Export display = localhost: 0
Export oracle_user = Oracle

# See how we are called:
Case $1 in
Start)
Su-"$ oracle_user" <EOO
LSNRCTL start
Sqlplus/nolog <Eos
Connect/As sysdba
Startup
EOS
Emctl start dbconsole
Isqlplusctl start
EOO
;;

Stop)
Su-"$ oracle_user" <EOO
LSNRCTL stop
Sqlplus/nolog <Eos
Connect/As sysdba
Shutdown immediate
EOS
Emctl stop dbconsole
Isqlplusctl stop
EOO
;;

Restart)
$0 stop
$0 start

;;

*)
Echo "Usage: $0 {START | stop | restart }"
;;
Esac

Name the script Oracle and save it under/etc/rc. d/init. d.
Change file attributes: chmod 755 Oracle

 

3. Establish a service connection:

When the system starts the database, we need the following link:
--------------------------------------------------------------------------------
$ Ln-S ../init. d/Oracle/etc/rc. d/rc2.d/s99oracle
$ Ln-S ../init. d/Oracle/etc/rc. d/rc3.d/s99oracle
$ Ln-S ../init. d/Oracle/etc/rc. d/rc5.d/s99oracle # rc4.d unused

--------------------------------------------------------------------------------

To stop the database at restart, we need the following link:

--------------------------------------------------------------------------------

$ Ln-S ../init. d/Oracle/etc/rc. d/rc0.d/k01oracle # Stop
$ Ln-S ../init. d/Oracle/etc/rc. d/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.