在Linux 啟動時自動啟動Oracle 10g多個執行個體資料庫的方法

來源:互聯網
上載者:User

在Linux 啟動時自動啟動Oracle 10g多個執行個體資料庫的方法:

# description: start or stop oracle
. /etc/rc.d/init.d/functions
#oracle_env
export ORACLE_BASE=/u01/app/oracle/db10g
export ORACLE_HOME=$ORACLE_BASE/db10g
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=twerp
oracle_user=oracle
#killproc
start(){
echo -n "starting oracle: "
su - "$oracle_user"<<EOO
lsnrctl start
sqlplus /nolog <<EOS
connect /as sysdba
startup
EOS
#exchange ORACLE_SID
export ORACLE_SID=twwh
sqlplus /nolog <<EOS
connect /as sysdba
startup
EOS
EOO
}
stop(){
echo -n "stoping oracle: "
su - "$oracle_user"<<EOO
lsnrctl stop
sqlplus /nolog <<EOS
connect /as sysdba
shutdown immediate
EOS
#exchange ORACLE_SID
export ORACLE_SID=twwh
sqlplus /nolog <<EOS
connect /as sysdba
shutdown immediate
EOS
EOO
}
case "$1" in
start)
start
touch /var/lock/subsys/orad
;;
stop)
stop
rm -f /var/lock/subsys/orad
;;
status)
status oracle
;;
restart)
stop
sleep 3
start
;;
*)
echo "$0 {start|stop|status|restart}"
;;
esac
將此指令碼cp到/etc/rc.d/init.d/目錄下
加上可執行許可權:
chmod 755 /etc/rc.d/init.d/orad
發布:
chkconfig --add orad
或用chmod a+x ora9,將這個指令碼加入到系統中使其可開機運行,那麼要運行以下命令:
chkconfig --level 3(或者是5) --add ora9

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.