Linux system boot oracle Auto-start (method 1) --- load as service auto-start, stop
1. dbstart and dbstop
The Oracle database automatically starts and stops the dbstart and dbshut files provided by Oracle (in 7.3.3.0.0 ). These files can be used only when the/etc/oratab file exists (although you can remove this restriction by changing the dbshut and dbstart files .)
The format of the/etc/oratab file is as follows:
--------------------------------------------------------------------------------
SID: ORACLE_HOME: AUTO
--------------------------------------------------------------------------------
For example
--------------------------------------------------------------------------------
*:/Opt/oracle9/product/9.2.0.4: N
Boss:/opt/oracle9/product/9.2.0.4: Y
--------------------------------------------------------------------------------
Ii. init. d and rc. d
To automatically start and end the database at startup and shutdown, You need to modify the Linux Startup Script file. This is not difficult, but I need to point out that these changes vary with Linux releases (slackware, debian, redhat, and so on. My examples apply to Redhat 5.0. To make changes to your Linux system, first refer to the Linux file on your hand. (Although this should actually apply to all Sys v unix .)
First, we need to create a script file that will execute dbshut and dbstart in the/etc/rc. d/init. d directory. Name the following file/etc/rc. d/init. d/oracle:
######################################## #####################
# Chkconfig: 2345 98 05
# Description: Oracle Server
# Add for Oracle
Oracle_base =/opt/oracle9
Export oracle_base
ORACLE_HOME = $ oracle_base/product/9.2.0.4
Export ORACLE_HOME
Oracle_sid = boss
Export oracle_sid
Ora_nls33 = $ ORACLE_HOME/ocommon/NLS/admin/Data
Export ora_nls33
Nls_lang = american_america.zhs16gbk
Export nls_lang
LD_LIBRARY_PATH = $ LD_LIBRARY_PATH: $ ORACLE_HOME/lib
Export LD_LIBRARY_PATH
Case "$1" in
Start)
Echo "Starting oracle ..."
Su Oracle-c "/opt/oracle9/product/9.2.0.4/bin/LSNRCTL start"
Su Oracle-c "/opt/oracle9/product/9.2.0.4/bin/dbstart 1> $ ORACLE_HOME/bin/dbstart. log 2> $ ORACLE_HOME/bin/dbstart. Err"
Echo "started ."
Exit 0
;;
Stop)
Echo "stoping oracle ..."
Su Oracle-c "/opt/oracle9/product/9.2.0.4/bin/LSNRCTL stop"
Su Oracle-c "/opt/oracle9/product/9.2.0.4/bin/dbshut"
Echo "stoped ."
Exit 0
;;
*)
Echo "Usage: $0 {START | stop }"
Exit 1
Esac
######################################## #####################
The following is another shell
--------------------------------------------------------------------------------
#! /Bin/sh
#
# Chkconfig: 2345 98 05
# Description: Oracle Server
#/Etc/rc. d/init. d/Oracle
# Explanation: Start and Stop Oracle databases and listeners
# Check how script files are executed
Case "$1" in
Start)
Echo-n "Starting Oracle Databases :"
Echo "----------------------------------------------------">/var/log/oracle
Date + "! % T % A % d: Starting Oracle databases as part of system up. ">/var/log/Oracle
Echo "----------------------------------------------------">/var/log/Oracle
Su-Oracle-C dbstart>/var/log/Oracle
Echo "Done ."
Echo-n "Starting Oracle Listeners :"
Su-oracle-c "lsnrctl start">/var/log/oracle
Echo "Done ."
Echo ""
Echo "----------------------------------------------------">/var/log/oracle
Date + "! % T % a % D: Finished. ">/var/log/oracle
Echo "----------------------------------------------------">/var/log/oracle
Touch/var/lock/subsys/oracle
;;
Stop)
Echo-n "Shutting Down Oracle Listeners :"
Echo "----------------------------------------------------">/var/log/oracle
Date + "! % T % A % d: Shutting Down Oracle databases as part of system down. ">/var/log/Oracle
Echo "----------------------------------------------------">/var/log/Oracle
Su-Oracle-c "LSNRCTL stop">/var/log/Oracle
Echo "Done ."
Rm-f/var/lock/subsys/oracle
Echo-n "Shutting Down Oracle Databases :"
Su-oracle-c dbshut>/var/log/oracle
Echo "Done ."
Echo ""
Echo "----------------------------------------------------">/var/log/oracle
Date + "! % T % a % D: Finished. ">/var/log/oracle
Echo "----------------------------------------------------">/var/log/oracle
;;
Restart)
Echo-n "Restarting Oracle databases :"
Echo "----------------------------------------------------">/var/log/Oracle
Date + "! % T % a % D: Restarting Oracle Databases as part of system up. ">/var/log/oracle
Echo "----------------------------------------------------">/var/log/oracle
Su-oracle-c dbstop>/var/log/oracle
Su-Oracle-C dbstart>/var/log/Oracle
Echo "done ."
Echo-n "Restarting Oracle listeners :"
Su-Oracle-c "LSNRCTL stop">/var/log/Oracle
Su-Oracle-c "LSNRCTL start">/var/log/Oracle
Echo "done ."
Echo ""
Echo "----------------------------------------------------">/var/log/Oracle
Date + "! % T % a % D: Finished. ">/var/log/oracle
Echo "----------------------------------------------------">/var/log/oracle
Touch/var/lock/subsys/oracle
;;
*)
Echo "Usage: oracle {start | stop | restart }"
Exit 1
Esac
Check whether the file correctly starts and stops the database in the system. Check the log file to see if there is any error message.
After the script file is completed, we need to create and delete symbolic links in the correct runlevel directories/etc/rc. d/rcX. d directory ).
The following command ensures that the database is called under execution level 2, 3, 4, 5:
$ 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/rc4.d/S99oracle
$ Ln-s ../init. d/oracle/etc/rc. d/rc5.d/S99oracle
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/rc1.d/K01oracle # Stop
$ Ln-s ../init. d/oracle/etc/rc. d/rc6.d/K01oracle # restart
======================================
Add oracle service to service
# Chkconfig-add/etc/rc. d/init. d/oracle
Check whether the Automatic startup setting is successful:
# Chkconfig-list oracle
Oracle 0: Disable 1: Disable 2: Disable 3: Enable 4: Enable 5: Enable 6: Disable
* From the above we can see that all level 345 has been enabled, and the configuration is successful!
====================================
Start oracle on linux (method 2)
Log On As root:
$ Su-root
1. oracle dbstart and dbshut in linux do not respond: Modify the Oracle system configuration file/etc/oratab: # vi/etc/oratab
/Etc/oratab format: SID: ORACLE_HOME: AUTO
Set the AUTO domain to Y (uppercase). Mine is:
Oradb:/opt/u01/app/oracle/product/9.2.0.4: Y
Only in this way can dbstart and dbshut of oracle be used.
2. Modify the/etc/rc. d/rc. local configuration file.
Add the following content to/etc/rc. d/rc. local: # vi/etc/rc. d/rc. local
Su-oracle-c "/u01/app/oracle/product/9.2.0.4/bin/lsnrctl start"
Su-oracle-c "/u01/app/oracle/product/9.2.0.4/bin/dbstart start"
3. Restart
# Reboot
4. connection test (login as oracle)
$ Sqlplus"
[Email = sys/oracle @ oradb] sys/oracle @ oradb [/email]
As sysdba"
...
SQL>
5. It indicates that the auto-start is successful.