专注各种脚本编程
Baidu
加入收藏夹
本站内容有下面分类知识,欢迎您的到来^_^
shell相关:指令篇 基础篇 脚本欣赏 编程实例 shell问问 shell视频教程 技巧篇 水平测试 E文资料 vi编辑器 高级Bash脚本编程指南
其他:mysql perl c语言 oracle
当前位置:| 主页>shell脚本欣赏>

shell脚本实现在Radhat Enterprise Linux(RHAS4)上启动Oracle 10g服务

百度收藏 QQ搜藏

原文:http://bash.cyberciti.biz/misc-shell/linux-start-stop-restar-toracle-server/

脚本功能介绍:
1)启动/停止下面系列服务:
Oracle/Oracle iSQL Plus/Oracle Enterprise Manager 10g Database Control
2)查看oracle运行状态

应用操作系统平台:Radhat Enterprise Linux
以下是该shell脚本的源代码:

#!/bin/bash
#
# Run level script to start Oracle 10g services on RedHat Enterprise Linux (RHAS 4)
# Script should work on other UNIX like oses :)
# -------------------------------------------------------------------------
# Copyright (c) 2006 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# chkconfig: 345 91 19
# description: Startup/Shutdown Oracle service
 
OUSER="oracle"
OPATH="/home/oracle/oracle/product/10.2.0/db_1"
 
# 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
}
 
case "$1" in
        start)
        echo  "*** Starting Oracle *** "
        su - $OUSER -c "$OPATH/bin/lsnrctl start"
        su - $OUSER -c "$OPATH/bin/dbstart"
        ;;
        stop)
        echo  "*** Stopping Oracle *** "
        su - $OUSER -c "$OPATH/bin/lsnrctl stop"
        su - $OUSER -c "$OPATH/bin/dbshut"
        ;;
        restart)
        $0 stop
        $1 start
        ;;
        isqlstart)
        echo  "*** Starting Oracle iSQL Plus *** "
        su - $OUSER -c "$OPATH/bin/isqlplusctl start"
        echo "*** Note: You can access service at url:  http://$(hostname):5560/isqlplus"
        ;;
        isqlstop)
        echo  "*** Stopping Oracle iSQL Plus *** "
        su - $OUSER -c "$OPATH/bin/isqlplusctl stop"
        ;;
        emstart)
        echo  "*** Starting Oracle Enterprise Manager 10g Database Control ***"
        su - $OUSER -c "$OPATH/bin/emctl start dbconsole"
        echo "*** Note: You can access service at url:  http://$(hostname):1158/em"
        ;;
        emstop)
        echo  "*** Stopping Oracle Enterprise Manager 10g Database Control ***"
        su - $OUSER -c "$OPATH/bin/emctl stop dbconsole"
        ;;
        status)
        echo "*** Oracle database status ***"
        chkdb_status
        ;;
        *)
        echo $"Usage: $0 {start|stop|isqlstart|isqlstop|emstart|emstop}"
        exit 1
esac
exit 0
上一篇:模拟密码验证的shell脚本 下一篇:shell脚本(启动DLink PCL无线网卡520/510)

power by soyo123 2007-2008