Linux 分布式shell工具dsh
dsh是“Distributed Shell”或“Dancer’s Shell”的缩写,可以实现在多个 Linux 服务器上运行命令。
1.安装
Debian系
| # apt install dsh |
源码安装
编译库
| wget http://www.netfort.gr.jp/~dancer/software/downloads/libdshconfig-0.20.10.cvs.1.tar.gz tar xfz libdshconfig*.tar.gz cd libdshconfig-* ./configure ; make make install |
编译dsh
| wget https://www.netfort.gr.jp/~dancer/software/downloads/dsh-0.22.0.tar.gz tar xfz dsh-0.22.0.tar.gz cd dsh-* ./configure ; make make install |
2.配置链接方式
| # cat /etc/dsh/dsh.conf remoteshell =ssh |
3.配置主机列表
| # cat /etc/dsh/machines.list test1 test2 |
当同时访问多台计算机时,最好设置免密登录。
4.测试
| # dsh -aM -c uptime test1: test1: Authorized users only. All activities may be monitored and reported. test2: test2: Authorized users only. All activities may be monitored and reported. test1: 16:34:46 up 60 days, 1:21, 6 users, load average: 1.38, 1.32, 1.29 test2: 16:34:46 up 15 days, 1:11, 2 users, load average: 0.00, 0.03, 0.06 |