您的位置:首页 > 数据库 > Oracle

Linux 上设置Oracle DB开机自动启动

2008-07-22 15:17 1176 查看
Linux : CentOS-5

Oracle: 10.2.0.1.0

--------------设置 Linux 上Oracle 自动启动 20080722--------------------------------

1、首先在/etc/rc.d/init.d/目录下配置Oracle的服务文件。

su - root

vi oracledb

将最后的附件脚本贴入

chmod 775 oracledb

2、使用root用户修改:

[root@localhost init.d]# vi /etc/oratab

catlogdb:/oracle/product/10.2.0/db_1:Y

将最后的N改为Y

3、使用ORACLE用户修改$ORACLE_HOME/bin/dbstart文件

[root@localhost init.d]# su - oracle

[oracle@localhost ~]$ cd $ORACLE_HOME/bin

[oracle@localhost bin]$ vi dbstart

找到 ORACLE_HOME_LISTNER 这行, 修改成:

ORACLE_HOME_LISTNER=/oracle/product/10.2.0/db_1

或者直接修改成:

ORACLE_HOME_LISTNER=$ORACLE_HOME

测试运行 dbshut, dbstart 看能否启动ORACLE 服务及listener服务:

[oracle@localhost bin]$ ps -ef|grep ora_

[oracle@localhost bin]$ lsnrctl status

4、创建服务

chkconfig --add oracledb

service oracledb does not support chkconfig

在脚本中以下两行必须存在

# chkconfig: 345 99 10

# description: script for the Oracle Instance, Listener

[root@localhost ~]# chkconfig --list oracledb

oracledb 0:off 1:off 2:off 3:on 4:on 5:on 6:off

------------------------------------------------------------------------

--附件oracledb 脚本

#!/bin/bash

#

# chkconfig: 345 99 10

# description: script for the Oracle Instance, Listener

# /etc/init.d/oracledb

#

export ORACLE_HOME=/oracle/product/10.2.0/db_1

export ORACLE_SID=catlogdb

export PATH=$PATH:$ORACLE_HOME/bin

ORA_OWNR=oracle

# if the executables do not exist -- display error

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]

then

echo "Oracle startup: cannot start"

exit 1

fi

# depending on parameter -- startup, shutdown, restart

# of the instance and listener or usage display

case "$1" in

start)

# Oracle listener and instance startup

echo -n "Starting Oracle: "

su $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"

su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"

touch /var/lock/oracle

su $ORA_OWNR -c $ORACLE_HOME/bin/emctl start dbconsole

echo "OK"

;;

stop)

# Oracle listener and instance shutdown

echo -n "Shutdown Oracle: "

su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"

su $ORA_OWNR -c $ORACLE_HOME/bin/dbshut

rm -f /var/lock/oracle

su $ORA_OWNR -c $ORACLE_HOME/bin/emctl stop dbconsole

echo "OK"

;;

reload|restart)

$0 stop

$0 start

;;

****)

echo "Usage: `basename ` start|stop|restart|reload"

exit 1

esac

exit 0

------------------备注说明---------------------------------

# chkconfig: 345 99 10

指出3,4,5级别启动这个服务,99是在相应的/etc/rc.d/rcN.d(N为前面指定的

级别,这里是345)目录下生成的链接文件的序号(启动优先级别)S99oradbstart,

10为在除前面指出的级别对应的/etc/rc.d/rcN.d(N为除345之外的级别)目录生成的

链接文件的序号(服务停止的优先级别)K10oradbstart

撤销服务的话:chkconfig --del oracledb
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: