视频图像处理系列索引 || Arcgis/Engine/Server开发索引 || Web Map Gis开发索引 || jquery表格组件 JQGrid索引
WPF MVVM模式开发实现简明教程索引 || ArcGIS Runtime WPF(.net C#)开发简明教程索引

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

posted @ 2016-04-28 14:03  jhlong  阅读(512)  评论(0编辑  收藏  举报
海龙的博客 jhlong@cnblogs 版权所有© 转载请注明链接.有用请推荐一下
代码全部经过本人测试,但不保证复制粘贴就正常运行,更不保证能解决你的问题,请结合前后代码及描述理解后修改和使用