Well, since we received part of our shipment on Wednesday, I finally looked at how we’re gonna deploy our active/active Tivoli Storage Manager configuration. Right now, we do have a single pSeries box hosting ~100 client nodes which we’re looking to split by two (since we do have two x366 for that purpose now).
Now, as there ain’t no solution for this scenario yet (neither from International Business Machines nor someone out of the open source community), I sat down and started writing an OCF Resource agent for dsmserv (that is the Tivoli Storage Manager server).
At first I had a bit trouble adjusting myself on how stupid/non-standard dsmserv is, but after reading through the Storage Manager Installation handbook (on multiple installations on a single server) and through some peoples notes on multiple deployments of Tivoli Storage Manager on the same server, I think I managed to get my head around it.
I still think the resource agent lacks some real testing (I put a two node cluster online on Tuesday, but that is non-productive), but that’ll happen soon.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 |
#!/bin/sh # # Description: Manages a Tivoli Storage manager as an OCF High-Availability # resource under Heartbeat/LinuxHA control # # Author: Christian Heim (christian.heim@barfoo.org) # Copyright: (C) 2008 Christian Heim # License: GNU General Public License (GPL) # # An example XML-entry for this resource would look like this: # # <primitive class="ocf" id="dsmserv" provider="heartbeat" type="dsmserv"> # <operations> # <op id="dsmserv_mon" interval="5s" name="monitor" timeout="5s"/> # </operations> # <instance_attributes id="dsmserv_inst_attr"> # <attributes> # <!-- # All attributes listed below are required. # You are strongly advised to put them into your configuration, # otherwise the resource agent is gonna fail horribly. # --> # <nvpair id="dsmserv_attr_0" name="prefix" value="/opt/tivoli/tsm/server" /> # <nvpair id="dsmserv_attr_1" name="instance" value="tsm1" /> # <nvpair id="dsmserv_attr_2" name="id" value="ha_client" /> # <nvpair id="dsmserv_attr_3" name="password" value="ha_client" /> # <nvpair id="dsmserv_attr_4" name="TCPAddress" value="10.0.0.10" /> # <nvpair id="dsmserv_attr_5" name="TCPPort" value="1500" /> # <!-- # All below attributes are optional, meaning if you are not putting # anything into the configuration file, the resource agent is going # to use the defaults. # --> # <nvpair id="dsmserv_attr_6" name="max_retries" value="2" /> # <nvpair id="dsmserv_attr_6" name="shutdown_timeout" value="10" /> # <nvpair id="dsmserv_attr_7" name="dsmserv_dir" value="/opt/tivoli/tsm/server/bin" /> # <nvpair id="dsmserv_attr_8" name="dsmclient_dir" value="/opt/tivoli/client/ba/bin" /> # <!-- # If you are unclear, what this agent set a certain variable to, change # the below to "1" to enable the extended debugging to your ha.log. # --> # <nvpair id="dsmserv_attr_9" name="extended_debugging" value="0" /> # </attributes> # </instance_attributes> # </primitive> # # OCF parameters: # OCF_RESKEY_prefix # OCF_RESKEY_instance # OCF_RESKEY_id # OCF_RESKEY_password # OCF_RESKEY_TCPAddress # OCF_RESKEY_TCPPort # OCF_RESKEY_max_retries # OCF_RESKEY_shutdown_timeout # OCF_RESKEY_dsmserv_dir # OCF_RESKEY_dsmclient_dir # OCF_RESKEY_extended_debugging . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs unset LC_ALL; export LC_ALL unset LANGUAGE; export LANGUAGE dsmserv_metadata() { cat <<END <?xml version="1.0"?> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <resource-agent name="dsmserv"> <version>1.0</version> <longdesc lang="en"> This script manages the Tivoli Storage Manager server. Please be aware, that in order to run your Tivoli Storage Manager Server via Heartbeat you need to prepare the according to the Storage Manager Handbook. </longdesc> <shortdesc lang="en">OCF Resource Agent compilant dsmserv script.</shortdesc> <parameters> <parameter name="prefix"> <longdesc lang="en"> Where all your Tivoli Storage Manager Server instances are going to show up. This is adjustable to your wishes, just make sure the directory exists on all possible owners of this resource. </longdesc> <shortdesc lang="en">Prefix for all Tivoli Storage Manager Server instances.</shortdesc> <content type="string" /> </parameter> <parameter name="instance"> <longdesc lang="en"> The Tivoli Storage Manager Server named instance. This is the path to the named instance, which is located on a single file system. </longdesc> <shortdesc lang="en">Name of a single dsmserv instance located in your Prefix.</shortdesc> <content type="string" /> </parameter> <parameter name="TCPAddress"> <longdesc lang="en"> The Tivoli Storage Manager Server instance IP-Address. This is needed for the shutdown command to "nicely" halt the server instead of just sending a kill -9. </longdesc> <shortdesc lang="en">The Tivoli Storage Manager Server IP-Address.</shortdesc> <content type="string" /> </parameter> <parameter name="TCPPort" unique="1"> <longdesc lang="en"> The Tivoli Storage Manager Server instance Port. This is needed for the shutdown command to "nicely" halt the server instead of just sending a kill -9. </longdesc> <shortdesc lang="en">The Tivoli Storage Manager Server Port.</shortdesc> <content type="string" /> </parameter> <parameter name="id"> <longdesc lang="en"> This needs to be an account with ADMIN privileges, in order to correctly halt the server. </longdesc> <shortdesc lang="en">An administrative user (CLASS=SYSTEM) on the TSM server.</shortdesc> <content type="string" /> </parameter> <parameter name="password"> <longdesc lang="en"> The password for the specified user account. </longdesc> <shortdesc lang="en">The password for the specified account on the TSM server.</shortdesc> <content type="string" /> </parameter> <parameter name="max_retries"> <longdesc lang="en"> This defines the amount of retries the script is going to do before continuing. This is useful on busy servers, where you would end up with new sessions before shutting down the server. </longdesc> <shortdesc lang="en">Amount of retries before shutting down the server.</shortdesc> <content type="string" default="2" /> </parameter> <parameter name="shutdown_timeout"> <longdesc lang="en"> Time to wait (in seconds) before killing (as in running kill -9) the server instance. </longdesc> <shortdesc lang="en">Timeout before killing the server instance.</shortdesc> <content type="string" default="5" /> </parameter> <parameter name="dsmserv_dir"> <longdesc lang="en"> Path to the Tivoli Storage Manager Server binaries. This is a feature for multiple purposes. First, its a way to run instances with different versions on the same physical server. Second, if you had to customize the path where your version of Tivoli Storage Manager Server is installed, then use this to adjust the used path. </longdesc> <shortdesc lang="en">Path to the TSM server binaries.</shortdesc> <content type="string" default="/opt/tivoli/tsm/server/bin" /> </parameter> <parameter name="dsmclient_dir"> <longdesc lang="en"> Path to the Tivoli Storage Manager Administrative Console binary. This is a feature for multiple purposes. First, its a way to run instances with different versions on the same physical server. Second, if you had to customize the path where your version of Tivoli Storage Manager Administrative Console is installed, then use this to adjust the used path. </longdesc> <shortdesc lang="en">Path to the TSM Administrative Console binary.</shortdesc> <content type="string" default="/opt/tivoli/tsm/client/ba/bin" /> </parameter> <parameter name="extended_debugging"> <longdesc lang="en"> Enables the somewhat extensive debugging features in this OCF Resource Agent. This is coming in handy, if you suspect that either this Agent or something other is screwing up. </longdesc> <shortdesc lang="en">Enables the extended debugging.</shortdesc> <content type="string" default="0" /> </parameter> </parameters> <actions> <action name="start" timeout="90" /> <action name="stop" timeout="100" /> <action name="monitor" depth="10" timeout="30s" interval="60s" start-delay="1s" /> <action name="validate-all" timeout="30s" /> <action name="meta-data" timeout="5s" /> <action name="status" timeout="30s" /> </actions> </resource-agent> END exit $OCF_SUCCESS } dsmserv_settings() { # Settings the above mentioned defaults. : ${OCF_RESKEY_max_retries:=2} : ${OCF_RESKEY_shutdown_timeout:=5} : ${OCF_RESKEY_dsmserv_dir:=/opt/tivoli/tsm/server/bin} : ${OCF_RESKEY_dsmclient_dir:=/opt/tivoli/tsm/client/ba/bin} : ${OCF_RESKEY_extended_debugging:=0} : ${DSMSERV_DIR:=$OCF_RESKEY_dsmserv_dir} : ${DSMSERV_CONFIG:=$OCF_RESKEY_prefix/$OCF_RESKEY_instance/dsmserv.opt} : ${DSMADMC:=$OCF_RESKEY_dsmclient_dir/dsmadmc} # Make sure we put a note into the log about unconfigured # $OCF_RESKEY_TCPAddress and $OCF_RESKEY_TCPPort. if $TEST -z "$OCF_RESKEY_TCPAddress" -o -z "$OCF_RESKEY_TCPPort" ; then ocf_log info "Either $OCF_RESKEY_TCPAddress or $OCF_RESKEY_TCPPort are not configured." ocf_log info "This isn't a major fault (if you are only running a single instance" ocf_log info "for high-availibility), but it is gonna make this script fail if you are having" ocf_log info "multiple instances running on different ports." fi } dsmserv_checkstatus() { kill -0 "$1" >/dev/null 2>&1 } dsmserv_getpid() { $AWK --source '{print $4}' $OCF_RESKEY_prefix/$OCF_RESKEY_instance/dsmserv.lock 2>/dev/null } dsmserv_debuginfo() { if $TEST $OCF_RESKEY_extended_debugging ; then # Some debug information, makes it easier finding configuration mistakes. ocf_log debug " " ocf_log debug "$OCF_RESKEY_prefix: "$OCF_RESKEY_prefix"" ocf_log debug "$OCF_RESKEY_instance: "$OCF_RESKEY_instance"" ocf_log debug "$OCF_RESKEY_id: "$OCF_RESKEY_id"" ocf_log debug "$OCF_RESKEY_TCPAddress: "$OCF_RESKEY_TCPAddress"" ocf_log debug "$OCF_RESKEY_TCPPort: "$OCF_RESKEY_TCPPort"" ocf_log debug "$OCF_RESKEY_max_retries: "$OCF_RESKEY_max_retries"" ocf_log debug "$OCF_RESKEY_shutdown_timeout: "$OCF_RESKEY_shutdown_timeout"" ocf_log debug "$OCF_RESKEY_dsmserv_dir: "$OCF_RESKEY_dsmserv_dir"" ocf_log debug "$OCF_RESKEY_dsmclient_dir: "$OCF_RESKEY_dsmclient_dir"" ocf_log debug " " ocf_log debug "$DSMSERV_DIR: "$DSMSERV_DIR"" ocf_log debug "$DSMSERV_CONFIG: "$DSMSERV_CONFIG"" ocf_log debug "$DSMADMC: "$DSMADMC"" ocf_log debug " " fi } dsmserv_checksetup() { # Move the checks for dsmserv/dsmadmc binaries and dsmserv.opt/dsmserv.dsk # into a single function. dsmserv_settings local EXIT="" case "$1" in start) EXIT="$OCF_NOT_RUNNING" ;; validate) EXIT="$OCF_ERR_ARGS" ;; esac dsmserv_debuginfo # Terminate rather here than later with a half-hanging dsmserv instance, due to # main configuration values not being set properly. ocf_log debug "Probing whether or not $OCF_RESKEY_prefix, $OCF_RESKEY_instance, $OCF_RESKEY_id" ocf_log debug "and $OCF_RESKEY_password are set." if $TEST -z "$OCF_RESKEY_prefix" -o -z "$OCF_RESKEY_instance" -o -z "$OCF_RESKEY_id" -o -z "$OCF_RESKEY_password" ; then ocf_log err "Your configuration is missing the most important settings." ocf_log err "Please check whether you missed either of the following:" ocf_log err "$OCF_RESKEY_prefix, $OCF_RESKEY_instance, $OCF_RESKEY_id or $OCF_RESKEY_password." ocf_log err "This is a non-recoverable, fatal error!" exit $EXIT fi # Check for the 'dsmserv' binary from TIVsm-server ocf_log debug "Probing for existance of $DSMSERV_DIR/dsmserv." if $TEST ! -x $DSMSERV_DIR/dsmserv ; then ocf_log err "You are lacking a version of IBMs Tivoli Storage Manager Server." ocf_log err "Make sure you have the TIVsm-server RPM installed. Please check the debug log for further information." ocf_log err "This is a non-recoverable, fatal error!" exit $EXIT fi # Check for the 'dsmadmc' binary from TIVsm-BA ocf_log debug "Probing for existance of $DSMADMC." if $TEST ! -x $DSMADMC ; then ocf_log err "You are lacking a version of IBMs Tivoli Storage Manager Client." ocf_log err "Make sure you have the TIVsm-BA RPM installed. Please check the debug log for further information." ocf_log err "This is a non-recoverable, fatal error!" exit $EXIT fi # Check for 'dsmserv.opt' and 'dsmserv.dsk' in $OCF_RESKEY_prefix/$OCF_RESKEY_instance. if $TEST ! -f $DSMSERV_CONFIG -o ! -f ${DSMSERV_CONFIG%/*}/dsmserv.dsk ; then ocf_log err "Either $DSMSERV_CONFIG or ${DSMSERV_CONFIG%/*}/dsmserv.dsk for dsmserv instance "$OCF_RESKEY_instance"" ocf_log err "could not be found, thus exiting. The Tivoli Storage Manager Instance you are trying to run, needs" ocf_log err "to be prepared in order to be run by Heartbeat! Also, please check the debug log for further information." ocf_log err "This is a non-recoverable, fatal error!" exit $EXIT fi return $OCF_SUCCESS } dsmserv_start() { if ocf_is_root ; then : ; else ocf_log err "You must be root." exit $OCF_ERR_PERM fi if dsmserv_status ; then ocf_log info "dsmserv instance "$OCF_RESKEY_instance" is already running." exit $OCF_SUCCESS fi dsmserv_checksetup "start" export DSMSERV_CONFIG=$DSMSERV_CONFIG export DSMSERV_DIR=$DSMSERV_DIR # May be removed, still need to test it. cd ${DSMSERV_CONFIG%/*} $DSMSERV_DIR/dsmserv >>/var/log/dsmserv_$OCF_RESKEY_instance.log 2>&1 & unset DSMSERV_CONFIG unset DSMSERV_DIR if $TEST $? -ne 0 ; then ocf_log err "Error. dsmserv instance "$OCF_RESKEY_instance" returned error $?." exit $OCF_ERR_GENERIC fi ocf_log info "Started dsmserv instance "$OCF_RESKEY_instance"." exit $OCF_SUCCESS } dsmserv_stop() { if dsmserv_status ; then PID="$( dsmserv_getpid )" dsmserv_settings dsmserv_debuginfo local CMD="$DSMADMC -id=$OCF_RESKEY_id -password=$OCF_RESKEY_password -noconfirm -displaymode=list -tcpserveraddress=$OCF_RESKEY_TCPAddress -tcpport=$OCF_RESKEY_TCPPort" local i=1 while $TEST $i -le $OCF_RESKEY_max_retries; do # Check whether or not we need to terminate any running processes first. PROCESSES="$( $CMD query process | $EGREP 'Process Number: .*' | $AWK -F ': ' '{ print $2 }' )" ocf_log debug "Try #$i: Processing shutdown tests 1/2 (running processes) for dsmserv instance "$OCF_RESKEY_instance"" ocf_log debug "Executing "$CMD query process | $EGREP 'Process Number: .*' | $AWK -F ': ' '{ print $2 }'"" ocf_log debug "Process list: '$PROCESSES'" if $TEST -n $PROCESSES ; then ocf_log debug "Try #$i: Processing shutdown steps 1/2 (running processes) for dsmserv instance "$OCF_RESKEY_instance"" ocf_log info "Try #$i: Canceling all active processes." for process in $PROCESSES; do ocf_log debug "Executing "$CMD cancel process $process"" $CMD cancel process $process >>/var/log/dsmadmc.log 2>&1 done fi # Check whether or not we need to unmount the drives first. VOLUMES="$( $CMD query mount | $EGREP 'LTO volume .* is mounted' | $AWK -F ' ' '{ print $4 }' )" ocf_log debug "Try #$i: Processing shutdown tests 2/2 (volume mounts) for dsmserv instance "$OCF_RESKEY_instance"" ocf_log debug "Executing "$CMD query mount | $EGREP 'LTO volume .* is mounted' | $AWK -F ' ' '{ print $4 }'"" ocf_log debug "Mounted volumes: '$VOLUMES'" if $TEST -n "$VOLUMES" ; then ocf_log debug "Try #$i: Processing shutdown steps 2/2 (volume mounts) for dsmserv instance "$OCF_RESKEY_instance"" ocf_log info "Try #$i: Dismounting all mounted volumes." for tape in $VOLUMES; do ocf_log debug "Executing "$CMD dismount volume $tape"" $CMD dismount volume $tape >>/var/log/dsmadmc.log 2>&1 done fi i=$(($i+1)) done # Now, halt the server instance ocf_log info "Trying to send the 'HALT' command to the dsmserv instance "$OCF_RESKEY_instance"." ocf_log debug "Executing "$CMD halt"" $CMD halt >>/var/log/dsmadmc.log 2>&1 local i=1 while $TEST $i -le $OCF_RESKEY_max_retries; do ocf_log debug "Try #$i: Waiting for $OCF_RESKEY_shutdown_timeout seconds." sleep $OCF_RESKEY_shutdown_timeout i=$(($i+1)) done if dsmserv_checkstatus "$PID" ; then ocf_log err "Sending the 'HALT' command to the dsmserv instance "$OCF_RESKEY_instance" failed." ocf_log debug "The server might still be shutting down, try increasing $OCF_RESKEY_shutdown_timeout." ocf_log info "Proceeding with a SIGTERM." kill $PID if $TEST $? -ne 0 ; then ocf_log err "Ending the dsmserv instance "$OCF_RESKEY_instance" with SIGTERM failed." ocf_log info "Proceeding with a SIGKILL." kill -SIGKILL $PID if $TEST $? -ne 0 ; then ocf_log err "Ending the dsmserv instance "$OCF_RESKEY_instance" with SIGKILL failed." ocf_log err "Failed ending the process, giving up. User intervention is required." return $OCF_ERR_GENERIC fi fi fi fi ocf_log info "Stopped dsmserv instance "$OCF_RESKEY_instance"." exit $OCF_SUCCESS } dsmserv_status() { if $TEST -f $OCF_RESKEY_prefix/$OCF_RESKEY_instance/dsmserv.lock ; then # dsmserv is probably still running PID="$( dsmserv_getpid )" if $TEST -n $PID ; then dsmserv_checkstatus "$PID" >/dev/null && [ `ps -p $PID | grep dsmserv | wc -l` -eq 1 ] return $? fi fi false } dsmserv_monitor() { if dsmserv_status ; then return $OCF_SUCCESS else return $OCF_NOT_RUNNING fi } dsmserv_usage() { echo "Usage: $0 {start|stop|status|monitor|validate-all}" >&2 exit $OCF_SUCCESS } case "$1" in start) dsmserv_start ;; stop) dsmserv_stop ;; status) dsmserv_status ;; monitor) dsmserv_monitor ;; validate-all) dsmserv_checksetup "validate" ;; meta-data) dsmserv_metadata ;; usage) dsmserv_usage ;; notify|demote|promote|migrate_to|migrate_from|reload|recover) exit $OCF_ERR_UNIMPLEMENTED ;; *) dsmserv_usage exit $OCF_ERR_UNIMPLEMENTED ;; esac |
As you can see, I reworked the “stop” phase, to first terminate all running processes and then dismount all tapes in order to avoid data corruption (that was an advice from our friendly IBM systems engineer); if that fails, try terminating it by a “friendly” kill (SIGTERM); and if that ain’t helping, kill it the “Die Hard Way”™ (SIGKILL).
2 thoughts to “Linux-HA and Tivoli Storage Manager”