免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2419 | 回复: 8
打印 上一主题 下一主题

请问MC/SG中程序包 配置文件和控制脚本中的service有什么用? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-03-28 17:33 |只看该作者 |倒序浏览
在我做的测试中,好像没有这两个东西,程序包工作得也挺好的。假如我整个cluster只有 一个Oracle数据库 程序包,是不是不用配 什么service_cmd吧?
感觉function customer_defined_run_cmds()已经可以完成任务了,是不是?


配置文件中的 SERVICE_NAME有什么用?
# Example: SERVICE_NAME                   DB_SERVICE
#          SERVICE_FAIL_FAST_ENABLED      NO
#          SERVICE_HALT_TIMEOUT           300
#


控制文件脚本中的 SERVICE_NAME又是怎么一回事?跟配置文件中的SERVICE_NAME相关吗?
# For example:
#          SERVICE_NAME[0]=pkg1a
#          SERVICE_CMD[0]="/usr/bin/X11/xclock -display 192.10.25.54:0"
#          SERVICE_RESTART[0]=""  # Will not restart the service.
#
#          SERVICE_NAME[1]=pkg1b
#          SERVICE_CMD[1]="/usr/bin/X11/xload -display 192.10.25.54:0"
#          SERVICE_RESTART[1]="-r 2"   # Will restart the service twice.
#
#          SERVICE_NAME[2]=pkg1c
#          SERVICE_CMD[2]="/usr/sbin/ping"
#          SERVICE_RESTART[2]="-R" # Will restart the service an infinite
#                                    number of times.
#

论坛徽章:
0
2 [报告]
发表于 2003-03-28 19:58 |只看该作者

请问MC/SG中程序包 配置文件和控制脚本中的service有什么用?

service是被MC监听的进程,一旦该进程退出,MC会发生FAIL OVER。
当然如果不配它不会影响PKG运行,但MC将只考虑系统级的失败,应用程序的失败不会发生FAILOVER。

论坛徽章:
0
3 [报告]
发表于 2003-03-28 23:19 |只看该作者

请问MC/SG中程序包 配置文件和控制脚本中的service有什么用?

多谢指点。
不过,那么请问,对于Oracle这样的数据库来说,是不是没有合适的service_cmd 当作 MC/SG 监听的进程?
无论是 dbstart抑或 lsnrctl start,都是马上返回,正常退出的
虽然有很多后台进程确实一直跑,可是却无法配置在 PKG 中

如何也能让 MC考虑 数据库程序级的失败?
(可能没这必要)

论坛徽章:
0
4 [报告]
发表于 2003-03-28 23:43 |只看该作者

请问MC/SG中程序包 配置文件和控制脚本中的service有什么用?

在 Application 光盘中 有DBtoolkit 那里有关于主流数据库等的监控脚本供参考.

论坛徽章:
0
5 [报告]
发表于 2003-03-29 13:04 |只看该作者

请问MC/SG中程序包 配置文件和控制脚本中的service有什么用?

那个DBtoolkit 东西,好像需要另外购买的 安装的时候需要codeword

天知道 这套服务器 买了多少HP的license,非常失望

论坛徽章:
0
6 [报告]
发表于 2003-03-29 19:45 |只看该作者

请问MC/SG中程序包 配置文件和控制脚本中的service有什么用?

就是有个需要单独购买的东东,是需要钱的。叫什么忘了,提供了一个oracle.sh的脚本。

论坛徽章:
0
7 [报告]
发表于 2003-03-31 10:45 |只看该作者

请问MC/SG中程序包 配置文件和控制脚本中的service有什么用?

oracle.sh如下
#!/usr/bin/sh
# VERSION="@(#)B5139DA (11.x):"
# "@(#) B.01.08         $Revision: 2.00 $ $Date: 02/02/21 10:18:02 $"
# *****************************************************************************
# ******** Startup, Shutdown and Monitor Script for ORACLE (Template) *********
# *****************************************************************************
# ********** Note: This file MUST be edited before it can be used. ************
# *****************************************************************************
#
# *****************************************************************************
# *                 This script supports Oracle 9i only.                       *
# *                 For Oracle 7 or 8, use the ORACLE_7_8.sh script.          *
# *****************************************************************************
#
# This script executes one Oracle instance only. If you are running more than
# one instance on a node, it must be duplicated for each instance.  This script
# should be edited and moved to "/etc/cmcluster/${SID_NAME}/${SID_NAME}.sh",
# where ${SID_NAME} is the name of the Oracle instance.  Consult the README
# file for more information.
#
# Environment Variables:
#
# ORA_ver:                     To run Oracle 9i (9.0.1).  
#                       Set the variable: ORA_ver=9_0_1
#                       If you are running a prior version of Oracle please
#                       use the correct version of this template.
#
# SID_NAME:             The Oracle session name. This is sometimes called the   
#                       session ID (SID).                                       
#
# ORACLE_HOME:                The home directory of Oracle.
#
# LISTENER:             Set to "yes" if you want this template to start/stop
#                       the Listener
#
# LISTENER_NAME:        The name of the listener process.
#                                                                  
# LISTENER_PASS:        The password of the listener process. (optional)
#
# MONITOR_INTERVAL:     The time interval, in seconds, that this script will
#                       wait between checks that the Oracle database is
#                       running.
#
# MONITOR_PROCESSES:    The names of all processes that must be executing to   
#                       assume this Oracle instance is up and running.
#
# PACKAGE_NAME:                The name of the package as defined in the
#                        MC/ServiceGuard package configuration file.
#
# TIME_OUT:             The amount of time, in seconds, to wait for the Oracle
#                       abort to complete before killing the Oracle processes   
#                       defined in MONITOR_PROCESSES.  The TIME_OUT variable is
#                       used to protect against a worst case scenario where a   
#                       hung database prevents the halt script from completing,
#                       therefore preventing the standby node from starting the
#                       database.  The value of TIME_OUT must be less than the  
#                       time-out set in the package configuration file.  This   
#                       variable has no effect package failover times.         
#
# Examples:
#
# ORA_ver=9_0_1
# SID_NAME=owas
# ORACLE_HOME=/mnt1/base/app/oracle/product/9.0.1
# LISTENER=yes            
# LISTENER_NAME=LSNR_${SID_NAME}
# LISTENER_PASS=1DF5C2FD0FE9CFA2
# MONITOR_INTERVAL=30
# set -A MONITOR_PROCESSES ora_pmon_${SID_NAME} ora_dbw0_${SID_NAME} ora_ckpt_${SID_NAME}  ora_smon_${SID_NAME} ora_lgwr_${SID_NAME} ora_reco_${SID_NAME} ora_arc0_${SID_NAME}
# PACKAGE_NAME=dbs
# TIME_OUT=30
#   
###############################################################################
#
ORA_ver=9_0_1
SID_NAME=
ORACLE_HOME=
LISTENER=                  
LISTENER_NAME=
LISTENER_PASS=
MONITOR_INTERVAL=30
PACKAGE_NAME=
TIME_OUT=30
set -A MONITOR_PROCESSES ora_pmon_${SID_NAME} ora_dbw0_${SID_NAME} ora_ckpt_${SID_NAME}  ora_smon_${SID_NAME} ora_lgwr_${SID_NAME} ora_reco_${SID_NAME}

HOST=`hostname`
DATE=`date`
PATH=${ORACLE_HOME}/bin:/sbin:/usr/bin:/usr/sbin:/etc:/bin
export ORACLE_SID=${SID_NAME}
export ORACLE_HOME
###############################################################################
      
###############################################################################
# Function: oracle_run_cmds
#
# Start the ORACLE instance defined in the environment variables ORACLE_HOME
# and SID_NAME.
###############################################################################

function oracle_run_cmds
{
#   The Oracle initialization file (init${SID_NAME}.ora) can contain node
#   specific information. A large memory configuration might not run on a
#   smaller backup system so you might need to create node specific
#   configuration files as shown below:
#
#           ${ORACLE_HOME}/dbs/init${SID_NAME}.ora.${HOST}
#
#   Note: You must have node specific files for ALL NODES in the cluster.
       
    PFILE=${ORACLE_HOME}/dbs/init${SID_NAME}.ora

    if [[ -f ${PFILE}.${HOST} ]]
    then
        PFILE=${PFILE}.${HOST}
    fi

#   Make sure that the configuration file exists. If not, then the
#   database cannot be started on this node.

    if [[ ! -f ${PFILE} ]]
    then
        print "ORACLE: The file ${PFILE} does not exist."
        print "\tERROR:  Failed to start Oracle database."
        exit 1
    fi

#   Startup Oracle.
#   These commands will not return any error codes; therefore, anything
#   that fails after this point will cause a failover to another node.
#

    case $ORA_ver in
9_0_1) su oracle -c "${ORACLE_HOME}/bin/sqlplus '/as sysdba'"<<EOF
startup pfile=${PFILE}
exit
EOF
    if [[ $? != 0 ]]
    then
        print "Oracle startup failed."
    else
        print "Oracle startup done."
    fi
;;
*)
    print "Oracle startup failed, check configuration variables."
;;
esac


#   Start the listener process.

case $LISTENER in
yes )
su oracle -c "${ORACLE_HOME}/bin/lsnrctl start ${LISTENER_NAME}"
    if [[ $? != 0 ]]
    then
        print "Oracle lsnrctl start failed."
    else
        print "Oracle lsnrctl start done."
    fi
;;
*)
    print "Not starting the listener, configured not to start."
;;
esac

}

###############################################################################
# Function: oracle_shutdown_cmds
#
# Shutdown Oracle using the shutdown immediate command.
# This will do a clean shutdown of the database.  
# Do NOT use 'cmhaltpkg' to shutdown the database as 'cmhaltpkg'
# does a database abort and all transactions in memory will be lost.
###############################################################################

function oracle_shutdown_cmds
{
    case $ORA_ver in
9_0_1) su oracle -c "${ORACLE_HOME}/bin/sqlplus '/as sysdba'" <<EOF
shutdown immediate
exit
EOF
    if [[ $? != 0 ]]
    then
        print "Oracle shutdown failed."
    else
        print "Oracle shutdown done."
    fi
;;
*)
    print "Oracle shutdown failed, check configuration variables."
;;
esac

}

###############################################################################
# Function: oracle_abort_cmds
#
# Recursively call this script with the "kill" option to terminate any process
# that will not die normally after waiting for the TIME_OUT period.
###############################################################################

function oracle_abort_cmds
{
#   Something is wrong so we will abort.  If you wish to shutdown the database
#   without an abort, you must manually execute "${SID_NAME}.sh shutdown" from
#   the command line instead of using cmhaltpkg.  "Abort" is used because
#   "immediate" and "normal" will wait for all users to log off and they are
#   not deterministic.
#
#   Call this script with the kill option to terminate any process that will
#   not die normally after waiting for the TIME_OUT period.

     set -m                                                            
     ${0} kill &amp;

#   Stop Oracle process.

    case $ORA_ver in
9_0_1)  

su oracle -c "${ORACLE_HOME}/bin/sqlplus '/as sysdba'" <<EOF
shutdown abort
exit
EOF
    if [[ $? != 0 ]]
    then
        print "Oracle abort failed."
    else
        print "Oracle abort done."
    fi
;;
esac

#   Stop the listener process for Oracle.

case $LISTENER in
yes )
su oracle -c ${ORACLE_HOME}/bin/lsnrctl <<EOF
set password ${LISTENER_PASS}
stop ${LISTENER_NAME}
exit
EOF
;;
esac

#   Make sure all processes have gone away before determining that shutdown is
#   complete.  This stops the other node from starting up the package before it
#   has been stopped and the file system has been unmounted.

    typeset -i c
    typeset -i num_procs=${#MONITOR_PROCESSES[@]}
  
    while true
    do
        for i in ${MONITOR_PROCESSES[@]}
        do
            id=`ps -fu oracle | awk '/'${i}$'/ { print $2 }'`       #JAGad06432
            if [[ ${id} = "" ]]                                     #JAGad06432
            then
                print "\n *** ${i} process has stopped. ***\n"
                c=0
                while (( c < $num_procs ))
                do
                    if [[ ${MONITOR_PROCESSES[$c]} = $i ]]
                    then
                        unset MONITOR_PROCESSES[$c]
                        c=$num_procs
                    fi
                    (( c = c + 1 ))
                done
            fi
        done

        if [[ ${MONITOR_PROCESSES[@]} = "" ]]
        then
#           The shutdown was successful; therefore, get rid of the script (which
#           was started earlier) to kill any existing hung processes.  Check to
#           see if the script is still running.  If the result from the 'job'
#           command indicates that the script is done, then there is no need
#           to kill it.

            job=$(jobs | grep -v Done)
            if [[ ${job} != "" ]]
            then
                print "Killing the kill_hung_processes script\n"
                kill %1
            fi
            exit 0                                          # fix for 1653287920
        fi

        sleep 5
     done
}

###############################################################################
# Function: kill_hung_processes
#
# If the database is hung, spawn a background process that will issue a   
# a SIGKILL to each of the monitored processes. This allows us to guarantee
# a time limit for clean halt attempts.
###############################################################################

function kill_hung_processes
{
#   Wait for the TIME_OUT period before sending a kill signal.  The TIME_OUT
#   value should be less than the MC/Serviceguard package time-out.

    sleep ${TIME_OUT}
   
    for i in ${MONITOR_PROCESSES[@]}
    do
        id=`ps -fu oracle | awk '/'${i}$'/ { print $2 }'`            #JAGad06432
        if [[ ${id} != "" ]]
        then
            kill -9 ${id}
            if [[ $? != 0 ]]
            then
                print "\n *** ${0} kill_hung_processes function did NOT find process ***\n *** ${i} running. ***\n"
            else
                print "\n *** ${0} kill_hung_processes function did find process ***\n *** ${i} running.  Sent SIGKILL. ***\n"
            fi
        else
            print " *** kill_hung_processes function did NOT find ANY process running. ***\n"
        fi
    done
}

###############################################################################
# Function: monitor_processes
#
# Monitor the Oracle processes by making sure that all required processes are
# running.
##############################################################################

function monitor_processes
{
    typeset -i n=0

    for i in ${MONITOR_PROCESSES[@]}
    do
        MONITOR_PROCESSES_PID[$n]=`ps -fu oracle | awk '/'${i}$'/ { print $2 }'` #JAGad06432
        print "Monitored process = ${i}, pid = ${MONITOR_PROCESSES_PID[$n]}"
        if [[ ${MONITOR_PROCESSES_PID[$n]} = "" ]]
        then
            print "\n\n"
            ps -ef
            print "\n *** ${i} has failed at startup time.  Aborting Oracle. ***"
            set -m
            nohup ${0} fault &amp;    # The script calls itself with the fault option.
            set +m
            sleep 999999
        fi
        (( n = n + 1 ))
    done

    sleep ${MONITOR_INTERVAL}

    while true
    do
        for i in ${MONITOR_PROCESSES_PID[@]}
        do
            kill -s 0 ${i} >; /dev/null
            if [[ $? != 0 ]]
            then
                print "\n\n"
                ps -ef
                print "\n *** ${i} has failed.  Aborting Oracle. ***"
                set -m
                nohup ${0} fault &amp;    # The script calls itself with the fault option.
                set +m
                sleep 999999
            fi
        done
        sleep ${MONITOR_INTERVAL}
    done
}

###############################################################################
# Function: halt_package
#
# Because there is no move command in MC/Serviceguard, the package must first
# be halted, disabled from running on the host, and then enabled to run in the
# cluster.
###############################################################################

function halt_package
{
    cmhaltpkg ${PACKAGE_NAME}
    cmmodpkg -d -n ${HOST} ${PACKAGE_NAME}
    sleep 1
    cmmodpkg -e ${PACKAGE_NAME}
}

###############################################################################
# MAIN
#
# Check the command-line option and take the appropriate action.
###############################################################################

print "\n *** $0 called with $1 argument. ***\n"
case $1 in

    fault)
        halt_package
    ;;

    kill)
        kill_hung_processes
    ;;

    monitor)
        monitor_processes
    ;;

    start)
        print "\n \"${HOST}\": Starting Oracle SESSION $SID_NAME at ${DATE} "
        oracle_run_cmds
    ;;

    halt)
        print "\n \"${HOST}\": Aborting Oracle SESSION $SID_NAME at ${DATE} "
        oracle_abort_cmds
    ;;

    shutdown)
        print "\n \"${HOST}\": Shutting down Oracle SESSION $SID_NAME at ${DATE} "
        oracle_shutdown_cmds
    ;;
       
    *)
        print "Usage: ${0} [ shutdown | halt | start | monitor ]"
    ;;
esac

论坛徽章:
0
8 [报告]
发表于 2003-03-31 19:39 |只看该作者

请问MC/SG中程序包 配置文件和控制脚本中的service有什么用?

谢谢 楼上的菜鸟A
正想找人问 脚本呢

我自己写的脚本,就两句话
启动:
su - oracle -c 'dbstart'
su - oracle -c 'lsnrctl start'

但是关闭会有麻烦:
su - oracle -c 'lsnrctl stop'
su - oracle -c 'dbshut'
假如在关闭pkg的时候(我拔掉了网线),oracle还有其他session在活动,dbshut就会傻子那样的呆在那儿(因为它使用shutdown normal的方式,非要等所有session释放才肯关闭)
假如我修改dbshut的脚本,让他shutdown abort,也觉得不放心,需要instance recovery:(

看来得仔细研究 菜鸟A 给的脚本

非常感谢楼上几位的回答,//hug

论坛徽章:
0
9 [报告]
发表于 2003-04-01 13:21 |只看该作者

请问MC/SG中程序包 配置文件和控制脚本中的service有什么用?

不要客气,我也是在公司机器里找的。正自学中,什么都不懂,一起学习。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP