啟動(dòng)腳本代碼

#!/bin/bash
#
# /etc/init.d/oracledb
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface
export ORACLE_HOME=/your/oracle/home/goes/here
export ORACLE_SID=oraclesidgoeshere
export PATH=$PATH:$ORACLE_HOME/bin
ORA_OWNR="oracleownergoeshere"
# if the executables do not exist -- display error
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
su $ORA_OWNR -c $ORACLE_HOME/bin/dbstart
touch /var/lock/oracle
su $ORA_OWNR -c “$ORACLE_HOME/bin/emctl start dbconsole”
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
su $ORA_OWNR -c $ORACLE_HOME/bin/dbshut
rm -f /var/lock/oracle
su $ORA_OWNR -c “$ORACLE_HOME/bin/emctl stop dbconsole”
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac
exit 0

//script中有兩行的引號(hào)有問(wèn)題.把引號(hào)改一下.就可以.
另原腳本中無(wú)isqlplus的啟動(dòng).可自行加入:
su $ORA_OWNR -c “$ORACLE_HOME/bin/isqlplusctl start”
su $ORA_OWNR -c “$ORACLE_HOME/bin/isqlplusctl stop”
如不加入從客戶端瀏覽器中無(wú)法訪問(wèn).也可以手動(dòng)啟動(dòng).
將這個(gè)文件放到指定的位置并讓它可執(zhí)行, 將它連接到所有的運(yùn)行級(jí):
#chmod 755 /etc/init.d/oracledb
#update-rc.d oracledb defaults 99
如果你希望在系統(tǒng)啟動(dòng)時(shí)啟動(dòng)你創(chuàng)建的所有數(shù)據(jù)庫(kù)實(shí)例,那么需要修改
/etc/oratab 文件. 下面是一個(gè)例子:
oracle:/opt/oracle/:N
修改為
oracle:/opt/oracle:Y