zoukankan      html  css  js  c++  java
  • linux手动或者自动启动oracle11g的服务 Oracle 自动启动脚本

    手动启动:

    [oracle@localhost ~]$ sqlplus

     

    SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 26 23:39:52 2014

     

    Copyright (c) 1982, 2009, Oracle.  All rights reserved.

     

    Enter user-name: sys as sysdba

    Enter password:

    Connected to an idle instance.

     

    SQL> startup

    ORACLE instance started.

     

    Total System Global Area  496881664 bytes

    Fixed Size              2214696 bytes

    Variable Size                377488600 bytes

    Database Buffers      113246208 bytes

    Redo Buffers                 3932160 bytes

    Database mounted.

    Database opened.

    SQL>

     

    Oracle 自动启动脚本

    1. 修改Oracle系统配置文件:/etc/oratab,只有这样,Oracle 自带的dbstart和dbshut才能够发挥作用。N修改为Y

    vi /etc/oratab
    orcl:/ /home/oracle/app/oracle/product/11.2.0/dbhome_1:Y

    # Entries are of the form:
    #   $ORACLE_SID:$ORACLE_HOME:<N|Y>:

     

    修改vi /etc/init.d/oracle

    如已存在需要检查

    ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1

    对不对。

    不存在的话把以下内容加入:

    #!/bin/sh

    #chkconfig: 2345 20 80

    #description: Oracle dbstart / dbshut

    #以上两行为chkconfig所需

    ORA_HOME=/home/ oracle /app/oracle/product/11.2.0/dbhome_1

    ORA_OWNER= oracle

    LOGFILE=/var/log/oracle.log

    echo "#################################" >> ${LOGFILE}

    date +"### %T %a %D: Run Oracle" >> ${LOGFILE}

    if [ ! -f ${ORA_HOME}/bin/dbstart ] || [ ! -f ${ORA_HOME}/bin/dbshut ]; then

        echo "Error: Missing the script file ${ORA_HOME}/bin/dbstart or ${ORA_HOME}/bin/dbshut!" >> ${LOGFILE}

        echo "#################################" >> ${LOGFILE}

        exit

    fi

    start(){

        echo "###Startup Database..."

        su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbstart ${ORA_HOME}"

        echo "###Done."

        echo "###Run database control..."

        su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl start dbconsole"

        echo "###Done."

    }

    stop(){

        echo "###Stop database control..."

        su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl stop dbconsole"

        echo "###Done."

        echo "###Shutdown Database..."

        su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbshut ${ORA_HOME}"

        echo "###Done."

    }

    case "$1" in

        'start')

            start >> ${LOGFILE}

        ;;

        'stop')

            stop >> ${LOGFILE}

        ;;

        'restart')

            stop >> ${LOGFILE}

            start >> ${LOGFILE}

        ;;

    esac

    date +"### %T %a %D: Finished." >> ${LOGFILE}

    echo "#################################" >> ${LOGFILE}

    echo ""

     

    3. 改变文件权限
    chmod 755 /etc/init.d/oracle

    4. 添加服务
    chkconfig --level 35 oracle on

    5. 测试

    重启系统sqlplus查看

    6. 使用方法
    # service oracle start        //启动oracle
    # service oracle stop        //关闭oracle
    # service oracle restart     //重启oracle

  • 相关阅读:
    Python 性能剖分工具
    串口编程
    拼音输入法实现
    Android 第三方分享中遇到的问题以及解决方案
    linux C 获取与修改IP地址
    git拉取远程分支并创建本地分支
    再次探讨企业级开发中的Try......Catch性能问题
    [手游新项目历程]-38-Supervisord守护进程
    公务员考试
    概念的内涵和外延
  • 原文地址:https://www.cnblogs.com/jhlong/p/5442463.html
Copyright © 2011-2022 走看看