Linux-cluster

IBM CSM dsh, dcp Script

hongiiv 2007. 2. 2. 17:35
반응형

============================================================
Example 7-3 dgshell distributed shell command
============================================================
[root@node-a /root]# cat > /usr/local/bin/dgshell
#!/usr/bin/perl
$commands=join " ",@ARGV;
system "/bin/cat /tmp/gpfs.allnodes | /usr/bin/xargs -i /usr/bin/ssh {} \'hostname; echo
\"------\"; $commands; echo\'";
exit;
[root@node-a /root]# chmod 755 /usr/local/bin/dgshell

============================================================
Example 7-4 dgcopy distributed copy command
============================================================
[root@node-a /root]# cat > /usr/local/bin/dgcopy
#!/usr/bin/perl
if ($#ARGV != 1)
{print "Error: ";
print "Missing argument.\n";
print "Usage: dgshell local_filename remote_filename\n";
exit 1;
}
$in=$ARGV[0];
$out=$ARGV[1];
if ($in eq $out)
{print "Error: \n";
print "The localfile name and the remote filename must be different\n";
print "Otherwise your file will be corrupted during copying to the localhost\n";
exit 1;
}
system "/bin/cat /tmp/gpfs.allnodes | /usr/bin/xargs -i /usr/bin/scp $in {}:$out";
exit;
[root@node-a /root]# chmod 755 /usr/local/bin/dgcopy
[root@node-a /root]#

============================================================
Example 7-5 dgshell and dgcopy usage
============================================================
[root@node-a /root]# dgshell date
node-a
------
Thu Nov 15 17:54:49 CST 2001
node-b
------
Thu Nov 15 17:54:49 CST 2001
node-c
------
Thu Nov 15 17:54:50 CST 2001
[root@node-a /root]# dgcopy /root/gpfs.allnodes /tmp/gpfs.allnodes
gpfs.allnodes 100% |*****************************| 21 00:00
gpfs.allnodes 100% |*****************************| 21 00:00
Note: The /usr/bin/xargs command can run multiple processes at the same
time by using the command line option -P n, where n is the maximum number
of processes. In Example 7-3 on page 188 we are not using this option
because, since more than one process will be running at the same time, the
output of all commands may be mixed. If you want to run the commands on all
nodes as simultaneously as possible, use /usr/bin/xargs -i -P 0, but be
aware of the mixed output that you may receive.
190 Linux Clustering with CSM and GPFS
gpfs.allnodes 100% |*****************************| 21 00:00
[root@node-a /root]#

반응형