在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
使用chmod命令设置权限为750:
| chmod 750 /etc/init.d/dbora |
使用下面的命令配合适当的运行级别设置dbora服务自动启动:
| chkconfig --level 345 dbora on |
这样有关的实例就会随系统的启动而启动了。
这个方法仍然适用于Oracle10g和11g,使用正确的路径对ORA_HOME变量做一下改动,并将其添加到dbstart和dbshut末尾的行,在Oracle10gR2下可以移除启动和停止监听器的行了,因此dbstart命令包括启动监听器。
#!/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/10.2.0/db_1
#ORA_HOME=/u01/app/oracle/product/11.1.0/db_1
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/dbstart $ORA_HOME"
;;
'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"
;;
esac
相关专题
- Linux集群技术 (9343篇文章)
- 体验Linux的音影世界 (9007篇文章)
- Linux驱动大全 (9837篇文章)
- Linux下的路由的配置与应用 (12953篇文章)
- Linux命令简介 (10944篇文章)
- 数据库专栏 (5488篇文章)
- 数据库处理专题 (9294篇文章)
- 城域网专题 (8265篇文章)
- 数据库安全技术专题 (13949篇文章)
- Linux防火墙 (10718篇文章)
- Ubuntu 8.04 中开启3D桌面特效与设置方法 (498次浏览)
- Ubuntu发烧友三部曲 进阶篇 (183次浏览)
- 七大操作系统一季度漏洞比拼 (130次浏览)
- 用 Wubi 安装 Ubuntu 8.04 只需五步 (115次浏览)
- 实用技巧 从硬盘安装Fedora-9-i386-DVD (106次浏览)
- Ubuntu 8.04 使用感受及思考 (102次浏览)
- 随身系统:Puppy Linux 4.00 初体验 (80次浏览)
- ubuntu8.04桌面边框的美化 (76次浏览)
- Ubuntu 8.04 中的彩蛋(图) (75次浏览)
- ubuntu 8.04中文环境解决方法 (72次浏览)



