Linux下oracle自启动

文档详见:http://www.oracle-base.com/articles/linux/AutomatingDatabaseStartupAndShutdownOnLinux.php

 

[root@localhost oracle]# vim /etc/oratab

$ORACLE_SID:$ORACLE_HOME:Y

[root@localhost oracle]# vim /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=$ORACLE_HOME
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
        touch /var/lock/subsys/dbora
        ;;
    '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"
        rm -f /var/lock/subsys/dbora
        ;;
esac

[root@localhost oracle]# chmod 750 /etc/init.d/dbora

[root@localhost oracle]# chkconfig --add dbora

在chkconfig时,若出现bash: chkconfig: command not found

[root@localhost oracle]# rpm -aq |grep chkconfig
chkconfig-1.3.30.2-2.el5
[root@localhost oracle]# export PATH=/sbin:$PATH
[root@localhost oracle]# chkconfig

 应该可以了,重启系统吧!

你可能感兴趣的:(oracle,linux,服务,自启动)