HOWTO: Setup DSH PDF Print E-mail
User Rating: / 3
Written by Michael Felt   

DSH: The basics

I have used dsh a lot over the years, but I always had trouble getting it setup quickly. Here you will find the bare basics to get dsh up and running.


1. Fileset names

Starting with AIX 6.1 TL3 the fileset name changed from csm.dsh to dsm.dsh.
The current fileset for AIX 5.3 and AIX 6.1 through 6100-02 (or AIX 6.1 TL2) is:
  csm.dsh              C     F    Cluster Systems Management Dsh
And on AIX 6.1 TL3 and later the fileset of choice is:
  dsm.dsh             C     F    Distributed Systems Management

2. Define environment variables to make life easier!

export DSH_NODE_RSH=/usr/bin/ssh
export DSH_NODE_RCP=/usr/bin/scp
export DSH_NODE_LIST=$HOME/.dsh/AllNodes
export DSH_NODEGROUP_PATH=${HOME}/.dsh/grps   # create files in this directory for different lists
## possible alturnate port and/or username
export DSH_NODE_OPTS="-p 22 -l root"
export DCP_NODE_OPTS="-p 22 -l root"
# do not want to wait forever when virtual machines are turned off
export DSH_TIMEOUT=3

3. You need a known_hosts relationship to use dsh

The first step is to is to get all the hosts you want to contact included in $HOME/.ssh/known_hosts -- and maybe in AllNodes as well. I use this script to get both short and longname included. I should probably add a line that adds the IP address as well (each are unique known_hosts entries).
Note - both short and longnames are needed because dsh generally expands a shortname argument to a longname when it connects to the remote host.

# run the date command on remote hosts using dsh.
# if dsh fails run ssh to add key to known_hosts
# using both short and long names
for shortname in $*
dsh -n $shortname -r /usr/bin/ssh -l root date
if [[ $? != 0 ]]; then
    print "$0: the command\n>> dsh -n $shortname -r /usr/bin/ssh -l root date <<\nreturned an error"
    print "$0: executing a ssh command to fix common authentification problems\n"

    nslookup $shortname | grep Name: | read xxx fullname
    print "$0: answer yes to both: ssh root@$fullname date\n and sh root@$shortname date"

    print "$0: executing >>ssh root@$fullname date<<"
    ssh root@$fullname date
    print "$0: executing >>ssh root@$shortname date<<"
    print "\nssh root@$shortname date"
    ssh root@$shortname date
    [[ ! -z ${DSH_NODE_LIST} ]] && [[ -e ${DSH_NODE_LIST} ]] && \
    (grep $shortname ${DSH_NODE_LIST} || print $shortname >> ${DSH_NODE_LIST})

< Prev   Next >