DYNIX/ptx V4.5.3 and Layered Products Software Installation Release Notes: Script to Compare Names and Serial Numbers of Shared Disks


Appendix E
Script to Compare Names and Serial Numbers of Shared Disks

This appendix provides a sample script that is run on one node of a clustered-system to assist you in determining if the names of the shared disks need to be synchronized.


ATTENTION

Because each site configuration is unique, this script is not provided in electronic form on any distribution media. Instead, use it as an example to help plan and create your own site-specific script.



Compare the Names and Serial Numbers of Shared Disks on all Nodes

The sample script is run from one node of a clustered-system to determine whether the shared disks in the cluster have the same name, with the same serial number, in each node's naming database.


ATTENTION

The sample script should be run on the node of the cluster that has your desired shared disk naming conventions. The output from the script is relative to the node it is run on and generates suggested commands to rename the shared disk names on the other cluster nodes so they will match this reference node.


The script uses the dumpconf command to determine which disks on a node are shared. Then, it executes the diskid command for each identified disk to determine the serial number of the disk.

Because the scsibus name associated with a disk could be different on each node, you cannot directly compare the diskid output from each node. Instead, the sample script distills the diskid output from each node such that only name:serialnumber pairs remain for each disk. The script writes the resulting output for each node to a file called /tmp/diskserials.nodename, for example, /tmp/diskserials.myhost.

The contents of such a file are similar to the following:

sd100:680932A4
sd101:68090BE8
sd102:6809619A

After a file is created for each node, the sample script compares the files. When the script does not detect any mismatches between the name:serialnumber pairs, output similar to the following is displayed:

Gathering shared disk names and serial numbers on node1 
Gathering shared disk names and serial numbers on node2 
Comparing disk names on node1 to the names on node2 
No action required for nodes: node1 node2

However, when the script detects mismatches, output similar to the following is displayed:

Gathering shared disk names and serial numbers on node1 
Gathering shared disk names and serial numbers on node2 
Comparing disk names on node1 to the names on node2 
WARNING: names do not match between: node1 node2 
Please review the files: 
  /tmp/diskserials.node1 which is the reference name list, 
  /tmp/diskserials.node2 which lists the names on node2, 
  /tmp/diskrenames.node2 which contains possible solutions.

Use Disk Renaming Suggestions to Synchronize Shared Disk Names

In the case of mismatches, the sample script creates an additional file called /tmp/diskrenames.nodename. This file contains suggested renaming solutions for the shared disk names on the indicated node and includes output similar to the following:

# Disk serial number 68093770 named sd141 on node1 and sd201 on node2 
# Suggested action to take on node2: 
devctl -n sd201 sd141 
# Disk serial number 680983EB named sd140 on node1 and sd200 on node2 
# Suggested action to take on node2: 
devctl -n sd200 sd140

The sample script assumes that the names of the shared disks on the node where the script was run are the preferred names. Therefore, the suggested solutions are to rename the mismatched names on the other node of the cluster to match the preferred names. However, these suggestions might not be appropriate for your host.

For example, if the preferred name of a shared disk is sd100, but the second node already has a different disk named sd100, then you cannot rename the mismatched disk on the second node. In this case, you either have to make the preferred name available on the second host (rename the sd100 to a different name first) or you change the disk name on the reference node to a name that does not conflict with the other nodes.


ATTENTION

If you change the name of a device, be sure that all references to that device (such as entries in the vfstab file, ORACLE data files, and ptx/SVM devices) now point to the new name of the device.


After you have evaluated the contents of the /tmp/diskrenames.nodename file and determined that the renaming suggestions are acceptable to the host involved, you can copy the file to the node where you need to do the renaming operations. You can then manually execute this file. You must run the /tmp/diskrenames.nodename script as root.

If there are any name conflicts that prevent renaming from happening, the renaming script does not attempt to resolve the issues. If this happens, you must examine the errors and take appropriate actions to synchronize the shared disk names on the cluster.


Sample Script Contents

This sample script should be run as a non-root user that has the ability to remotely execute (resh) commands on all nodes of the cluster.

#!/bin/ksh
# An example script which determines whether shared disks have the same name 
# on all nodes of a clustered system.  (Only applicable on ptx v4.4.x.) 
# This is not a supported tool, it is provided as an example only.  

# Pipe dumpconf -m to this function for a list of shared disk names. 
function dumpconfm2shared 
{ 
  awk -F: '{if (($1 ~ /^sd[0-9]/) && ($8 ~ /^S/)) print $1}' - 
} 
 
# Pipe diskid to this function to extract the name:serialnumber. 
function diskid2serial 
{ 
  awk '{if ($1 ~ /^sd[0-9]/) printf("%s",$1); if ($1 == "Vendor") \
  print $NF}' - 
} 
 
# Sort name:serialnumber records by serialnumber. 
function sortbyserial 
{ 
  sort -t: -k 2 
} 
 
thisnode=`/bin/uname -n` 
nodes=`/bin/clustadm -m all` 
 
# For each node create a file with the shared disk names and serial numbers. 
for node in $nodes 
do 
  echo "Gathering shared disk names and serial numbers on $node" 
  resh $node /etc/dumpconf -m \ 
    | dumpconfm2shared \ 
    | resh $node /usr/bin/xargs -l1 /etc/diskid \ 
    | diskid2serial | sortbyserial >| /tmp/diskserials.$node 
done
  
# Compare the serial number files of every other node to this nodes file. 
for node in $nodes 
do 
  if [ "$node" != "$thisnode" ]; then 
    echo "Comparing disk names on $thisnode to the names on $node" 
    if cmp -s /tmp/diskserials.$node /tmp/diskserials.$thisnode 
    then 
      echo "No action required for nodes: $thisnode $node" 
    else 
      echo "WARNING: names do not match between: $thisnode $node" 
      cat /tmp/diskserials.$thisnode | while read record 
      do 
        namethisnode=${record%:*} 
        serialthisnode=${record#*:} 
        recordthatnode=`grep ":${serialthisnode}$" /tmp/diskserials.$node` 
        namethatnode=${recordthatnode%:*} 
        if [ "$namethisnode" != "$namethatnode" ] 
        then 
          echo "# Disk serial number $serialthisnode named $namethisnode"\ 
               "on $thisnode and $namethatnode on $node" 
          echo "# Suggested action to take on $node:" 
          echo "devctl -n $namethatnode $namethisnode" 
        fi 
      done >| /tmp/diskrenames.$node 
      echo "Please review the files:" 
      echo "  /tmp/diskserials.$thisnode which is the reference name list," 
      echo "  /tmp/diskserials.$node which lists the names on $node,"
      echo "  /tmp/diskrenames.$node which contains possible solutions." 
    fi 
  fi 
done