oracle 11g 开机服务启动

一、修改/etc/oratab
#orcl:/u01/app/oracle/product/11gr2:N orcl:/u01/app/oracle/product/11gr2:Y 将“N”改为“Y”
二、修改/u01/app/oracle/product/11gr2/bin目录下dbstart和dbshut
[oracle@localhost bin]$ vim dbstart

将注释去掉
 ORATAB=/etc/oratab
将ORACLE_HOME_LISTNER=$1改为oracle的安装目录
ORACLE_HOME_LISTNER=/u01/app/oracle/product/11gr2
将“echo "Processing $INST \"$ORACLE_SID\": log file $ORACLE_HOME/startup.log"”注释

[oracle@localhost bin]$ vim dbstart 

将注释去掉
 ORATAB=/etc/oratab
将ORACLE_HOME_LISTNER=$1改为oracle的安装目录
ORACLE_HOME_LISTNER=/u01/app/oracle/product/11gr2
在“LOG=$ORACLE_HOME/shutdown.log”下添加“chmod 766 $LOG”
LOG=$ORACLE_HOME/shutdown.log
chomod 766 $LOG

三、添加oracle到系统服务
vim /etc/rc.d/init.d/oracle
[root@localhost ~]# vim /etc/rc.d/init.d/oracle 

     # Oracle listener and instance shutdown
#!/bin/sh
# chkconfig: 345 61 61
# description: Oracle 11g AutoRun Services
# /etc/init.d/oracle
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11gr2
export ORACLE_SID=ORCL
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
     su $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart
     echo "Oracle Started!"
     sleep 1
     ;;
 stop)
     # Oracle listener and instance shutdown
     su $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut
     echo "Oracle Stoped!"
     sleep 1
     ;;
 status)
        STAT=`ps -ef|grep dbw0|grep -v grep |awk -F' ' '{print($8)}'|awk -F'_' '{print $2}'`
        if [ -z $STAT ];then
          echo "Oracle is not running"
        else
          echo "Oracle is running"
        fi

     ;;
 reload|restart)
     $0 stop
     $0 start
     ;;
 *)
     echo $"Usage: `basename $0` {start|stop|reload|reload}"
     exit 1
esac
exit 0

 

[root@localhost ~]# chkconfig --add oracle
[root@localhost ~]# chkconfig oracle on





验证
[root@localhost ~]# service oracle stop
Oracle Stoped!
[root@localhost ~]# service oracle status
Oracle is not running
[root@localhost ~]# service oracle start
Oracle Started!
[root@localhost ~]# service oracle status
Oracle is running







 

posted on 2015-08-29 22:40  侯志清  阅读(255)  评论(0编辑  收藏  举报

导航