如何把oracle服务加到linux启动项

来源:互联网 发布:php 统计图 编辑:程序博客网 时间:2024/05/16 14:24

转自: http://www.cnblogs.com/HondaHsu/archive/2010/11/29/1890892.html


写个启动跟关闭ORACLE的SHELL放到/etc/init.d/下
然后ln -s 到rc0.d跟rc3.d下

设置oracle自动启动与关闭

1、编辑 /etc/oratab,把所有的 instance 的重启动标志设置成 'Y',如:
fstest:/oracle/product/10.2.0:Y
2、做一个启动oracle的脚本 /etc/init.d/dbora ,如下所示:

#!/bin/sh
# description: Oracle auto start-stop script.
# chkconfig: - 20 80
#
# 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/product/10.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/dbstart
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
;;
'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/lsnrctl stop"
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
;;
'restart')
$0 stop
$0 start
;;
esac

3、赋予执行权限
chmod 750 /etc/init.d/dbora
作成以下链接:
ln -s /etc/init.d/dbora/etc/rc0.d/K10dbora
ln -s /etc/init.d/dbora/etc/rc3.d/S99dbora
执行以下命令(设置执行级别):
chkconfig --level 345 dbora on

 

解决Linux上dbora启动脚本错误---env: /etc/init.d/dbora : no such file or directory

文章分类:数据库

如果你试图让dbora在linux上随系统自启动,并总是得到“no such file or directory”的错误提示信息,那么你可以尝试使用UltraEdit(其他工具如Dos2Unix也可以),文件--转换--DOS TO Unix。

附件为启动脚本,使用方法:

1、前提是你的服务器应该支持 LSB,没有就安装;

2、将脚本复制到 /etc/init.d/目录下,取名为dbora,当然,你肯定要根据自己的安装情况进行一些必要的修改;

3、配置

HOST-X:~ # /sbin/chkconfig -d dbora
HOST-X:~ # /sbin/chkconfig -a dbora
HOST-X:~ # reboot

重启后用top命令查看是否有dbora进程
0 0