Every time you start and shut down Oracle, you have to knock a bunch of commands. Especially in the learning or testing environment, it is annoying to knock too much, so I wrote a servcie script to use the redhat s
Every time you start and shut down Oracle, you have to knock a bunch of commands. Especially in the learning or testing environment, it is annoying to knock too much, so I wrote a servcie script to use the redhat s
Every time you start and shut down Oracle, you have to think about a bunch of commands. Especially in the learning or testing environment, it is hard to get bored when you knock too much, so you have written a servcie script, use the RedHat service command to start, close, and restart the Oracle database, and enable or disable em and lsnrctl. The shell script and test result are attached below.
[Root @ jsb-ylw-5024 ~] # Cat/etc/init. d/oracle
#! /Bin/sh
# Chkconfig: 35 85 15
# Description: oracle
# Function: start... stop and restart the oracle instance on 11g R2 64bit
# Author: lw. yang
# Version: V.1.0
ORACLE_PID = 'ps-ef | grep ora | grep-E 'smon | pmon | ckpt' | wc-l'
Export ORACLE_BASE =/u01
Export ORACLE_HOME =/u01/oracle
Export ORACLE_SID = yang
Export PATH = $ ORACLE_HOME:/bin: $ PATH
# Source function library.
./Etc/rc. d/init. d/functions
Start (){
Su-oracle < Emctl start dbconsole
Lsnrctl start
Sqlplus/nolog < Conn/as sysdba
Startup
Exit
EOD
Exit
EOF
}
Stop (){
Su-oracle < Emctl stop dbconsole
Lsnrctl stop
Sqlplus/nolog < Conn/as sysdba
Shutdown immediate
Exit
EOD
Exit
EOF
}
Case "$1" in
Start)
Start
Touch/var/lock/subsys/oracle
;;
Stop)
Stop
;;
Status)
If ["$ ORACLE_PID" = "3"]; then
Echo "Oracle instance is running ..."
Else echo "Oracle instance is not running ..."
Fi
;;
Restart)
Stop
Start
;;
*)
Echo $ "Usage: $0 {start | stop | restart | status }"
Exit 1
Esac
[Root @ jsb-ylw-5024 ~] # Chmod + x/etc/init. d/oracle
[Root @ jsb-ylw-5024 ~] # Chkconfig -- add oracle
[Root @ jsb-ylw-5024 ~] # Service oracle status
Oracle instance is not running...