Linux下的Oracle启动脚本

下面为您介绍的是Oracle启动脚本,该Oracle启动脚本供您参考学习之用,希望可以让您对Oracle数据库有更深的了解。

  1. view plaincopy to clipboardprint?  
  2. #!/bin/sh     
  3.     
  4. cmdname="restart"     
  5. # get oracle sid information from env by default.     
  6. oracleSID=${ORACLE_SID}     
  7. env_oracleSID=${ORACLE_SID}     
  8.     
  9. function echohelp(){     
  10.   echo "******oracled Tool Helper******"     
  11.   echo "Usage:sh oracled [start|stop|restart] SIDs"     
  12.   echo "SIDs : seperated by comma"     
  13.   exit 5     
  14. }     
  15.     
  16. function startoracle(){     
  17.   echo "begin to start oracle ..."     
  18.     
  19.   lsnrctl start     
  20.   for curSID in `echo ${oracleSID} | awk 'BEGIN {RS=","}{ORS="n"}{print $1}'` ; do     
  21.     if [ "x${curSID}" = "x" ] ; then     
  22.       continue;     
  23.     fi     
  24.     export ORACLE_SID=${curSID}     
  25.     
  26. sqlplus /nolog <<EOF     
  27.     
  28. connect /as sysdba     
  29. startup     
  30. exit     
  31. exit     
  32.     
  33. EOF     
  34.     
  35.     echo "oracle DB [${curSID}] started OK."     
  36.   done     
  37. }     
  38. function stoporacle(){     
  39.   echo "begin to stop oracle ..."     
  40.     
  41.   for curSID in `echo ${oracleSID} | awk 'BEGIN {RS=","}{ORS="n"}{print $1}'` ; do     
  42.     if [ "x${curSID}" = "x" ] ; then     
  43.       continue;     
  44.     fi     
  45.     export ORACLE_SID=${curSID}     
  46.     
  47. sqlplus /nolog <<EOF     
  48.     
  49. connect /as sysdba     
  50. shutdown immediate     
  51. exit     
  52. exit     
  53.     
  54. EOF     
  55.     
  56.     echo "oracle DB [${curSID}] stopped OK."     
  57.   done     
  58.   lsnrctl stop     
  59. }     
  60. function restartoracle(){     
  61.   stoporacle     
  62.   startoracle     
  63. }     
  64.     
  65.     
  66. if [ $# -lt 1 ] ; then     
  67.   echohelp     
  68. fi     
  69.     
  70. until [ $# -eq 0 ]     
  71. do     
  72.   tmpVOrg=$1     
  73.   tmpV=`echo "${tmpVOrg}" | awk '{printf "%s",$1}' | tr '[A-Z]' '[a-z]'`     
  74.   if [ $tmpV = "start" -o $tmpV = "restart" -o $tmpV = "stop" ] ; then     
  75.     cmdname=${tmpV}     
  76.   elif [ $tmpV = "--help" -o $tmpV = "-h" ] ; then     
  77.     echohelp     
  78.   else    
  79.     oracleSID=$tmpVOrg     
  80.   fi     
  81.     
  82.   shift     
  83. done     
  84.     
  85. if [ "x${cmdname}" = "x" ] ; then     
  86.   echohelp     
  87. fi     
  88.     
  89. ${cmdname}oracle     
  90.     
  91. export ORACLE_SID=${env_oracleSID}     

相关文章

linux常用进程通信方式包括管道(pipe)、有名管道(FIFO)、...
Linux性能观测工具按类别可分为系统级别和进程级别,系统级别...
本文详细介绍了curl命令基础和高级用法,包括跳过https的证书...
本文包含作者工作中常用到的一些命令,用于诊断网络、磁盘占满...
linux的平均负载表示运行态和就绪态及不可中断状态(正在io)的...
CPU上下文频繁切换会导致系统性能下降,切换分为进程切换、线...