Usage:sh oracled [Start|stop|restart] SIDs where SIDs is the database name and multiple names are separated by commas. The default action is restart, or you can specify the action you want to take (start | Stop | Restart)
Copy Code code as follows:
#!/bin/sh
Cmdname= "Restart"
# get Oracle SID information from ENV by default.
ORACLESID=${ORACLE_SID}
ENV_ORACLESID=${ORACLE_SID}
function Echohelp () {
echo "******oracled Tool helper******"
echo "Usage:sh oracled [Start|stop|restart] SIDs"
echo "sids:seperated by comma"
Exit 5
}
function Startoracle () {
echo "Begin to start Oracle ..."
Lsnrctl start
For Cursid in ' Echo ${oraclesid} | awk ' BEGIN {rs= ', '}{ors= ' \ n '}{print '; Todo
if ["x${cursid}" = "X"]; Then
Continue
Fi
Export Oracle_sid=${cursid}
Sqlplus/nolog <<eof
Connect/as SYSDBA
Startup
Exit
Exit
Eof
echo "Oracle DB [${cursid}] started OK."
Done
}
function Stoporacle () {
echo "Begin to stop Oracle ..."
For Cursid in ' Echo ${oraclesid} | awk ' BEGIN {rs= ', '}{ors= ' \ n '}{print '; Todo
if ["x${cursid}" = "X"]; Then
Continue
Fi
Export Oracle_sid=${cursid}
Sqlplus/nolog <<eof
Connect/as SYSDBA
Shutdown immediate
Exit
Exit
Eof
echo "Oracle DB [${cursid}] stopped ok."
Done
Lsnrctl stop
}
function Restartoracle () {
Stoporacle
Startoracle
}
If [$#-lt 1]; Then
Echohelp
Fi
Until [$#-eq 0]
Todo
Tmpvorg=$1
Tmpv= ' echo "${tmpvorg}" | awk ' {printf '%s ', $} ' | TR ' [A-z] ' [A-z] '
if [$tmpV = "Start"-o $tmpV = "Restart"-o $tmpV = "Stop"]; Then
CMDNAME=${TMPV}
elif [$tmpV = "--help"-o $tmpV = "h"]; Then
Echohelp
Else
Oraclesid= $TMPVORG
Fi
Shift
Done
if ["x${cmdname}" = "X"]; Then
Echohelp
Fi
${cmdname}oracle
Export Oracle_sid=${env_oraclesid}