環境
Oracle Enterprise Linux 5Oracle Database 10g R2
Oracleの自動起動に必要なファイル
/etc/oratab インスタンスの定義ファイル/etc/init.d/dbora サービスのスクリプト
$ORACLE_HOME/bin/dbstart DB起動スクリプト
$ORACLE_HOME/bin/dbstop DB停止スクリプト
oratab
/etc/oratab を編集し、インスタンスを自動起動に設定する。$ORACLE_SID:$ORACLE_HOME:[Y|N] ←Y:自動起動
orcl:/opt/oracle/product/10.2/db_1:Y
dbora
以下のスクリプトを /etc/init.d/dbora に保存(リスナーはdbstartが起動するため、dboraでは起動しない)
#!/bin/sh
#
# chkconfig: 345 99 10
# description: Oracle Database 10g R2
# proccessname: ora_
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
ORA_HOME=/opt/oracle/product/10.2/db_1
ORA_OWNER=oracle
export ORACLE_HOME=$ORA_HOME
if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_HOME ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
start)
# Start the Oracle databases:
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart"
# Start Oracle Net
#su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
# Start emctl
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole"
touch /var/lock/subsys/dbora
;;
stop)
# Stop Oracle Net
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
# Stop the Oracle databases:
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut"
# Stop emctl
su - $ORA_OWNER -c "$ORA_HOME/bin/emctl stop dbconsole"
rm -f /var/lock/subsys/dbora
;;
restart)
$0 stop
$0 start
;;
status)
if [ -f /var/lock/subsys/dbora ]; then
echo $0 started.
else
echo $0 stopped.
fi
;;
*)
echo "usage: dbora {start|stop|restart|status}"
exit 1
esac
exit 0
以下のコマンドを実行し、自動起動を登録する。
# chmod 755 /etc/init.d/dbora
# chkconfig --add dbora
# chkconfig dbora on
# chkconfig --list dbora
dbora 0:off 1:off 2:on 3:on 4:on 5:on 6:off
dbstart
# /etc/init.d/dbora start上記エラーの解消のため、$ORACLE_HOME/bin/dbstart (78行目)を修正する。
Failed to auto-start Oracle Net Listene using /ade/vikrkuma_new/oracle/bin/tnslsnr
Processing Database instance "Ora10gTest": log file /opt/oracle/product/10.2/db_1/startup.log
修正前:ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle
修正後:ORACLE_HOME_LISTNER=$ORACLE_HOME
手動起動
起動# /etc/init.d/dbora start停止
# /etc/init.d/dbora stop
ログ出力
dboraスクリプトの実行ログは$ORACLE_HOME配下に出力される。shutdown.log
startup.log