并行管理工具pssh


并行管理工具pssh
 
pssh是一个简单的字符界面并发向多个服务器发送指令进行执行的工具。适合一次性向集群大量服务器发送相同指令(并观察输出)
 
1. 安装
a. 到google code找到最新的安装包
http://code.google.com/p/parallel-ssh/downloads/list
Bash代码  
$ wget http://code.google.com/p/parallel-ssh/downloads/detail?name=pssh-2.3.1.tar.gz&can=2&q=  
pssh是python写的,因此下载之后解压,安装python安装模块的方式安装
Bash代码  
$ tar -xf pssh-2.3.1.tar.gz  
  
$ cd pssh-2.3.1  
  
# python setup.py install  
 
2. 准备
为了方便使用,免去pssh时输入密码,需要生成rsa的key,然后拷贝到需要远程管理的机器上。
Bash代码  
# key-gen  
 
一直回车,会生成/root/.ssh/id_rsa.pub
拷贝并添加到授权的文件
Bash代码  
# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.16.X  
3. 使用
创建一个hosts.txt文件,将要远程管理的机器加入
Bash代码  
[root@localhost script]# cat hosts.txt   
127.0.0.1  
192.168.0.8  
192.168.0.51  
192.168.1.114  
192.168.1.115  
 运行管理命令:
Java代码  
[root@localhost script]# pssh -i -h hosts.txt "uptime"  
  
[1] 10:49:19 [FAILURE] 127.0.0.1 22 Received error code of 255  
[2] 10:49:19 [SUCCESS] 192.168.1.115 22  
 10:49:40 up 14 days, 17:50,  8 users,  load average: 0.00, 0.00, 0.00  
[3] 10:49:19 [SUCCESS] 192.168.1.114 22  
 02:49:35 up 14 days, 17:52,  9 users,  load average: 0.11, 0.04, 0.01  
[4] 10:49:19 [SUCCESS] 192.168.0.8 22  
 02:39:21 up 4 days, 29 min,  6 users,  load average: 0.00, 0.02, 0.03  
[5] 10:49:19 [SUCCESS] 192.168.0.51 22  
 10:50:14 up 8 days, 38 min, 20 users,  load average: 0.03, 0.06, 0.06
 

相关内容

    暂无相关文章