Start Oracle server when system boot

来源:互联网 发布:淘宝店名字 编辑:程序博客网 时间:2024/06/02 05:32
1. 生成脚本/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=/usr/oracle/db10g
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
        su - $ORA_OWNER -c "$ORA_HOME/bin/emctl start dbconsole"
        su - $ORA_OWNER -c "$ORA_HOME/bin/isqlplusctl 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/isqlplusctl stop"
        su - $ORA_OWNER -c "$ORA_HOME/bin/emctl stop dbconsole"
        su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
        #su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
        ;;
esac

2. 配置服务
赋予执行权限
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

这样就OK了。下次开关机的时候,Oracle也会随之启动/停止。

3. 修改/etc/oratab

/***********************************************

/* /etc/oratab

/***********************************************

/etc/oratab:

orcl:/usr/work/oracle/10.2.0/db_1:Y


Note: run dbstart to start up the oracle instance if above database set to "Y"



4. Issues

Question: dbstart problem: "Failed to auto-start Oracle Net Listener using /ade/vikrKuma_new/oracle/bin/tnslsnr". This problem usually happend when DHCP is used.

Fix:

Edit file $ORACLe_HOME/bin/dbstart

In line 78, replace the line with:

"ORACLE_HOME_LISTNER=$ORACLE_HOME"


原创粉丝点击