Linux/UNIX環境下Oracle資料庫多執行個體開機啟動指令碼

來源:互聯網
上載者:User

標籤:blog   http   os   ar   for   檔案   資料   art   on   

作業系統平台:RHEL 5
Shell環境:Bash
Oracle:10g2

功能描述:開機時自動切換到oracle使用者下,啟動oracle的多個執行個體。並記錄資料庫的啟動情況到自訂的記錄檔中。

#!/bin/bash

LOG_PATH=$HOME/oracle_initing.log
log() {
if [ $# -lt 1 -a $# -gt 1 ];then
exit 5
fi
case "[email protected]" in
success)
echo `date +%b" "%d" "%T`" "$PRO": Oracle instence \"$ORACLE_SID\" starting up succefully" >> $LOG_PATH;;
failed)
echo `date +%b" "%d" "%T`" "$PRO": Oracle instence \"$ORACLE_SID\" starting up FAILED" >> $LOG_PATH;;
*)
echo `date +%b" "%d" "%T`" "$PRO": "[email protected] >> $LOG_PATH;;
esac
}
lsstart() {
# stop stopping
# start starting
lsnrctl >> $LOG_PATH <<EOF
status
start
exit
EOF
}
init_oracle() {
#lsstart stop the listen
# lsstart
HOSTNAME=`hostname |awk -F. ‘{print $1}‘`
PRO=$0
ORACLE_SIDS=`sed -rn ‘/^([^#].*):/!d;p‘ /etc/oratab |awk -F: ‘{printf $1" "}‘`
if [ -z "$ORACLE_SIDS" ] ;then
exit 2
else
echo $ORACLE_SIDS
for ORACLE_SID in $ORACLE_SIDS
do
# echo $ORACLE_SID
#start or stop the oracle databases
# startup
# shutdown immediate
if sqlplus -S /nolog >> $LOG_PATH <<EOF
conn / as sysdba
startup
EOF
then
log success
continue
else
log failed
exit 3
fi
done
fi
}
if [ $"$UID" -eq 0 ] ;then
su - oracle
init_oracle
#lsstart start the listen
# lsstart
exit 0
elif [ "$USER" = "oracle" ] ;then
init_oracle
#lsstart start the listen
# lsstart
exit 0
else
exit 4
fi

http://wangxiaoyu.blog.51cto.com/922065/197630

Linux/UNIX環境下Oracle資料庫多執行個體開機啟動指令碼(轉)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.