博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
71.8. Run level shell script to start Oracle 10g services on RedHat Enterprise Linux (RHAS 4)
阅读量:6608 次
发布时间:2019-06-24

本文共 3005 字,大约阅读时间需要 10 分钟。

 

#!/bin/bash
##############################################################
# Script to startup and shutdown Oracle and listener
# Author: neo - http://netkiller.8800.org
# File:/etc/rc.d/init.d/oracle
# chmod 750 /etc/init.d/oracle
# chkconfig --add oracle --level 0356
##############################################################
# Setup environment for script execution
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/10.2.0.1/
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH
export NLS_LANG='croatian_croatia.ee8iso8859p2'
export ORACLE_SID=orcl
export DISPLAY=:0
export USER=oracle
if [ -f ./home/oracle/.bash_profile ]; then
        ./home/oracle/.bash_profile
fi
# Determine and execute action based on command line parameter
# check Oracle db status
function chkdb_status() {
        # set username
        SUSER="scott"
        # set password
        SPASS="123456"
        sqlplus -s /nolog > /dev/null 2>&1 <<EOF
whenever sqlerror exit failure
connect $SUSER/$SPASS
exit success
EOF
        if [ $? -ne 0 ]; then
                echo "Connection failed : DB is down"
                exit 1
        else
                echo "Connection succeeded : DB is up"
fi
}
function isql {
        case "$1" in
                start)
                        echo  "*** Starting Oracle iSQL Plus *** "
                        su - $USER -c "$ORACLE_HOME/bin/isqlplusctl start"
                        echo "*** Note: You can access service at url:  http://$(hostname):5560/isqlplus"
                        ;;
                stop)
                        echo  "*** Stopping Oracle iSQL Plus *** "
                        su - $USER -c "$ORACLE_HOME/bin/isqlplusctl stop"
                        ;;
                *)
                        echo "Usage: $1 isql {start|stop}"
                        ;;
        esac
}
function sqlplus {
        case "$1" in
                start)
su - "$oracle_user"<<EOO
    lsnrctl start
    apachectl start
    sqlplus /nolog<<EOS
      connect / as sysdba
      startup
EOS
EOO
                        ;;
                stop)
su - "$oracle_user"<<EOO
    lsnrctl stop
    apachectl stop
    sqlplus /nolog<<EOS
      connect / as sysdba
      shutdown immediate
EOS
EOO
                        ;;
                *)
                        echo "Usage: $1 emctl {start|stop}"
                        ;;
        esac
}
function emctl {
        case "$1" in
                start)
                        echo  "*** Starting Oracle Enterprise Manager 10g Database Control ***"
                        su - $USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
                        echo "*** Note: You can access service at url:  http://$(hostname):1158/em"
                        ;;
                stop)
                        echo  "*** Stopping Oracle Enterprise Manager 10g Database Control ***"
                        su - $USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
                        ;;
                *)
                        echo "Usage: $1 emctl {start|stop}"
                        ;;
        esac
}
case "$1" in
        start)
                echo "Starting Oracle database(s) listed in /etc/oratab ..."
                sleep 2
                su - $USER -c "$ORACLE_HOME/bin/dbstart"
                echo "Starting TNS listener ..."
                sleep 2
                su - $USER -c "$ORACLE_HOME/bin/lsnrctl start"
                touch /var/lock/subsys/orcl
                ;;
        stop)
                echo "Shutting down TNS listener ..."
                sleep 2
                su - $USER -c "$ORACLE_HOME/bin/lsnrctl stop"
                echo "Shutting down Oracle database(s) listed in /etc/oratab ..."
                su - $USER -c "$ORACLE_HOME/bin/dbshut"
                rm -f /var/lock/subsys/orcl
                ;;
        status)
                chkdb_status
                ps -ax | grep -e ora_ -e tnslsnr
                ;;
        isql)
                isql $2
                ;;
        sqlplus)
                sqlplus $2
                ;;
        emctl)
                emctl $2
                ;;
        *)
                echo "Usage: $1 {start|stop|status}"
                echo
                echo "Usage: $1 [isql | sqlplus | emctl] {start|stop}"
                ;;
esac
exit 0
  
 

原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

你可能感兴趣的文章
国内外DNS服务器地址列表
查看>>
买电脑之受骗经历--与诸位共享,愿诸位多一个心眼
查看>>
Lind.DDD.Authorization用户授权介绍
查看>>
counting objects in class
查看>>
上海Uber优步司机奖励政策(2月1日~2月7日)
查看>>
第二章 JVM内存分配
查看>>
Codeforces Round #272 (Div. 2)
查看>>
Fragment中的setUserVisibleHint()方法调用
查看>>
获取、增加、修改、删除sqlserver字段描述及快速查看表字段与描述
查看>>
转FTP协议详解
查看>>
ABP源码分析三十八: ABP.Web.Api.OData
查看>>
WPF 虚拟化 VirtualizingWrapPanel 和 VirtualLizingTilePanel
查看>>
Redis快速入门
查看>>
nodejs 相关
查看>>
Diffie-Hellman密钥交换算法
查看>>
复制表结构和数据SQL语句
查看>>
JavaScript onkeydown事件入门实例(键盘某个按键被按下)
查看>>
免费开源的DotNet二维码操作组件ThoughtWorks.QRCode(.NET组件介绍之四)
查看>>
Unity进阶技巧 - 动态创建UGUI
查看>>
【简单易懂的AMV图文教程-2】VEGAS基础进阶——认识关键帧
查看>>