我遇到了几个Linux启动脚本的问题,特别是那些启动我的Oracle 10g数据库和我的oc4j容器的脚本。
我已经使用chkconfig告诉Linux在容器之前启动数据库,但是,似乎容器在oc4j根本不喜欢的数据库之前启动。我可以访问我的应用程序,但是,我没有数据库连接。如果我重新启动oc4j,一切正常。
有没有办法可以“暂停”oc4j的启动,直到数据库(和监听器)都启动并准备连接?
答案 0 :(得分:1)
将它们放入1个启动脚本中?
start listener
start database
start appserver
这是我的/etc/init.d/dbora脚本。添加调用以启动OC4J
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# 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=/app/oracle/product/10.2.0/db_1
ORA_OWNER=oracle
echo $1
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
su - $ORA_OWNER -c $ORA_HOME/bin/emctl start dbconsole
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c $ORA_HOME/bin/emctl stop dbconsole
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
;;
esac