首页 > 学技术 > 技术网文 > HP-UX > 正文

[精彩] 关于双机备份


来源 chinaunix.net 酷勤网整理

请教双机备份都要做哪些工作,谁有相关的命令操作文档?



 frankswf 回复于:2003-08-27 11:01:39

MC主要管理命令
MC/ServiceGuard的一些基本概念
Cluster集群—由若干台计算机组成一个群体共同向客户端提供服务
Node—组成cluster的单台计算机
Package—可以向客户端提供服务的一组资源总和
资源包括:
共享vg—cluster中用于存放数据库的物理空间,可以被cluster中所有节点访问;不允许同时访问,共享vg一般设为排它访问,以防止数据冲突;在一个时间里,只有运行package的节点可以访问共享vg。
浮动IP—与应用绑定的动态地址,哪一个节点运行package提供服务,它就持有浮动ip;浮动ip随package浮动。
Lock Disk—锁盘,用于在心跳不通时,cluster重组中进行仲裁,一般不用来存放数据。


查看MC配置命令:cmviewconf
查看MC当前状态:cmviewcl  -v
运行命令:cmruncl
停止cluster命令:cmhaltcl  -f
停止某一节点:cmhaltnode
启动某一脚本:cmrunnode
在一个节点停止一个包:cmhaltpkg  -n node pkg
在一个节点启动一个包:cmrunpkg  -n node pkg
改变package的切换开关,允许/禁止包切换到某一节点:
cmmodpkg  –e/-d  pkgname  –n nodename

vgchange –c n  vg04
vgchange –a y  vg04
vgchange –a n  vg04
vgchange –c y  vg04
vgexport
vgimport
vgcfgbackup


二、 高可靠性集群环境MC/Service Guard配置
1、 配置(SCSI联结图)













当前系统配置
# cmviewconf

Cluster information:

   cluster name: cluster1
   version: 0
   flags: 12 (single cluster lock)
   heartbeat interval: 1.00    (seconds)
   node timeout: 2.00    (seconds)
   heartbeat connection timeout: 4.00    (seconds)
   auto start timeout: 600.00  (seconds)
   network polling interval: 2.00    (seconds)
   first lock vg name: /dev/vg02
   second lock vg name: (not configured)

Cluster Node information:

   Node ID 1:
      Node name: ccsh1
      first lock pv name: /dev/dsk/c4t0d0
      first lock disk interface type: c720

      Network ID 1:
        mac addr: 0x001083f62ce6
        hardware path: 0/5/0/0
        network interface name: lan1
        subnet: 188.1.1.0
        subnet mask: 255.255.255.0
        ip address: 188.1.1.10
        flags: 1 (Heartbeat Network)
        bridged net ID: 1

      Network ID 2:
        mac addr: 0x00108396116b
        hardware path: 0/0/0/0
        network interface name: lan0
        subnet: 192.1.1.0
        subnet mask: 255.255.255.0
        ip address: 192.1.1.1
        flags: 1 (Heartbeat Network)
        bridged net ID: 2

      Network ID 3:
        mac addr: 0x001083f62c1c
        hardware path: 1/12/0/0
        network interface name: lan2
        subnet: 0.0.0.0
        subnet mask: 0.0.0.0
        ip address: 0.0.0.0
        flags: 0 (Non-Heartbeat Network)
        bridged net ID: 1

   Node ID 2:
      Node name: ccsh2
      first lock pv name: /dev/dsk/c6t0d0
      first lock disk interface type: c720

      Network ID 1:
        mac addr: 0x0060b0b3d134
        hardware path: 0/5/0/0
        network interface name: lan1
        subnet: 188.1.1.0
        subnet mask: 255.255.255.0
        ip address: 188.1.1.20
        flags: 1 (Heartbeat Network)
        bridged net ID: 1

      Network ID 3:
        mac addr: 0x0060b0b3d1a6
        hardware path: 1/12/0/0
        network interface name: lan2
        subnet: 0.0.0.0
        subnet mask: 0.0.0.0
        ip address: 0.0.0.0
        flags: 0 (Non-Heartbeat Network)
        bridged net ID: 1

      Network ID 2:
        mac addr: 0x0010839601f9
        hardware path: 0/0/0/0
        network interface name: lan0
        subnet: 192.1.1.0
        subnet mask: 255.255.255.0
        ip address: 192.1.1.2
        flags: 1 (Heartbeat Network)
        bridged net ID: 2

Package information:

   package ID 24065:
      package name: pkg1
      package global flags: 5
(Package Switch Enabled)
(Package Local Switch Enabled)
(Configured Node Failover)
(Manual Failback)
      package run script: /etc/cmcluster/pkg1/control.sh
      package run timeout: (No Timeout)
      package halt script: /etc/cmcluster/pkg1/control.sh
      package halt timeout: (No Timeout)
      package primary node: ccsh1
      package alternate node: ccsh2

      package services:
        service ID: 1
          service name: informix
          service halt timeout: 300 (seconds)
          service fail fast: Enabled

集群配置文件/etc/cmcluster/cmclconf.ascii
包packge配置文件/etc/cmcluster/pkg1/cmclpkg1.ascii
MC启动/停止应用及监控脚本/etc/cmcluster/pkg1/control.sh
系统应用的主要脚本/etc/cmcluster/informix.sh
商行应用启动脚本/etc/cmcluster/start_bank.sh
商行应用停止脚本/etc/cmcluster/halt_bank.sh
2、 主要管理命令
MC/ServiceGuard的一些基本概念
Cluster集群—由若干台计算机组成一个群体共同向客户端提供服务
Node—组成cluster的单台计算机
Package—可以向客户端提供服务的一组资源总和
资源包括:
共享vg—cluster中用于存放数据库的物理空间,可以被cluster中所有节点访问;不允许同时访问,共享vg一般设为排它访问,以防止数据冲突;在一个时间里,只有运行package的节点可以访问共享vg。
浮动IP—与应用绑定的动态地址,哪一个节点运行package提供服务,它就持有浮动ip;浮动ip随package浮动。
Lock Disk—锁盘,用于在心跳不通时,cluster重组中进行仲裁,一般不用来存放数据。
查看MC配置命令:cmviewconf
查看MC当前状态:cmviewcl  -v
运行命令:cmruncl
停止cluster命令:cmhaltcl  -f
停止某一节点:cmhaltnode
启动某一脚本:cmrunnode
在一个节点停止一个包:cmhaltpkg  -n node pkg
在一个节点启动一个包:cmrunpkg  -n node pkg
改变package的切换开关,允许/禁止包切换到某一节点:
cmmodpkg  –e/-d  pkg  –n node

vgchange –c n  vg04
vgchange –a y  vg04
vgchange –a n  vg04
vgchange –c y  vg04
vgexport
vgimport
vgcfgbackup


附件B. MC/Servives Guard配置文件cmclconf.ascii
# **********************************************************************
# ********* HIGH AVAILABILITY CLUSTER CONFIGURATION FILE ***************
# ***** For complete details about cluster parameters and how to    ****
# ***** set them, consult the cmquerycl(1m) manpage or your manual. ****
# **********************************************************************

# Enter a name for this cluster.  This name will be used to identify the
# cluster when viewing or manipulating it.

CLUSTER_NAME cluster1

# Cluster Lock Device Parameters.  This is the volume group that
# holds the cluster lock which is used to break a cluster formation
# tie.  This volume group should not be used by any other cluster
# as cluster lock device.

FIRST_CLUSTER_LOCK_VG /dev/vg02

# Definition of nodes in the cluster.
# Repeat node definitions as necessary for additional nodes.

NODE_NAME ccsh1
  NETWORK_INTERFACE lan1
    HEARTBEAT_IP 188.1.1.10
  NETWORK_INTERFACE lan0
    HEARTBEAT_IP 192.1.1.1
  NETWORK_INTERFACE lan2
  FIRST_CLUSTER_LOCK_PV /dev/dsk/c4t0d0
# List of serial device file names
# For example:
# SERIAL_DEVICE_FILE /dev/tty0p0

# Warning: There are no standby network interfaces for lan0.
# Possible standby Network Interfaces for lan1: lan2.

NODE_NAME ccsh2
  NETWORK_INTERFACE lan1
    HEARTBEAT_IP 188.1.1.20
  NETWORK_INTERFACE lan0
    HEARTBEAT_IP 192.1.1.2
  NETWORK_INTERFACE lan2
  FIRST_CLUSTER_LOCK_PV /dev/dsk/c6t0d0
# List of serial device file names
# For example:
# SERIAL_DEVICE_FILE /dev/tty0p0

# Warning: There are no standby network interfaces for lan0.
# Possible standby Network Interfaces for lan1: lan2.

# Cluster Timing Parmeters (microseconds).

HEARTBEAT_INTERVAL 1000000
NODE_TIMEOUT 2000000

# Configuration/Reconfiguration Timing Parameters (microseconds).

AUTO_START_TIMEOUT 600000000
NETWORK_POLLING_INTERVAL 2000000

# Package Configuration Parameters.
# Enter the maximum number of packages which will be configured in the cluster.
# You can not add packages beyond this limit.
# This parameter is required.
MAX_CONFIGURED_PACKAGES 2

# List of cluster aware Volume Groups. These volume groups will
# be used by package applications via the vgchange -a e command.
# For example: 
# VOLUME_GROUP /dev/vgdatabase.
# VOLUME_GROUP /dev/vg02.

VOLUME_GROUP /dev/vg02
VOLUME_GROUP /dev/vg03
VOLUME_GROUP /dev/vg04
 
附件C:MC/Services Guard配置文件pkg1conf.ascii
# **********************************************************************
# ****** HIGH AVAILABILITY PACKAGE CONFIGURATION FILE (template) *******
# **********************************************************************
# ******* Note: This file MUST be edited before it can be used. ********
# * For complete details about package parameters and how to set them, *
# * consult the MC/ServiceGuard or ServiceGuard OPS Edition manpages   *
# * or manuals.                                                        *
# **********************************************************************

# Enter a name for this package.  This name will be used to identify the
# package when viewing or manipulating it.  It must be different from
# the other configured package names.

PACKAGE_NAME pkg1

# Enter the failover policy for this package. This policy will be used
# to select an adoptive node whenever the package needs to be started.
# The default policy unless otherwise specified is CONFIGURED_NODE.
# This policy will select nodes in priority order from the list of
# NODE_NAME entries specified below.
#
# The alternative policy is MIN_PACKAGE_NODE. This policy will select
# the node, from the list of NODE_NAME entries below, which is
# running the least number of packages at the time this package needs
# to start.

FAILOVER_POLICY CONFIGURED_NODE

# Enter the failback policy for this package. This policy will be used
# to determine what action to take when a package is not running on
# its primary node and its primary node is capable of running the
# package. The default policy unless otherwise specified is MANUAL.
# The MANUAL policy means no attempt will be made to move the package
# back to its primary node when it is running on an adoptive node.
#
# The alternative policy is AUTOMATIC. This policy will attempt to
# move the package back to its primary node whenever the primary node
# is capable of running the package.

FAILBACK_POLICY MANUAL

# Enter the names of the nodes configured for this package.  Repeat
# this line as necessary for additional adoptive nodes.
# Order IS relevant.  Put the second Adoptive Node AFTER the first
# one.
# Example : NODE_NAME  original_node  
#           NODE_NAME  adoptive_node  

NODE_NAME ccsh1
NODE_NAME ccsh2

# Enter the complete path for the run and halt scripts.  In most cases
# the run script and halt script specified here will be the same script,
# the package control script generated by the cmmakepkg command.  This
# control script handles the run(ning) and halt(ing) of the package.
# If the script has not completed by the specified timeout value,
# it will be terminated.  The default for each script timeout is
# NO_TIMEOUT.  Adjust the timeouts as necessary to permit full 
# execution of each script.
# Note: The HALT_SCRIPT_TIMEOUT should be greater than the sum of
# all SERVICE_HALT_TIMEOUT specified for all services.

RUN_SCRIPT /etc/cmcluster/pkg1/control.sh
RUN_SCRIPT_TIMEOUT NO_TIMEOUT
HALT_SCRIPT /etc/cmcluster/pkg1/control.sh
HALT_SCRIPT_TIMEOUT NO_TIMEOUT

# Enter the SERVICE_NAME, the SERVICE_FAIL_FAST_ENABLED and the
# SERVICE_HALT_TIMEOUT values for this package.  Repeat these  
# three lines as necessary for additional service names.  All  
# service names MUST correspond to the service names used by   
# cmrunserv and cmhaltserv commands in the run and halt scripts.
#
# The value for SERVICE_FAIL_FAST_ENABLED can be either YES or 
# NO.  If set to YES, in the event of a service failure, the   
# cluster software will halt the node on which the service is  
# running.  If SERVICE_FAIL_FAST_ENABLED is not specified, the 
# default will be NO.                                          
#
# SERVICE_HALT_TIMEOUT is represented in the number of seconds.
# This timeout is used to determine the length of time (in     
# seconds) the cluster software will wait for the service to   
# halt before a SIGKILL signal is sent to force the termination
# of the service.  In the event of a service halt, the cluster 
# software will first send a SIGTERM signal to terminate the   
# service.  If the service does not halt, after waiting for the
# specified SERVICE_HALT_TIMEOUT, the cluster software will send
# out the SIGKILL signal to the service to force its termination.
# This timeout value should be large enough to allow all cleanup
# processes associated with the service to complete.  If the   
# SERVICE_HALT_TIMEOUT is not specified, a zero timeout will be
# assumed, meaning the cluster software will not wait at all   
# before sending the SIGKILL signal to halt the service.       
#
# Example: SERVICE_NAME                   DB_SERVICE           
#          SERVICE_FAIL_FAST_ENABLED      NO                   
#          SERVICE_HALT_TIMEOUT           300                  
#
# To configure a service, uncomment the following lines and    
# fill in the values for all of the keywords.                  
#
#SERVICE_NAME                   <service name>;                 
#SERVICE_FAIL_FAST_ENABLED      <YES/NO>;                       
#SERVICE_HALT_TIMEOUT           <number of seconds>;            

SERVICE_NAME                   informix                 
SERVICE_FAIL_FAST_ENABLED      YES                       
SERVICE_HALT_TIMEOUT           300            

# Enter the network subnet name that is to be monitored for this package.
# Repeat this line as necessary for additional subnet names.  If any of
# the subnets defined goes down, the package will be switched to another
# node that is configured for this package and has all the defined subnets
# available.

#SUBNET

# The keywords RESOURCE_NAME, RESOURCE_POLLING_INTERVAL,               
# RESOURCE_START, and RESOURCE_UP_VALUE are used to specify Package    
# Resource Dependencies.  To define a package Resource Dependency, a   
# RESOURCE_NAME line with a fully qualified resource path name, and    
# one or more RESOURCE_UP_VALUE lines are required.  The               
# RESOURCE_POLLING_INTERVAL and the RESOURCE_START are optional.       
#
# The RESOURCE_POLLING_INTERVAL indicates how often, in seconds, the   
# resource is to be monitored.  It will be defaulted to 60 seconds if  
# RESOURCE_POLLING_INTERVAL is not specified.                          
#
# The RESOURCE_START option can be set to either AUTOMATIC or DEFERRED.
# The default setting for RESOURCE_START is AUTOMATIC.  If AUTOMATIC   
# is specified, ServiceGuard will start up resource monitoring for     
# these AUTOMATIC resources automatically when the node starts up.     
# If DEFERRED is selected, ServiceGuard will not attempt to start      
# resource monitoring for these resources during node start up.  User  
# should specify all the DEFERRED resources in the package run script  
# so that these DEFERRED resources will be started up from the package 
# run script during package run time.                                  
#                                                                      
# RESOURCE_UP_VALUE requires an operator and a value.  This defines    
# the resource 'UP' condition.  The operators are =, !=, >;, <, >;=,     
# and <=, depending on the type of value.  Values can be string or     
# numeric.  If the type is string, then only = and != are valid        
# operators.  If the string contains whitespace, it must be enclosed   
# in quotes.  String values are case sensitive.  For example,          
#
#  Resource is up when its value is
#  --------------------------------
#  RESOURCE_UP_VALUE = UP "UP"
#  RESOURCE_UP_VALUE != DOWN Any value except "DOWN"
#  RESOURCE_UP_VALUE = "On Course" "On Course"

# If the type is numeric, then it can specify a threshold, or a range to
# define a resource up condition.  If it is a threshold, then any operator
# may be used.  If a range is to be specified, then only >; or >;= may be used
# for the first operator, and only < or <= may be used for the second operator.
# For example,
#  Resource is up when its value is
#  --------------------------------
#  RESOURCE_UP_VALUE     = 5 5     (threshold)
#  RESOURCE_UP_VALUE     >; 5.1 greater than 5.1    (threshold)
#  RESOURCE_UP_VALUE     >; -5 and < 10 between -5 and 10   (range)

# Note that "and" is required between the lower limit and upper limit
# when specifying a range.  The upper limit must be greater than the lower 
# limit.  If RESOURCE_UP_VALUE is repeated within a RESOURCE_NAME block, then 
# they are inclusively OR'd together.  Package Resource Dependencies may be 
# defined by repeating the entire RESOURCE_NAME block.

# Example : RESOURCE_NAME               /net/interfaces/lan/status/lan0
#      RESOURCE_POLLING_INTERVAL 120
#      RESOURCE_START AUTOMATIC
#      RESOURCE_UP_VALUE = RUNNING 
#      RESOURCE_UP_VALUE = ONLINE 

#           Means that the value of resource /net/interfaces/lan/status/lan0
#           will be checked every 120 seconds, and is considered to
#           be 'up' when its value is "RUNNING" or "ONLINE".

# Uncomment the following lines to specify Package Resource Dependencies.
#
#RESOURCE_NAME     <Full_path_name>;
#RESOURCE_POLLING_INTERVAL  <numeric_seconds>;
#RESOURCE_START             <AUTOMATIC/DEFERRED>;
#RESOURCE_UP_VALUE     <op>; <string_or_numeric>; [and <op>; <numeric>;]

# The default for PKG_SWITCHING_ENABLED is YES. In the event of a
# failure, this permits the cluster software to transfer the package 
# to an adoptive node.  Adjust as necessary.

PKG_SWITCHING_ENABLED YES

# The default for NET_SWITCHING_ENABLED is YES.  In the event of a
# failure, this permits the cluster software to switch LANs locally 
# (transfer to a standby LAN card).  Adjust as necessary.

NET_SWITCHING_ENABLED YES

# The default for NODE_FAIL_FAST_ENABLED is NO.  If set to YES,
# in the event of a failure, the cluster software will halt the node 
# on which the package is running.  Adjust as necessary.

NODE_FAIL_FAST_ENABLED NO 
附件D:MC/ServicesGuard配置文件control.sh
#"(#) A.11.08                                         $Date: 99/04/18 $"
# **********************************************************************
# *                                                                    * 
# *        HIGH AVAILABILITY PACKAGE CONTROL SCRIPT (template)         * 
# *                                                                    *
# *       Note: This file MUST be edited before it can be used.        *
# *                                                                    *
# **********************************************************************
       
# UNCOMMENT the variables as you set them.

# Set PATH to reference the appropriate directories.
PATH=/sbin:/usr/bin:/usr/sbin:/etc:/bin

# VOLUME GROUP ACTIVATION: 
# Specify the method of activation for volume groups.
# Leave the default ("VGCHANGE="vgchange -a e") if you want volume
# groups activated in exclusive mode. This assumes the volume groups have
# been initialized with 'vgchange -c y' at the time of creation.
#
# Uncomment the first line (VGCHANGE="vgchange -a e -q n"), and comment 
# out the default, if your disks are mirrored on separate physical paths,
#
# Uncomment the second line (VGCHANGE="vgchange -a e -q n -s"), and comment 
# out the default, if your disks are mirrored on separate physical paths,
# and you want the mirror resynchronization to ocurr in parallel with
# the package startup.
#
# Uncomment the third line (VGCHANGE="vgchange -a y") if you wish to 
# use non-exclusive activation mode. Single node cluster configurations
# must use non-exclusive activation.
#
# VGCHANGE="vgchange -a e -q n"
# VGCHANGE="vgchange -a e -q n -s"
# VGCHANGE="vgchange -a y"
VGCHANGE="vgchange -a e" # Default
       
# VOLUME GROUPS
# Specify which volume groups are used by this package. Uncomment VG[0]="" 
# and fill in the name of your first volume group. You must begin with 
# VG[0], and increment the list in sequence.
#
# For example, if this package uses your volume groups vg01 and vg02, enter:
#         VG[0]=vg01
#         VG[1]=vg02
#
# The volume group activation method is defined above. The filesystems
# associated with these volume groups are specified below.
#

VG[0]=vg03
VG[1]=vg04

# FILESYSTEMS
# Specify the filesystems which are used by this package. Uncomment 
# LV[0]=""; FS[0]=""; FS_MOUNT_OPT[0]="" and fill in the name of your first 
# logical volume, filesystem and mount option for the file system. You must 
# begin with LV[0], FS[0] and FS_MOUNT_OPT[0] and increment the list in 
# sequence.
#
# For example, if this package uses the file systems pkg1a and pkg1b, 
# which are mounted on the logical volumes lvol1 and lvol2 with read and
# write options enter:
#          LV[0]=/dev/vg01/lvol1; FS[0]=/pkg1a; FS_MOUNT_OPT[0]="-o rw"
#          LV[1]=/dev/vg01/lvol2; FS[1]=/pkg1b; FS_MOUNT_OPT[1]="-o rw"
#
# The filesystems are defined as triplets of entries specifying the logical 
# volume, the mount point and the mount options for the file system. Each 
# filesystem will be fsck'd prior to being mounted. The filesystems will be 
# mounted in the order specified during package startup and will be unmounted 
# in reverse order during package shutdown. Ensure that volume groups 
# referenced by the logical volume definitions below are included in 
# volume group definitions above.
#
#LV[0]=""; FS[0]=""; FS_MOUNT_OPT[0]=""

# FILESYSTEM UNMOUNT COUNT
# Specify the number of unmount attempts for each filesystem during package
# shutdown.  The default is set to 1.
FS_UMOUNT_COUNT=1

# IP ADDRESSES
# Specify the IP and Subnet address pairs which are used by this package.
# Uncomment IP[0]="" and SUBNET[0]="" and fill in the name of your first
# IP and subnet address. You must begin with IP[0] and SUBNET[0] and 
# increment the list in sequence.
#
# For example, if this package uses an IP of 192.10.25.12 and a subnet of 
# 192.10.25.0 enter:
#          IP[0]=192.10.25.12 
#          SUBNET[0]=192.10.25.0 # (netmask=255.255.255.0)
#
# Hint: Run "netstat -i" to see the available subnets in the Network field.
#
# IP/Subnet address pairs for each IP address you want to add to a subnet 
# interface card.  Must be set in pairs, even for IP addresses on the same
# subnet.
#

IP[0]=188.1.1.100
SUBNET[0]=188.1.1.0

# SERVICE NAMES AND COMMANDS.
# Specify the service name, command, and restart parameters which are 
# used by this package. Uncomment SERVICE_NAME[0]="", SERVICE_CMD[0]="",
# SERVICE_RESTART[0]="" and fill in the name of the first service, command,
# and restart parameters. You must begin with SERVICE_NAME[0], SERVICE_CMD[0],
# and SERVICE_RESTART[0] and increment the list in sequence.
#
# 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.
#
# Note: No environmental variables will be passed to the command, this 
# includes the PATH variable. Absolute path names are required for the
# service command definition.  Default shell is /usr/bin/sh.
#
#SERVICE_NAME[0]=""
#SERVICE_CMD[0]=""
#SERVICE_RESTART[0]=""

SERVICE_NAME[0]=informix
SERVICE_CMD[0]="/etc/cmcluster/informix.sh monitor"
SERVICE_RESTART[0]=""

# DEFERRED_RESOURCE NAME
# Specify the full path name of the 'DEFERRED' resources configured for
# this package.  Uncomment DEFERRED_RESOURCE_NAME[0]="" and fill in the
# full path name of the resource.
#
#DEFERRED_RESOURCE_NAME[0]=""
       
# DTC manager information for each DTC.
# Example: DTC[0]=dtc_20
#DTC_NAME[0]=
       
       
# START OF CUSTOMER DEFINED FUNCTIONS

# This function is a place holder for customer define functions.
# You should define all actions you want to happen here, before the service is
# started.  You can create as many functions as you need.  

function customer_defined_run_cmds
{
# ADD customer defined run commands.
: # do nothing instruction, because a function must contain some command.
/etc/cmcluster/informix.sh start

test_return 51
}
       
# This function is a place holder for customer define functions.
# You should define all actions you want to happen here, before the service is
# halted.

function customer_defined_halt_cmds
{
# ADD customer defined halt commands.
: # do nothing instruction, because a function must contain some command.
/etc/cmcluster/informix.sh halt

test_return 52
}
       
# END OF CUSTOMER DEFINED FUNCTIONS
       

# START OF RUN FUNCTIONS
       
       
function activate_volume_group
{
for I in ${VG[@]}
do
if [[ "${VGCHANGE}" = "vgchange -a y" ]]
then
         print "$(date '+%b %e %X') - Node \"$(hostname)\": Activating volume group $I with non-exclusive option."
else
         print "$(date '+%b %e %X') - \"$(hostname)\": Activating volume group $I with exclusive option."
fi

$VGCHANGE $I
test_return 1

# If the -s option has been specified, then we perform
# the resynchronization as a background task
#
if [[ ${VGCHANGE#*-s} != ${VGCHANGE} ]]
then
    {
if /sbin/vgsync $I
then
    print "$(date '+%b %e %X') - Node \"$(hostname)\": Resynchronized volume group $I"
else
    print "$(date '+%b %e %X') - Node \"$(hostname)\": Resynchronization of volume group $I encountered an error"
fi
    } &
fi
done
}
       
# For each {file system/logical volume} pair, fsck the file system
# and mount it.  If the file system is busy, mounting of the file
# system will fail, the control script will exit with an error.

function check_and_mount
{
integer R=0

for I in ${LV[@]}
do
if [[ $(mount -p | awk '$1 == "'$I'"') = "" ]]
then
RLV[$R]="${I%/*}/r${I##*/}"

             if [ -x /usr/sbin/fstyp ]
             then
                fstype[$R]=$(fstyp $I)
fi 
(( R = $R + 1 ))
fi
done

# Verify that there is at least one file system to check and what type.
if [[ ${RLV[@]} != "" ]]
then
print -n "$(date '+%b %e %X') - Node \"$(hostname)\": "
print "Checking filesystems:"
print ${LV[@]} | tr ' ' '\012' | sed -e 's/^/   /'

# If there is more than one filesystem type being checked
# then each filesystem is check individually.
#
R=$(print ${fstype[*]} | tr ' ' '\012' | sort -u | wc -l)
if (( R >; 1 )) 
then
    R=0
    while (( R < ${#RLV[*]} ))
    do
case ${fstype[$R]} in

    hfs) fsck -F hfs -P ${RLV[$R]}
test_return 2
;;

    vxfs) fsck -F vxfs -y ${RLV[$R]}
test_return 2
;;

    unk*) fsck ${RLV[$R]}
test_return 2
;;

    *) if [[ ${fstype[$R]} = "" ]]
then
    fsck ${RLV[$R]}
else
    fsck -F ${fstype[$R]} ${RLV[$R]}
fi
test_return 2
;;
esac
(( R = R + 1 ))
    done

# If there is only one filesystem type being checked, then
# multiple invocations of fsck can be avoided. All filesystems
# are specified on the command line to one fsck invocation.
#
else
    case ${fstype} in

hfs) fsck -F hfs -P ${RLV[@]}
test_return 2
;;

vxfs) fsck -F vxfs -y ${RLV[@]}
test_return 2
;;

unk*) fsck ${RLV[@]}
test_return 2
;;

*) if [[ ${fstype} = "" ]]
then
    fsck ${RLV[@]}
else
    fsck -F ${fstype} ${RLV[@]}
fi
test_return 2
;;
    esac
fi
fi
       
integer F=0
for I in ${LV[@]}
do
if [[ $(mount | grep -e $I" ") = "" ]]
then
print "$(date '+%b %e %X') - Node \"$(hostname)\": Mounting $I at ${FS[$F]}"
mount ${FS_MOUNT_OPT[$F]} $I ${FS[$F]}
test_return 3
else
print "$(date '+%b %e %X') - Node \"$(hostname)\": WARNING:  File system \"${FS[$F]}\" was already mounted."
fi
(( F = $F + 1 ))
done
}
       
# For each {IP address/subnet} pair, add the IP address to the subnet
# using cmmodnet(1m).
       
function add_ip_address
{
integer S=0
integer error=0

for I in ${IP[@]}
do
print "$(date '+%b %e %X') - Node \"$(hostname)\": Adding IP address $I to subnet ${SUBNET[$S]}"
XX=$( cmmodnet -a -i $I ${SUBNET[$S]} 2>;&1 )
if (( $? != 0 ))
then
                if [[ $(echo $XX | grep "heartbeat IP") != "" ]]
                then
                        # IP has been configured as a heartbeat IP address.
                        print "$XX" >;>; $0.log
                        (( error = 1 ))
                else
                        YY=$( netstat -in | awk '$4 == "'${I}'"')
                        if [[ -z $YY ]]
                        then
                                print "$XX" >;>; $0.log
                                print "\tERROR:  Failed to add IP $I to subnet ${SUBNET[$S]}"
                                (( error = 1 ))
                        else
                                print "\tWARNING:  IP $I is already configured on the subnet ${SUBNET[$S]}"
                        fi
                fi
fi
(( S = $S + 1 ))
done

if (( error != 0 ))
then

# `let 0` is used to set the value of $? to 1. The function test_return 
# requires $? to be set to 1 if it has to print error message.

        let 0
        test_return 4
fi

}
       
# Own and reset the DTC connections
       
function get_ownership_dtc
{
for I in ${DTC_NAME[@]}
do
print "$(date '+%b %e %X') - Node \"$(hostname)\": Assigning Ownership of the DTC $I"
dtcmodifyconfs -o $I
test_return 5
       
for J in ${IP[@]}
do
print "$(date '+%b %e %X') - Node \"$(hostname)\": Resetting the DTC connections to IP address $J"
dtcdiag -Q $J -q -f $I
test_return 6
done
done
}


# For each {service name/service command string} pair, start the
# service command string at the service name using cmrunserv(1m).

function start_services
{
integer C=0
for I in ${SERVICE_NAME[@]}
do
print "$(date '+%b %e %X') - Node \"$(hostname)\": Starting service $I using"
print "   \"${SERVICE_CMD[$C]}\""
            #
            # Check if cmrunserv should be called the old
            # way without a restart count.
            #
if [[ "${SERVICE_RESTART[$C]}" = "" ]]
then
    cmrunserv $I ">;>; $0.log 2>;&1 ${SERVICE_CMD[$C]}"
else
    cmrunserv ${SERVICE_RESTART[$C]} $I ">;>; $0.log 2>;&1 ${SERVICE_CMD[$C]}"
fi
test_return 8
(( C = $C + 1 ))
done
}


# For each {deferred resource name}, start resource monitoring for this
# resource using cmstartres(1m).

function start_resources
{
for I in ${DEFERRED_RESOURCE_NAME[@]}
do
print "$(date '+%b %e %X') - Node \"$(hostname)\": Starting resource monitoring for $I"
cmstartres -u -p $PACKAGE $I >;>; $0.log 2>;&1
test_return 15
done
}

# END OF RUN FUNCTIONS.



# START OF HALT FUNCTIONS

# For each {deferred resource name}, stop resource monitoring for this
# resource using cmstopres(1m).

function stop_resources
{
for I in ${DEFERRED_RESOURCE_NAME[@]}
do
        print "$(date '+%b %e %X') - Node \"$(hostname)\": Stopping resource monitoring for $I"
        cmstopres -p $PACKAGE $I >;>; $0.log 2>;&1
        test_return 16
done
}


# Halt each service using cmhaltserv(1m).

function halt_services
{
for I in ${SERVICE_NAME[@]}
do
print "$(date '+%b %e %X') - Node \"$(hostname)\": Halting service $I"
cmhaltserv $I
test_return 9
done
}

# Disown the DTC.

function disown_dtc 
{
for I in ${DTC_NAME[@]}
do
print "$(date '+%b %e %X') - Node \"$(hostname)\": Disowning the DTC $I"
dtcmodifyconfs -d $I
test_return 11
done
}

# For each IP address/subnet pair, remove the IP address from the subnet
# using cmmodnet(1m).

function remove_ip_address
{
integer S=0
integer error=0

for I in ${IP[@]}
do
print "$(date '+%b %e %X') - Node \"$(hostname)\": Remove IP address $I from subnet ${SUBNET[$S]}"
XX=$( cmmodnet -r -i $I ${SUBNET[$S]} 2>;&1 )
if (( $? != 0 ))
then
echo $XX | grep "is not configured on the subnet"
if (( $? != 0 ))
then
print "$XX" >;>; $0.log
(( error = 1 ))
fi
fi
(( S = $S + 1 ))
done
if (( $error != 0 ))
then

# `let 0` is used to set the value of $? to 1. The function test_return 
# requires $? to be set to 1 if it has to print error message.

let 0
test_return 12
fi
}

# Unmount each logical volume.

function umount_fs
{
integer UM_CNT=${FS_UMOUNT_COUNT:-1}

if [[ $UM_CNT < 1 ]]
then
   UM_CNT=1
fi

integer L=${#LV[*]}
while (( L >; 0 ))
do 
(( L = L - 1 ))
I=${LV[$L]}
mount | grep -e $I" " >; /dev/null 2>;&1
if (( $? == 0 ))
then
print "$(date '+%b %e %X') - Node \"$(hostname)\": Unmounting filesystem on $I"
print "\tWARNING:   Running fuser to remove anyone using the file system directly."
UM_COUNT=$UM_CNT
while (( $UM_COUNT >; 0 ))
do
fuser -ku $I
umount $I
if (( $? == 0 ))
then
(( UM_COUNT = 0 ))
else
if (( $UM_COUNT == 1 ))
then
let 0
test_return 13
fi
(( UM_COUNT = $UM_COUNT - 1 ))
sleep 1
if (( $UM_COUNT >; 0 ))
then
print "\t$(date '+%b %e %X') - Unmount failed, trying again."
fi
fi
done
fi
done
}


function deactivate_volume_group
{
for I in ${VG[@]}
do
print "$(date '+%b %e %X') - Node \"$(hostname)\": Deactivating volume group $I"
vgchange -a n $I
test_return 14
done
}

# END OF HALT FUNCTIONS.

# FUNCTIONS COMMON TO BOTH RUN AND HALT.

# Test return value of functions and exit with NO RESTART if bad.
# Return value of 0 - 50 are reserved for use by Hewlett-Packard.
# System administrators can use numbers above 50 for return values.
function test_return
{
if (( $? != 0 ))
then
case $1 in
1)
print "\tERROR:  Function activate_volume_group"
print "\tERROR:  Failed to activate $I"
deactivate_volume_group
exit 1
;;

2)
print "\tERROR:  Function check_and_mount"
print "\tERROR:  Failed to fsck one of the logical volumes."
exit_value=1
;;

3)
print "\tERROR:  Function check_and_mount"
print "\tERROR:  Failed to mount $I to ${FS[$F]}"
umount_fs
deactivate_volume_group
exit 1
;;

4)
print "\tERROR:  Function add_ip_address"
print "\tERROR:  Failed to add IP address to subnet"
remove_ip_address
umount_fs
deactivate_volume_group
exit 1
;;

5)
print "\tERROR:  Function get_ownership_dtc"
print "\tERROR:  Failed to own $I"
disown_dtc
remove_ip_address
umount_fs
deactivate_volume_group
exit 1
;;

6)
print "\tERROR:  Function get_ownership_dtc"
print "\tERROR:  Failed to switch $I"
disown_dtc
remove_ip_address
umount_fs
deactivate_volume_group
exit 1
;;

8)
print "\tERROR:  Function start_services"
print "\tERROR:  Failed to start service ${SERVICE_NAME[$C]}"
halt_services
customer_defined_halt_cmds
disown_dtc
remove_ip_address
umount_fs
deactivate_volume_group
exit 1
;;

9)
print "\tFunction halt_services"
print "\tWARNING: Failed to halt service $I"
;;

11)
print "\tERROR:  Function disown_dtc"
print "\tERROR:  Failed to disown $I from ${SUBNET[$S]}"
exit_value=1
;;

12) 
print "\tERROR:  Function remove_ip_address"
print "\tERROR:  Failed to remove $I" 
exit_value=1 
;; 

13) 
print "\tERROR:  Function umount_fs"
print "\tERROR:  Failed to unmount $I"
exit_value=1
;;

14)
print "\tERROR:  Function deactivate_volume_group"
print "\tERROR:  Failed to deactivate $I"
exit_value=1
;;

15)
print "\tERROR:  Function start_resources"
print "\tERROR:  Failed to start resource $I"
stop_resources
halt_services
customer_defined_halt_cmds
disown_dtc
remove_ip_address
umount_fs
deactivate_volume_group
exit 1
;;

16)
print "\tERROR:  Function stop_resources"
print "\tERROR:  Failed to stop resource $I"
exit_value=1
;;

51)
print "\tERROR:  Function customer_defined_run_cmds"
print "\tERROR:  Failed to RUN customer commands"
halt_services
customer_defined_halt_cmds
disown_dtc
remove_ip_address
umount_fs
deactivate_volume_group
exit 1
;;

52)
print "\tERROR:  Function customer_defined_halt_cmds"
print "\tERROR:  Failed to HALT customer commands"
exit_value=1
;;

*)
print "\tERROR:  Failed, unknown error."
;;
esac
fi
}

# END OF FUNCTIONS COMMON TO BOTH RUN AND HALT

#-------------------MAINLINE Control Script Code Starts Here-----------------
#
# FUNCTION STARTUP SECTION.

typeset MIN_VERSION="A.10.03"  # Minimum version this control script works on

integer exit_value=0
typeset CUR_VERSION

#
# Check that this control script is being run on a A.10.03 or later release
# of MC/ServiceGuard or ServiceGuard OPS Edition.  The control scripts are forward 
# compatible but are not backward compatible because newer control 
# scripts use commands and option not available on older releases.

CUR_VERSION="$(/usr/bin/what /usr/lbin/cmcld | /usr/bin/grep "Date" | \
    /usr/bin/egrep '[AB]\...\...|NTT\...\...' | \
    cut -f2 -d" ")"

if [[ "${CUR_VERSION}" = ""  ]] || \
      [[ "${CUR_VERSION#*.}" < "${MIN_VERSION#*.}" ]]
then
    print "ERROR:  Mismatched control script version ($MIN_VERSION).  You cannot run"
    print "\ta version ${MIN_VERSION} control_script on a node running pre"
    print "\t${MIN_VERSION} MC/ServiceGuard or ServiceGuard OPS Edition software"
    exit 1
fi

# Test to see if we are being called to run the package, or halt the package.

if [[ $1 = "start" ]]
then
print "\n\t########### Node \"$(hostname)\": Starting package at $(date) ###########"

activate_volume_group

check_and_mount

add_ip_address

get_ownership_dtc

customer_defined_run_cmds

start_services

start_resources


# Check exit value

if (( $exit_value == 1 ))
then
print "\n\t########### Node \"$(hostname)\": Package start failed  at $(date) ###########"
exit 1 
else 
print "\n\t########### Node \"$(hostname)\": Package start completed  at $(date) ###########"
exit 0 
fi

elif [[ $1 = "stop" ]]
then
print "\n\t########### Node \"$(hostname)\": Halting package at $(date) ###########"


stop_resources

halt_services

customer_defined_halt_cmds

disown_dtc

remove_ip_address

umount_fs

deactivate_volume_group

# Check exit value
if (( $exit_value == 1 ))
then
print "\n\t########### Node \"$(hostname)\": Package halt failed at $(date) ###########"
exit 1 
else 
print "\n\t########### Node \"$(hostname)\": Package halt completed at $(date) ###########"
exit 0 
fi

fi 
附件E:MC/Service Guard配置文件informix.sh
#!/usr/bin/sh
#VERSION="@(#) A.10.06  $Revision: 1.4.1.1 $ $Date: 96/05/20 14:37:42 $"
# **********************************************************************
# **** Startup, Shutdown and Monitor Scripts for INFORMIX (Template) ***
# **********************************************************************
# ******* Note: This file MUST be edited before it can be used. ********
# **********************************************************************
#
# The Informix README file is /opt/toolkit/informix/README
#
# The following variables need to be set:    
#
# VERSION: If you're using Informix version 6.0 or later, set VERSION=on
#    If you're using Informix 5.x or earlier, set VERSION=tb
#    
# INFORMIX_SESSION_NAME:
#
# INFORMIX_HOME: The install directory for Informix        
#
# MONITOR_INTERVAL:  How often (in seconds) to monitor Informix's state.
#
# PACKAGE_NAME: The name of the package as defined in the
# MC/ServiceGuard package configuration script.
#
# TIME_OUT: The amount of time in seconds you want to wait for the
# Informix abort to complete before resorting to killing
# the Informix processes.  The TIME_OUT variable is to
# protect against the worst case of a hung database
# that would prevent the halt script from completing
# and the standby node from starting up the data base.
# The value of TIME_OUT must be less than the time out
# variable set in the package configuration file.
#
# Examples:
# VERSION=on
# INFORMIX_SESSION_NAME=informix
# INFORMIX_HOME=/home/informix
# set -A MONITOR_PROCESSES oninit
# MONITOR_INTERVAL=10
# PACKAGE_NAME=informix
# TIME_OUT=250

VERSION=on
INFORMIX_SESSION_NAME=informix
INFORMIX_HOME=/usr/informix
#set -A MONITOR_PROCESSES oninit Server jhserver
MONITOR_PROCESSES=oninit 
MONITOR_INTERVAL=15
PACKAGE_NAME=pkg1
TIME_OUT=30

HOST=`hostname`
DATE=`date`
PATH=/sbin:/usr/sbin:/usr/bin
       

# START OF INFORMIX START FUNCTION

function run_cmds
{
/bin/su - informix -c "${INFORMIX_HOME}/bin/${VERSION}init" >;/dev/null 2>;&1
/etc/cmcluster/start_bank.sh >;/dev/null 2>;&1

if [[ $? != 0 ]]
then
print "INFORMIX: Database on ${HOST} NOT started!"
else
print "INFORMIX: Database on ${HOST} started!"
fi

}

# START OF INFORMIX HALT FUNCTION
       
function halt_cmds
{
#${0} kill &

/etc/cmcluster/halt_bank.sh >;/dev/null 2>;&1
su - informix -c "${INFORMIX_HOME}/bin/${VERSION}mode -ky" >; /dev/null 2>;&1

if [[ $? != 0 ]]
then
print "INFORMIX: Database $HOST NOT halted!"
else
print "INFORMIX: Database $HOST halted!"
fi
# Clear share memory
SHM=`ipcs -m |grep informix|cut -c 5-9`
for shm in $SHM
do 
ipcrm -m $SHM
done
# Clear message queus 
QUE=`ipcs -q |grep informix|cut -c 5-9`
for que in $QUE
do
ipcrm -q $QUE
done
# Clear semaphone
SEMA=`ipcs -s |grep informix|cut -c 5-9`
for sema in $SEMA
do
ipcrm -s $SEMA
done

# For daemon 
# id=`ps -ef | grep Server | awk '{ print $2 }'`
# kill  ${id}
# id=`ps -ef | grep auto_reverse | awk '{ print $2 }'`
# kill  ${id}
# id=`ps -ef | grep jhserver | awk '{ print $2 }'`
# kill  ${id}

# Make sure all processes have gone away before saying 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=0

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"
unset MONITOR_PROCESSES[$c]
(( c = c + 1 ))
fi
done

if [[ ${MONITOR_PROCESSES[@]} = "" ]]
then
exit
fi

c=0
sleep 5
done
sleep 5 

}

# In case of a database hang we spawn a background process that will issue
# a SIGKILL to each of the monitored processes, this allows us to guarantee
# a time limit for clean halt attempts.

function kill_hung_processes
{
sleep ${TIME_OUT}

for i in ${MONITOR_PROCESSES}
do
id=`ps -ef | grep ${i} | awk '{ print $2 }'`
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 SIGTERM! ***\n"
fi
done
}

# START OF INFORMIX MONITOR FUNCTION

function monitor_processes
{
# Monitor the Informix processes by making sure that all required processes
# are running.

while true
do

for i in ${MONITOR_PROCESSES}
do
ps -ef | grep ${i} | grep -v grep >; /dev/null
if [[ $? != 0 ]]
then
print "\n\n"
ps -ef
print "\n *** ${i} has failed, ABORTING Informix! ***"
set -m
nohup ${0} fault &
set +m
break 2
fi
done

for i in 'BBL -C dom=banka' 'BBL -C dom=bankd' 'BBL -C dom=banks'
do
ps -ef | grep "$i" | grep -v grep >; /dev/null
if [[ $? != 0 ]]
then
print "\n\n"
ps -ef
print "\n *** ${i} has failed, ABORTING Tuxedo ! ***"
set -m
nohup ${0} fault &
set +m
break 2
fi
done

for i in 'WSL -C dom=banka' 'WSL -C dom=bankd' 'WSL -C dom=banks'
do
ps -ef | grep "$i" | grep -v grep >; /dev/null
if [[ $? != 0 ]]
then
print "\n\n"
ps -ef
print "\n *** ${i} has failed, ABORTING Tuxedo ! ***"
set -m
nohup ${0} fault &
set +m
break 2
fi
done
sleep ${MONITOR_INTERVAL}

done
}

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

# FUNCTION STARTUP SECTION.

# Test to see if we are being called to run the application, or halt the 
# application.

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 Informix SESSION $INFORMIX_SESSION_NAME at ${DATE} "

run_cmds
;;

halt)
print "\n \"${HOST}\": Aborting Informix SESSION $INFORMIX_SESSION_NAME at ${DATE} "

halt_cmds
;;

*)
print "Usage: ${0} [ fault | halt | start | monitor ]"
;;
esac

 
附件F:MC/ServiceGuard配置文件start_bank.sh
echo "\n====  Begin Startup  application  ====\n"

# Kill old process
echo "Kill old application process ..." 
for i in `ps -u banka|grep -v "PID"|cut -c 1-7`
do
kill $i
done

for i in `ps -u bankd|grep -v "PID"|cut -c 1-7`
do
kill $i
done

for i in `ps -u banks|grep -v "PID"|cut -c 1-7`
do
kill $i
done

#Clear share memory
echo "Clear share memory ..."
SHM=`ipcs -m |grep banka|cut -c 5-9`
for shm in $SHM
do
ipcrm -m $shm
done

SHM=`ipcs -m |grep bankd|cut -c 5-9`
for shm in $SHM
do
ipcrm -m $shm
done

SHM=`ipcs -m |grep banks|cut -c 5-9`
for shm in $SHM
do
ipcrm -m $shm
done

# Clear message queues
echo "Clear message queues ..."
QUE=`ipcs -q |grep banka|cut -c 5-9`
for que in $QUE
do
ipcrm -q $que
done

QUE=`ipcs -q |grep bankd|cut -c 5-9`
for que in $QUE
do
ipcrm -q $que
done
QUE=`ipcs -q |grep banks|cut -c 5-9`
for que in $QUE
do
ipcrm -q $que
done

# Clear semaphores 
echo "Clear semaphores ..."
SEMA=`ipcs -s |grep banka|cut -c 5-9`
for sema in $SEMA
do
ipcrm -s $sema
done

SEMA=`ipcs -s |grep bankd|cut -c 5-9`
for sema in $SEMA
do
ipcrm -s $sema
done

SEMA=`ipcs -s |grep banks|cut -c 5-9`
for sema in $SEMA
do
ipcrm -s $sema
done

# Start application
echo "Start up application ..."
su - banka -c "tmboot -y"
su - banks -c "tmboot -y"
su - bankd -c "tmboot -y"
sleep 5

echo "\n=== Finish application start up ! ===\n"

附件G:MC/ServiceGuard配置文件halt_bank.sh
echo "\n====  Begin halt application  ====\n"

# Stop application
echo "Stop application ..."
su - banka -c "tmshutdown -y"
su - banks -c "tmshutdown -y"
su - bankd -c "tmshutdown -y"
sleep 5

# Kill process
echo "Kill application process ..." 
for i in `ps -u banka|grep -v "PID"|cut -c 1-7`
do
kill $i
done

for i in `ps -u bankd|grep -v "PID"|cut -c 1-7`
do
kill $i
done

for i in `ps -u banks|grep -v "PID"|cut -c 1-7`
do
kill $i
done

#Clear share memory
echo "Clear share memory ..."
SHM=`ipcs -m |grep banka|cut -c 5-9`
for shm in $SHM
do
ipcrm -m $shm
done

SHM=`ipcs -m |grep bankd|cut -c 5-9`
for shm in $SHM
do
ipcrm -m $shm
done

SHM=`ipcs -m |grep banks|cut -c 5-9`
for shm in $SHM
do
ipcrm -m $shm
done

# Clear message queues
echo "Clear message queues ..."
QUE=`ipcs -q |grep banka|cut -c 5-9`
for que in $QUE
do
ipcrm -q $que
done

QUE=`ipcs -q |grep bankd|cut -c 5-9`
for que in $QUE
do
ipcrm -q $que
done
QUE=`ipcs -q |grep banks|cut -c 5-9`
for que in $QUE
do
ipcrm -q $que
done

# Clear semaphores 
echo "Clear semaphores ..."
SEMA=`ipcs -s |grep banka|cut -c 5-9`
for sema in $SEMA
do
ipcrm -s $sema
done

SEMA=`ipcs -s |grep bankd|cut -c 5-9`
for sema in $SEMA
do
ipcrm -s $sema
done

SEMA=`ipcs -s |grep banks|cut -c 5-9`
for sema in $SEMA
do
ipcrm -s $sema
done

echo "\n=== Finish halt application ===\n"


 ranger 回复于:2003-09-02 22:21:25

佩服!佩服!


 inHP 回复于:2003-09-15 11:51:27

还好,有些步骤没有写进去,不然HP的USD8K安装费就没得赚了。




原文链接:http://bbs.chinaunix.net/viewthread.php?tid=147321
转载请注明作者名及原文出处



收藏本页到: