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