您现在的位置: 万盛学电脑网 >> 程序编程 >> 数据库 >> oracle教程 >> 正文

在Linux上自动启动和关闭Oracle数据库(9i/10g/11g)

作者:佚名    责任编辑:admin    更新时间:2022-06-22

在Oracle 1gR2或更高版本下使用RAC或ASM时,Oracle Clusterware会自动启动和停止Oracle数据库实 例,因此下面的过程不是必需的,对于其他情况,你就可以使用下面描述的方法了。

◆su命令

下面的描述是Oracle建议采用的自动启动和关闭Oracle 9i实例的方法。

一旦实例创建好后,标记/etc/oratab文件设置每个实例的重启标志为“Y”:

TSH1:/u01/app/oracle/product/9.2.0:Y

接下来,作为root用户登陆创建一个叫做/etc/init.d/dbora的文件,包括下面的内容:

#!/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=/u01/app/oracle/product/9.2.0
ORA_OWNER=oracle
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
;;
'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
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
;;
esac

  • 共4页:
  • 上一页
  • 1
  • 2
  • 3
  • 4
  • 下一页