1.首先需要配置节点之间的SSH,然后在其中一个节点上安装
2.安装epel
yum -y install epel-release
3.安装pssh
[root@slave1 ~]# yum -y install pssh
二、PSSH的使用
1.常用参数
-h:主机文件列表,内容格式”[user@]host[:port]” -H:主机字符串,内容格式”[user@]host[:port]” -l:远程机器的用户名 -p:并发的线程数 -o:输出的文件目录 -t:超时时间设置,0无限制 -i:显示标准输出和标准错误
2.pssh
①查看各个节点的时间
[root@slave1 ~]# pssh -h hostlist -i 'date' [1] 04:00:33 [SUCCESS] 20.0.5.10 Tue Jan 9 04:00:33 EST 2018 [2] 04:00:33 [SUCCESS] 20.0.5.11 Tue Jan 9 04:00:33 EST 2018 [3] 04:00:33 [SUCCESS] 20.0.5.12 Tue Jan 9 04:00:33 EST 2018 [4] 04:00:33 [SUCCESS] 20.0.5.13 Tue Jan 9 04:00:33 EST 2018 [5] 04:00:33 [SUCCESS] 20.0.5.14 Tue Jan 9 04:00:33 EST 2018 [6] 04:00:33 [SUCCESS] 20.0.5.15 Tue Jan 9 04:00:33 EST 2018
②安装tree命令
[root@slave1 ~]# pssh -h hostlist 'yum -y install tree' [1] 03:20:12 [SUCCESS] 20.0.5.10 [2] 03:20:12 [SUCCESS] 20.0.5.13 [3] 03:20:12 [SUCCESS] 20.0.5.15 [4] 03:20:12 [SUCCESS] 20.0.5.14 [5] 03:20:14 [SUCCESS] 20.0.5.12 [6] 03:20:16 [SUCCESS] 20.0.5.11
[root@slave1 ~]# pssh -h hostlist -i 'rpm -qa tree' [1] 03:20:44 [SUCCESS] 20.0.5.10 tree-1.6.0-10.el7.x86_64 [2] 03:20:44 [SUCCESS] 20.0.5.12 tree-1.6.0-10.el7.x86_64 [3] 03:20:44 [SUCCESS] 20.0.5.14 tree-1.6.0-10.el7.x86_64 [4] 03:20:44 [SUCCESS] 20.0.5.13 tree-1.6.0-10.el7.x86_64 [5] 03:20:44 [SUCCESS] 20.0.5.11 tree-1.6.0-10.el7.x86_64 [6] 03:20:44 [SUCCESS] 20.0.5.15 tree-1.6.0-10.el7.x86_64
③显示主机名输出到指定目录
[root@slave1 ~]# pssh -h hostlist -o pssh.log 'hostname' [1] 04:15:19 [SUCCESS] 20.0.5.11 [2] 04:15:19 [SUCCESS] 20.0.5.10 [3] 04:15:19 [SUCCESS] 20.0.5.12 [4] 04:15:19 [SUCCESS] 20.0.5.14 [5] 04:15:19 [SUCCESS] 20.0.5.13 [6] 04:15:19 [SUCCESS] 20.0.5.15 [root@slave1 ~]# cat pssh.log pssh.log/ pssh.log1/ [root@slave1 ~]# cat pssh.log/20.0.5.10 amb1 [root@slave1 ~]# cat pssh.log/20.0.5.11 slave1
原文:http://blog.51cto.com/lullaby/2059123