7.2. DSH,分布式 Shell
在撰写本文时(2003 年 5 月),DSH 的最新版本可从 http://www.netfort.gr.jp/~dancer/software/downloads/ 获取。有关该软件包的更多信息,请访问 http://www.netfort.gr.jp/~dancer/software/dsh.html 可供下载的最新版本是 0.23.6。您将需要 libdshconfig-0.20.8.tar.gz 和 dsh-0.23.5.tar.gz。首先安装 libdshconfig。
./configure
make
make install |
对 dsh 软件包重复此过程。
假设我们有一个包含几个节点的小型集群。为了简化操作,我们希望只输入一次命令,但使其在每个节点上执行。然后,您必须在 $HOME/.dsh/group/clusterwname 中创建一个文件,其中列出您的集群的 IP 地址。例如:
[root@inspon root]# cat .dsh/group/mosix
192.168.10.220
192.168.10.84 |
例如,我们在每台机器上运行 ls。我们使用 -g 来使用 mosix 组(通过这种方式,您可以创建具有不同配置的组子集)。
[root@inspon root]# dsh -r ssh -g mosix ls
192.168.10.84: anaconda-ks.cfg
192.168.10.84: id_rsa.pub
192.168.10.84: install.log
192.168.10.84: install.log.syslog
192.168.10.84: openmosix-kernel-2.4.17-openmosix1.i686.rpm
192.168.10.84: openmosix-tools-0.2.0-1.i386.rpm
192.168.10.220: anaconda-ks.cfg
192.168.10.220: id_dsa.pub
192.168.10.220: id_rsa.pub
192.168.10.220: openmosix-kernel-2.4.17-openmosix1.i686.rpm
192.168.10.220: openmosix-tools-0.2.0-1.i386.rpm
192.168.10.220: oscar-1.2.1rh72
192.168.10.220: oscar-1.2.1rh72.tar.gz |
请注意,这些机器都没有要求输入密码。这是因为我们已经在不同帐户之间设置了 RSA 身份验证。如果您想运行带有多个参数的命令,您要么需要将命令放在引号之间。
[root@inspon root]# dsh -r ssh -g mosix "uname -a"
192.168.10.84: Linux omosix2.office.be.stone-it.com 2.4.17-openmosix1 #1
Wed May 29 14:32:28 CEST 2002 i686 unknown
192.168.10.220: Linux oscar0 2.4.17-openmosix1 #1 Wed May 29 14:32:28 CEST
2002 i686 unknown |
或者使用 -c -- 选项。两者都给出基本相同的输出。
[root@inspon root]# dsh -r ssh -g mosix -c -- uname -a
192.168.10.220: Linux oscar0 2.4.17-openmosix1 #1 Wed May 29 14:32:28 CEST
2002 i686 unknown
192.168.10.84: Linux omosix2.office.be.stone-it.com 2.4.17-openmosix1 #1
Wed May 29 14:32:28 CEST 2002 i686 unknown |