Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5698956
  • 博文数量: 745
  • 博客积分: 10075
  • 博客等级: 上将
  • 技术积分: 7716
  • 用 户 组: 普通用户
  • 注册时间: 2005-04-29 12:09
文章分类

全部博文(745)

文章存档

2019年(1)

2016年(1)

2010年(31)

2009年(88)

2008年(129)

2007年(155)

2006年(197)

2005年(143)

分类:

2006-03-29 17:10:21

启动Cluster

# cmruncl -v

# cmruncl -v -n node1 -n node2

Cluster中增加一个节点运行

# cmrunnode -v node2

Cluster中停止一个节点运行

# cmhaltnode -f -v node2

Cluster

# cmhaltcl -f -v

Package

# cmrunpkg -n node1 pkg1

# cmmodpkg -e node1 pkg1

Package,不切换

# cmhaltpkg pkg1

Package

# cmhaltpkg pkg1 -n node1

# cmrunpkg -n node2 pkg1

# cmmodpkg -e pkg1

# cmviewcl -v

 

 

附件一: : oracle.sh参数分析 
#!/usr/bin/sh   
#VERSION="@(#) B.01.04  $Revision: 1.13 $ $Date: 98/07/23 10:18:02 $" 
# ***************************************************************************** 
# ******** Startup, Shutdown and Monitor Script for ORACLE (Template) ********* 
# ***************************************************************************** 
# ********** Note: This file MUST be edited before it can be used. ************ 
# ***************************************************************************** 
processes when 
#     there was more than one Oracle instance running. 

ORA_7_3_X=no 
ORA_8_0_X=no 
ORA_8_1_X=yes 
#
注意:用户的ORACLE版本 
SID_NAME=ora82 
#
注意:实例名 
ORACLE_HOME=/home/oracle/app/oracle/product/8.1.6 
#
注意:设置变量 
SQLNET=no 
NET8=yes 
#
注意:使用NET8连接客户端 
LISTENER_NAME= 
LISTENER_PASS= 
#
注意:不用写 
MONITOR_INTERVAL=30 
#
注意:30秒一个询问 
PACKAGE_NAME=pkg1 
#
注意:程序包名字 
TIME_OUT=10 
#
注意:超时错误 
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} 

#
强烈注意:如果ORACLE某些进程没有使用,比如没有使用归档进程,( ora_arc0_${SID_NAME})一定不可以在上面监控,否则MC认为你的ORACLE总是有问题,强制停止ORACLE进程 

 

附件二、监控进程(既monitor
############################################################################################################################################################ 
下面的程序是HP根据你设置好的变量,详细的监控你的ORACLE的主要进程,即使你的ORACLE主要的6个进程是好的,但是有一个进程发生问题,HP一样会发生程序包的切换
############################################################################## 
############################################################################## 
HOST=`hostname` 
DATE=`date` 
PATH=${ORACLE_HOME}/bin:/sbin:/usr/bin:/usr/sbin:/etc:/bin 
export ORACLE_SID=${SID_NAME} 
export ORACLE_HOME 
        
附件三、moniter监控脚本示例

#!/usr/bin/sh

SYBASE_SERVER=dataserver

while true

do

ps -ef | grep $SYBASE_SERVER | grep -v grep >> /dev/null

if [ $? -eq 0 ]

then

 echo Alive >> /dev/null

else

 echo Die >> /dev/null

exit

fi

 

sleep 2

done

 

附件四: HP 原版 ORACLE.SH 文件

#!/usr/bin/sh 

#Thu Nov 28 16:33:50 EAT 2002

 

# Define variables

 

SID_NAME=test1

ORACLE_HOME=/oracle/product/8.1.7

LISTENER_NAME=LISTENER

LISTENER_PASS=

MONITOR_INTERVAL=10

PACKAGE_NAME=pkg1

TIME_OUT=40

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} tnslsnr

 

HOST=`hostname`

DATE=`date`

PATH=${ORACLE_HOME}/bin:/sbin:/usr/bin:/usr/sbin:/etc:/bin

export ORACLE_SID=${SID_NAME}

export ORACLE_HOME

 

ret=0

 

function oracle_run_cmds

{

su oracle -c "${ORACLE_HOME}/bin/sqlplus /nolog" <

connect / as sysdba

startup

exit

EOF

 

    ret=$?

    if [[ $ret != 0 ]]

    then

        print "Oracle startup failed!"

    return $ret

    else

        print "Oracle startup done."

    fi

 

su oracle -c "${ORACLE_HOME}/bin/lsnrctl start ${LISTENER_NAME}"

 

    ret=$?

    if [[ $ret != 0 ]]

    then

        print "Oracle lsnrctl start failed! Stop instance [$ORACLE_SID]."

    oracle_shutdown_cmds >/dev/null 2>&1

    return 1

    else

        print "Oracle lsnrctl start done."

    fi

}

 

function oracle_shutdown_cmds

{

    ret=0

 

    su oracle -c "${ORACLE_HOME}/bin/lsnrctl" <

        set password ${LISTENER_PASS}

        stop ${LISTENER_NAME}

        exit

    EOF

 

    ret=$?

    if [[ $ret != 0 ]]

    then

        print "Oracle lsnrctl stop failed!"

    else

        print "Oracle lsnrctl stop done."

    fi

 

    su oracle -c "${ORACLE_HOME}/bin/sqlplus /nolog" <

        connect / as sysdba

        shutdown immediate

        exit

    EOF

 

    ret=$?

    if [[ $ret != 0 ]]

    then

        print "Oracle shutdown failed!"

    return $ret

    else

        print "Oracle shutdown done."

    fi

}

 

 

function oracle_abort_cmds

{

 

    set -m                                                            

    ${0} kill &

    KILL_PID=$!

 

su oracle -c "${ORACLE_HOME}/bin/lsnrctl" <

set password ${LISTENER_PASS}

stop ${LISTENER_NAME}

exit

EOF

 

su oracle -c "${ORACLE_HOME}/bin/sqlplus /nolog" <

connect / as sysdba

shutdown abort

exit

EOF

 

    if [[ $? != 0 ]]

    then

        print "Oracle abort failed."

    else

        print "Oracle abort done."

    fi

 

    typeset -i c

    typeset -i num_procs=${#MONITOR_PROCESSES[@]}

 

    while true

    do

        for i in ${MONITOR_PROCESSES[@]}

        do

            ps -ef | grep ${i} | grep -v grep > /dev/null

            if [[ $? != 0 ]]

            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

 

            job=$(jobs | grep -v Done)

            if [[ ${job} != "" ]]

            then

                print "Killing the kill_hung_processes script\n"

                kill %1

            fi

            exit 0

        fi

 

        sleep 5

     done

}

 

function terminate

{

     print "This monitor script has been signaled to terminate\n"

     exit

}

 

function kill_hung_processes

{

 

    sleep ${TIME_OUT}

 

    for i in ${MONITOR_PROCESSES[@]}

    do

        id=`ps -fu oracle | awk '/'${i}'/ { print $2 }'`

        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

{

    typeset -i n=0

 

    for i in ${MONITOR_PROCESSES[@]}

    do

        MONITOR_PROCESSES_PID[$n]=`ps -fu oracle | awk '/'${i}'/ { print $2 }'`

        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 &   

            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 &   

                set +m

                sleep 999999

            fi

        done

        sleep ${MONITOR_INTERVAL}

    done

}

 

 

function halt_package

{

    cmhaltpkg ${PACKAGE_NAME}

    cmmodpkg -d -n ${HOST} ${PACKAGE_NAME}

    sleep 1

    cmmodpkg -e ${PACKAGE_NAME}

}

 

 

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

 

 

阅读(3686) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~