Sun Cluster Geographic Edition 系统管理指南

创建角色更改操作脚本

您可以对 Sun Cluster Geographic Edition 软件加以配置,使其在保护组中某个群集的角色从 secondary 变为 primary 时运行一条命令。这种角色更改可能是切换或接管操作的结果。

该操作命令在角色发生变化(即从辅助变为主要)的群集上执行。命令参数提供了事件信息。该脚本在 Sun Cluster Geographic Edition 软件使资源组进入联机状态前执行。以下命令行即运行该脚本:


# custom-action-command-path -o primary -c cluster-name \ 
 -s partnership-name protection-group-name user-arguments
custom-action-command-path

指定您已创建的操作命令的路径。

-o primary

指定群集担当的角色为 primary

-c cluster-name

指定新担当主群集角色的辅助群集的名称。

-s partnership-name

指定容纳保护组的伙伴关系的名称。

protection-group-name

指定正在经历角色更改的保护组的名称。

user-arguments

指定在所有 Sun Cluster Geographic Edition 提供选项后传递的静态参数。

这种格式自由的字符串可根据需要由脚本进行解析。例如,您可以指定一列 key=value 对,如 name=sun.com,ip=10.1.2.3。您还可以指定选项序列,如 -n sun.com -a 10.1.2.3.4。上述参数的格式不受 Sun Cluster Geographic Edition 软件的限制。

角色更改操作脚本的退出状态是作为 geopg switchovergeopg takeover 命令结果的一部分加以报告的。如果成功启动该操作脚本,则退出状态为零。非零的退出状态表明出现了错误或故障。退出状态的值不会影响角色更改操作的其他方面。无论操作脚本的退出状态如何,切换或接管操作均会继续使保护组中的应用程序资源组进入联机状态。

在继续执行其他操作之前,您应该等待脚本返回结果。创建操作脚本时,请考虑运行脚本所需的时间。


示例 14–1 用于更新 DNS 的切换操作脚本

本示例创建的脚本使用 nsupdate 命令,该脚本可重新配置主机名以指向新的群集。有关 nsupdate 命令的更多信息,请参阅 nsupdate(1M) 手册页。

名称服务使尝试连接 companyX.com 的客户机指向保护组主群集 cluster-paris 的地址。当主群集未能响应时,管理员将执行使保护组切换到备用群集 cluster-newyork 的操作。


#!/bin/ksh
# script to update dns
# Assumes each cluster has an entry with name "lh-paris-1" in /etc/hosts
# but different value for the IP in each cluster
# for forward DNS (A) entry: will delete old entry for "lh-paris-1"
# and add one that is correct for "this cluster"
#
# For reverse (PTR) DNS entry, will just add one for this cluster. 
# Will NOT delete PTR record left over from old cluster. So
# eventually you will just have reverse lookup for the IP for both clusters
# doing reverse resolution to the same name (lh-paris-1.odyssey.com)
# This should be fine, as long as the forward resolution stays "correct"
#
# The blank line of input at the end of nsupdate is REQUIRED
#
# A short TTL is put on the new records (600 = 10 minutes)
# but you can't really control what kind of caching goes on on
# the client side


# get IP corresponding to name "lh-paris-1" on THIS Cluster
NEWIP=$(getent hosts lh-paris-1|cut -f1)

# this bit splits out the octets in order to add the reverse PTR entry
IFS=.
set $NEWIP
unset IFS

/usr/sbin/nsupdate <<ENDNSUPDATE
update delete ora-lh.odyssey.com A
update add ora-lh.odyssey.com 600 A $NEWIP
update add $4.$3.$2.$1.in-addr.arpa 600 PTR ora-lh.odyssey.com.

ENDNSUPDATE