下面為您介紹的是Oracle啟動腳本,該Oracle啟動腳本供您參考學習之用,希望可以讓您對Oracle數據庫有更深的了解。
- vIEw plaincopy to clipboardprint?
- #!/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 $1}'` ; do
- 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 $1}'` ; do
- 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 ]
- do
- tmpVOrg=$1
- tmpV=`echo "${tmpVOrg}" | awk '{printf "%s",$1}' | 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}