平台:Redhat AS 4、5
数据库版本:Oracle 10g 11g
今天重启服务器时候,突然发现数据库不能随服务关闭自动关闭,直接被killall了。原来一直没注意 ,自动启动脚本还有这毛病。
经过对比检查,发现能自动启动并正常关闭的数据库的服务每次启动都会在/var/lock/subsys目录中生成跟服务名字相同的一个lock文件。
于是,编辑启动脚本如下:
#!/bin/sh
# chkconfig: 2345 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= 你的Oracle_HOME
ORA_OWNER= 你的ORA_OWNER
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/dbstart $ORA_HOME"
touch /var/lock/subsys/oracle
;;
'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/dbshut $ORA_HOME"
rm -rf /var/lock/subsys/oracle
;;
esac
带颜色部分为添加内容。
数据库版本:Oracle 10g 11g
今天重启服务器时候,突然发现数据库不能随服务关闭自动关闭,直接被killall了。原来一直没注意 ,自动启动脚本还有这毛病。
经过对比检查,发现能自动启动并正常关闭的数据库的服务每次启动都会在/var/lock/subsys目录中生成跟服务名字相同的一个lock文件。
于是,编辑启动脚本如下:
#!/bin/sh
# chkconfig: 2345 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= 你的Oracle_HOME
ORA_OWNER= 你的ORA_OWNER
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/dbstart $ORA_HOME"
touch /var/lock/subsys/oracle
;;
'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/dbshut $ORA_HOME"
rm -rf /var/lock/subsys/oracle
;;
esac
带颜色部分为添加内容。