项目地址:
https://code.google.com/p/parallel-ssh/downloads/list
安装略......
参数介绍:
-h 执行命令的远程主机列表 或者 -H user@ip:port 文件内容格式[user@]host[:port]
-l 远程机器的用户名
-P 显示执行输出
-p 一次最大允许多少连接
-o 输出内容重定向到一个文件
-e 执行错误重定向到一个文件
-t 设置命令执行的超时时间
-A 提示输入密码并且把密码传递给ssh
-O 设置ssh参数的具体配置,参照ssh_config配置文件
-x 传递多个SSH 命令,多个命令用空格分开,用引号括起来
-X 同-x 但是一次只能传递一个命令
-i 显示标准输出和标准错误在每台host执行完毕后
pssh- (平行的)Parallel SCP,与ClusterSSh或GEXEC相似。
pscp- Parallel SCP,允许用户以与PCP类似的方式拷贝文件到多个节点。
prsync- prsync工具自动化地在多个节点上平行的运行rsync,本质上来说是另一个拷贝文件或整个目录树到大量远程节点的方法。
pnuke- pnuke命令可以被用来终止运行在多个节点上的大量进程。
pslurp- pslurp工具与pscp类似,它是设计用来从一个主机集合中拷贝文件,它允许用户拷贝.
========================================================
1:需要做信任关系 这个就不多说了 网上文档一堆
2:ip_list.txt格式定义
[root@control work]# cat ip_list.txt
root@192.168.0.120:10000
root@192.168.0.121:10000
root@192.168.0.122:10000
root@192.168.0.124:10000
root@192.168.0.125:10000
root@192.168.0.126:10000
root@192.168.0.127:10000
3:批量执行命令:
[root@control work]# pssh -h ip_list.txt -P "hostname"
192.168.0.120: club.com
[1] 10:23:21 [SUCCESS] root@192.168.0.120:10000
192.168.0.121: db1
[2] 10:23:21 [SUCCESS] root@192.168.0.121:10000
192.168.0.126: WEB1
192.168.0.124: SVN1
[3] 10:23:21 [SUCCESS] root@192.168.0.126:10000
[4] 10:23:21 [SUCCESS] root@192.168.0.124:10000
192.168.0.125: SVN2
[5] 10:23:21 [SUCCESS] root@192.168.0.125:10000
192.168.0.127: WEB2
[6] 10:23:21 [SUCCESS] root@192.168.0.127:10000
192.168.0.122: db2
[7] 10:23:21 [SUCCESS] root@192.168.0.122:10000
4:批量文件传输:(本地到远程)
[root@control work]# pscp -h ip_list.txt /home/work/test.txt /home/zhangly/
[1] 10:33:34 [SUCCESS] root@192.168.0.120:51022
[2] 10:33:34 [SUCCESS] root@192.168.0.126:51022
[3] 10:33:34 [SUCCESS] root@192.168.0.121:51022
[4] 10:33:34 [SUCCESS] root@192.168.0.124:51022
[5] 10:33:34 [SUCCESS] root@192.168.0.127:51022
[6] 10:33:34 [SUCCESS] root@192.168.0.125:51022
[7] 10:33:34 [SUCCESS] root@192.168.0.122:51022
[root@control work]# pssh -h ip_list.txt -P "ls /home/zhangly/"
192.168.0.121: test.txt
[1] 10:35:15 [SUCCESS] root@192.168.0.121:51022
192.168.0.125: test.txt
[2] 10:35:15 [SUCCESS] root@192.168.0.125:51022
192.168.0.120: test.txt
[3] 10:35:15 [SUCCESS] root@192.168.0.120:51022
192.168.0.126: test.txt
[4] 10:35:15 [SUCCESS] root@192.168.0.126:51022
192.168.0.122: test.txt
[5] 10:35:15 [SUCCESS] root@192.168.0.122:51022
192.168.0.124: test.txt
[6] 10:35:15 [SUCCESS] root@192.168.0.124:51022
192.168.0.127: test.txt
[7] 10:35:15 [SUCCESS] root@192.168.0.127:51022
如果是传输目录,命令为:
[root@control work]# pscp -h ip_list.txt -r /home/work/ /tmp/
[1] 10:41:56 [SUCCESS] root@192.168.0.120:51022
[2] 10:41:56 [SUCCESS] root@192.168.0.121:51022
[3] 10:41:56 [SUCCESS] root@192.168.0.125:51022
[4] 10:41:56 [SUCCESS] root@192.168.0.127:51022
[5] 10:41:56 [SUCCESS] root@192.168.0.126:51022
[6] 10:41:56 [SUCCESS] root@192.168.0.124:51022
[7] 10:41:56 [SUCCESS] root@192.168.0.122:51022
[root@control work]# pssh -h ip_list.txt -P "ls /tmp|grep work"
192.168.0.120: work
[1] 10:42:18 [SUCCESS] root@192.168.0.120:51022
192.168.0.121: work
[2] 10:42:18 [SUCCESS] root@192.168.0.121:51022
192.168.0.124: work
192.168.0.125: work
[3] 10:42:18 [SUCCESS] root@192.168.0.125:51022
[4] 10:42:18 [SUCCESS] root@192.168.0.124:51022
192.168.0.126: work
[5] 10:42:18 [SUCCESS] root@192.168.0.126:51022
192.168.0.127: work
[6] 10:42:18 [SUCCESS] root@192.168.0.127:51022
192.168.0.122: work
5:批量将多个文件或者目录从远程传输到中心主机:
[root@control work]# pslurp -r -h ip_list.txt /home/zhangly/ .
[1] 11:22:57 [SUCCESS] root@192.168.0.120:51022
[2] 11:22:57 [SUCCESS] root@192.168.0.125:51022
[3] 11:22:57 [SUCCESS] root@192.168.0.126:51022
[4] 11:22:57 [SUCCESS] root@192.168.0.127:51022
[5] 11:22:57 [SUCCESS] root@192.168.0.124:51022
[6] 11:22:57 [SUCCESS] root@192.168.0.122:51022
[7] 11:22:57 [SUCCESS] root@192.168.0.121:51022
[root@control work]# cd ..
[root@control home]# tree work/
work/
|-- 192.168.0.120
| `-- zhangly
| `-- test.txt
|-- 192.168.0.121
| `-- zhangly
| `-- test.txt
|-- 192.168.0.122
| `-- zhangly
| `-- test.txt
|-- 192.168.0.124
| `-- zhangly
| `-- test.txt
|-- 192.168.0.125
| `-- zhangly
| `-- test.txt
|-- 192.168.0.126
| `-- zhangly
| `-- test.txt
|-- 192.168.0.127
| `-- zhangly
| `-- test.txt
|-- aa
|-- ip_list.txt
`-- test.txt
15 directories, 9 files