国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > Oracle > 正文

Oracle的標準系統(tǒng)服務(wù)腳本-for Linux

2024-08-29 13:40:35
字體:
供稿:網(wǎng)友

  一、所謂標準系統(tǒng)服務(wù),應(yīng)該是滿足以下幾條標準的后臺運行程序。
  
  1) 用chkconfig --add來安裝,用chkconfig --list檢查狀態(tài)。
  
  2) 用ntsysv來定制某個服務(wù),是否伴隨機器的啟動而自動啟動。
  
  3) 在圖形模式下,可以用serviceconf來啟動、停止、重啟服務(wù)。
  
  4) 開機象系統(tǒng)服務(wù)那樣顯示starting,關(guān)機顯示shutting down。
  
  二、下面是具體的dbora腳本,在Redhat 7.3上通過,本人已經(jīng)驗證了幾十次,保證能運行。
  
  備注:啟動lsnrctl的時候不用su- 而使用su,否則失敗,并且要求使用Oracle用戶本身的BASH_ENV.腳本開頭的幾個ORA_xxx參數(shù)都要依照實際情況寫,否則會說找不到Oracle程序或者pid.DOS格式方便發(fā)文,拷下來后請大家用UltraEdit轉(zhuǎn)為Unix格式。
  
  ------------------------------------------------------------------------
  
  代碼:
  
  #!/bin/bash
  #
  # /etc/rc.d/init.d/dbora
  #
  # Starts the dbora daemon
  #
  # chkconfig: 345 94 6
  # description: Runs commands scheduled by the at command at the time
  # specified when at was run, and runs batch commands when the load
  # average is low enough.
  # PRocessname: dbora
  #
  # copyright: Written by Wwashington AT smth bbs, free to distribute.
  # You must keep everything in this file, including the copyright
  # announcement. Study demo: atd & postgresql in /etc/rc.d/init.d
  
  # Source function library.
  INITD=/etc/rc.d/init.d
  . $INITD/functions
  
  # Source system profile.
  if [ -r /etc/profile ] ; then . /etc/profile ; fi
  
  ORA_SID=udb01
  ORA_USER=oracle
  ORA_BASE=/udb01/app/oracle
  ORA_HOME=/udb01/app/oracle/prodUCt/8.1.7
  BASH_ENV=$ORA_BASE/.bashrc
  
  test -x $ORA_HOME/bin/dbstart exit 0
  RETVAL=0
  
  GREP_UNIX=`uname awk '{if($1 ~ /(^SunOS^HP-UX)/) print $1}'`
  if ! [ "$GREP_UNIX" = "" ]
  then
  GREP_FLAG=ef
  else
  GREP_FLAG=efw
  fi
  
  RUNLEVEL=`runlevel awk '{ print $2 }'`
  # RUNLEVEL=6
  
  case "$RUNLEVEL" in
  3)
  SH_FLAG=1
  ;;
  4)
  SH_FLAG=1
  ;;
  5)
  SH_FLAG=1
  ;;
  *)
  SH_FLAG=0
  ;;
  esac
  
  # Below is a debug info to display Show Flag
  # echo RUNLEVEL=$RUNLEVEL , SH_FLAG=$SH_FLAG
  
  #
  # See how we were called.
  #
  
  prog="dbora"
  
  start() {
  # Check flag, if dbora already started, quit dbora
  if [ ! -f /var/lock/subsys/dbora ]; then
  echo -n $"Starting $prog: "
  
  # This is the background exec which can work under
  # both CLI (dbora) and GUI mode (serviceconf). We
  # must forward stderr to a file or null, otherwise
  # dbora won't start with a return code in GUI mode
  echo ""
  echo "[oralog] ----->"
  echo "Starting Oracle8i: "
  echo "-------------------------------------------------------------------------"
  # Please note that forward stderr(2) to /dev/null or &- means close stderr
  su - $ORA_USER -c "$ORA_HOME/bin/dbstart > /tmp/ORA-dbuplog" 2>/dev/null
  if [ $SH_FLAG -eq 1 ]; then
  cat /tmp/ORA-dbuplog
  fi
  echo
  echo "Starting TNS Listener:"
  echo "-------------------------------------------------------------------------"
  su $ORA_USER -c "$ORACLE_HOME/bin/lsnrctl start > /tmp/ORA-lsnrlog" 2>&-
  if [ $SH_FLAG -eq 1 ]; then
  cat /tmp/ORA-lsnrlog
  fi
  
  pid=`pidof -s ora_pmon_$ORA_SID`
  if [ "$pid" == "" ]; then
  RETVAL=1;
  else
  RETVAL=0;
  fi
  
  [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dbora
  echo
  fi
  return $RETVAL
  }
  
  stop() {
  echo -n $"Stopping $prog: "
  
  # In order to use database local cmd to keep safe,
  # we use dbshut instead of simply kill ora_ proc.
  # When we reboot (runlevel = 0 or 6), no verbose.
  # Force remove /var/lock/subsys/dbora to activate
  if [ $SH_FLAG -eq 1 ]; then
  echo ""
  echo "[oralog] ----->"
  echo "Shutting down TNS Listener:"
  echo "-------------------------------------------------------------------------"
  su $ORA_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
  else
  su $ORA_USER -c "$ORACLE_HOME/bin/lsnrctl stop > /dev/null"
  fi
  if [ $SH_FLAG -eq 1 ]; then
  echo
  fi
  if [ $SH_FLAG -eq 1 ]; then
  echo "Shutting down Oracle8i: "
  echo "-------------------------------------------------------------------------"
  su - $ORA_USER -c "$ORA_HOME/bin/dbshut"
  else
  su - $ORA_USER -c "$ORA_HOME/bin/dbshut > /dev/null"
  fi
  
  pid=`ps -$GREP_FLAG grep -e ora_ -e lsnr grep -v grep awk '{ print $2 }'`
  # Show pids when shutdown failed, to see debug info
  # echo $pid
  
  if [ $pid ]; then
  failure ""
  else
  success ""
  fi
  echo ""
  rm -f /var/lock/subsys/dbora
  return $RETVAL
  }
  
  restart() {
  echo "Restarting Oracle8i and Listener: "
  echo "========================================================================="
  stop
  start
  }
  
  reload() {
  restart
  }
  
  status_ol() {
  echo "Checking Oracle8i and Listener: "
  echo "========================================================================="
  su - $ORA_USER -c "$ORA_HOME/bin/dbstat"
  }
  
  case "$1" in
  start)
  start
  ;;
  stop)
  stop
  ;;
  reloadrestart)
  restart
  ;;
  condrestart)
  if [ -f /var/lock/subsys/dbora ]; then
  restart
  fi
  ;;
  status)
  status_ol
  ;;
  *)
  echo $"Usage: $0 {startstoprestartcondrestartstatus}"
  exit 1
  esac
  
  exit $?
  exit $RETVAL
  
  剛才的文件是 /etc/rc.d/init.d/dbora,現(xiàn)在補充一個,$ORACLE_HOME/bin/dbstat
  
  GREP_UNIX=`uname awk '{if($1 ~ /(^SunOS^HP-UX)/) print $1}'`
  
  if !
[ "$GREP_UNIX" = "" ]
  then
  GREP_FILE=/usr/XPg4/bin/grep
  GREP_FLAG=ef
  else
  GREP_FILE=/bin/grep
  GREP_FLAG=efw
  fi
  echo
  echo "# ps -$GREP_FLAG $GREP_FILE -e ora_ -e lsnr grep -v grep"
  echo
  ps -$GREP_FLAG $GREP_FILE -e ora_ -e lsnr grep -v grep
  echo

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 闻喜县| 彭阳县| 射阳县| 丰城市| 峡江县| 页游| 修水县| 青铜峡市| 绥德县| 桑日县| 凉城县| 黎川县| 蓬莱市| 阳曲县| 宁陕县| 咸丰县| 武鸣县| 镇江市| 封丘县| 甘肃省| 驻马店市| 嵊泗县| 监利县| 景德镇市| 河北省| 莆田市| 龙泉市| 枣强县| 鹿泉市| 庆阳市| 江达县| 乐昌市| 峡江县| 西和县| 扎赉特旗| 鄯善县| 贵德县| 布尔津县| 桓仁| 钦州市| 宿松县|