在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