How to Set auto-start for Oracle in Linux

Source: Internet
Author: User

Method 1) Add the following script to/etc/rc. d/rc. Local or/etc/rc. d/RC

# Setting Environment Variables
Export oracle_base =/opt/Oracle
Export ORACLE_HOME =/opt/Oracle/product/9204
Export Path = $ ORACLE_HOME/bin: $ ORACLE_HOME/Apache/bin: $ path
Export oracle_owner = Oracle
Export oracle_sid = test
Export oracle_term = xterm
Export ld_assume_kernel = 2.4.19
Export threads_flag = native
Export LD_LIBRARY_PATH =/opt/Oracle/product/9204/lib: $ LD_LIBRARY_PATH
Export Path =/opt/Oracle/product/9204/bin: $ path

Export display =: 0
# Use the account name Oracle to log on to start Oracle
Oracle_user = Oracle

# Start listeners and databases

Su-"$ oracle_user" <EOO
LSNRCTL start
Sqlplus/nolog <Eos
# Use the DBA Account System to log on to connect system (this is the account name)/system (account password) as sysdba
Connect system/system as sysdba
Startup
EOS
EOO

PS: You can also put the above script in a file, and then add the called statement to RC. Local.

Method 2) load as service self-start and stop

Step 1: Add a STARTUP script in the/etc/rc. d/init. d directory, such as oracleservice. The script is as follows:

#! /Bin/sh
#
# Name:/etc/rc. d/init. d/oracleservice
# Chkconfig: 345 99
# Description: Start and Stop Oracle database and Listener ControlProgram
# Note: The above two lines are required. For details, refer to chkconfig.
# Oracle environment

Export oracle_base =/opt/Oracle
Export ORACLE_HOME =/opt/Oracle/product/9204
Export Path = $ ORACLE_HOME/bin: $ ORACLE_HOME/Apache/bin: $ path
Export oracle_owner = Oracle
Export oracle_sid = test
Export oracle_term = xterm
Export ld_assume_kernel = 2.4.19
Export threads_flag = native
Export LD_LIBRARY_PATH =/opt/Oracle/product/9204/lib: $ LD_LIBRARY_PATH
Export Path =/opt/Oracle/product/9204/bin: $ path

Export display =: 0

Oracle_user = Oracle

Case "$1" in
Start)

# Start the Listener Control Program and database

Su-"$ oracle_user" <EOO
LSNRCTL start
Sqlplus/nolog <Eos
Connect system/system as sysdba
Startup
EOS
EOO
;;

Stop)

# Stop the Listener Control Program and database

Su-"$ oracle_user" <EOO
LSNRCTL stop
Sqlplus/nolog <Eos
Connect system/system as sysdba
Shutdown immediate

EOS
EOO
;;

*)
;;

Esac
# -- Script end
# It can be learned from the script that the script starts and stops the database and Listener Control Program through the start or stop parameters.

Step 2:

Change the permission and set it to run. In the Shel window, enter:
# Chmod + x/etc/rc. d/init. d/oracleservice

Step 3: Add oracleservice to the service

# Chkconfig-Add/etc/rc. d/init. d/oracleservice

Check whether the Automatic startup setting is successful:
# Chkconfig-list oracleservice
Oracleservice 0: Disabled 1: Disabled 2: Disabled 3: enabled 4: enabled 5: enabled 6: Disabled
* From the above we can see that all level 345 has been enabled, and the configuration is successful!

Step 4: restart and check whether Oracle Auto-start is successful.

Method 3) use the Oracle dbstart script at $ ORACLE_HOME/bin/dbstart.
After reading the online Introduction, You need to modify/etc/oratab to set the last item in dbstart to Y, for example:
Test:/opt/Oracle/product/9204: N, changed to test:/opt/Oracle/product/9204: Y

You have no time to try dbstart. Try again when you are free.

/Etc/oratab file description:
This file is used by Oracle utilities. It is created by root. Sh
# And updated by the database configuration assistant when creating
# A database.

# A colon,:, is used as the field Terminator. A new line terminates
# the entry. lines beginning with a pound sign, #, are comments.
#< BR ># entries are of the form:
#$ oracle_sid: $ ORACLE_HOME: :
# The first and second fields are the system identifier and home
# directory of the database respectively. the third filed indicates
# To the dbstart utility that the database shocould, "Y", or shocould not,
# "N ", be brought up at system boot time.
# multiple entries with the same $ oracle_sid are not allowed.

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.