[root@localhost ~]# pssh -i -O "StrictHostKeyChecking=no" -h /etc/pssh_hosts 'date'
[1] 09:56:38 [SUCCESS] web1.jiajie.com 22
2017年 10月 17日 星期二 09:56:38 CST
[2] 09:56:38 [SUCCESS] web2.jiajie.com 22
2017年 10月 17日 星期二 09:56:38 CST
[3] 09:56:38 [SUCCESS] web3.jiajie.com 22
2017年 10月 17日 星期二 09:56:37 CST
[root@localhost ~]# pssh -i -h /etc/pssh_hosts 'uptime'
[1] 09:59:50 [SUCCESS] web1.jiajie.com 22
09:59:50 up 1:20,1 user,load average: 0.06,0.01,0.00
[2] 09:59:50 [SUCCESS] web3.jiajie.com 22
09:59:49 up 1:20,2 users,load average: 0.00,0.05
[3] 09:59:50 [SUCCESS] web2.jiajie.com 22
09:59:50 up 1:20,0.02,0.00
[root@localhost ~]# pssh -i -h /etc/pssh_hosts "tar -zxvf pssh-1.4.3.tar.gz"
[root@localhost ~]# pssh -i -h /etc/pssh_hosts "rpm -qa httpd|wc -l"
[1] 10:20:18 [SUCCESS] web2.jiajie.com 22
0
[2] 10:20:19 [SUCCESS] web1.jiajie.com 22
0
[3] 10:20:19 [SUCCESS] web3.jiajie.com 22
0
</code></pre>
<h3 id="pscp-命令">pscp 命令
pscp: 把文件或者目录并行的复制到多个主机上面
Usage: pscp [OPTIONS] -h hosts.txt local remote
-r 递归复制目录
-h 主机文件列表,格式"host[:port] [user]"
-l 用户名
-p --par 并发线程数
-o --outdir 输出的文件目录
-e --errdir 错误输出的文件目录
-t --timeout 设置命令执行超时时间 -1表示无限制
-O --options 设置ssh的一些选项
-v --verbose 详细模式
Example: pscp -h hosts.txt -l irb2 foo.txt /home/irb2/foo.txt
[root@localhost ~]# pscp -h /etc/pssh_hosts /etc/hosts /tmp/
[1] 10:29:11 [SUCCESS] web2.jiajie.com 22
[2] 10:29:11 [SUCCESS] web1.jiajie.com 22
[3] 10:29:11 [SUCCESS] web3.jiajie.com 22
[root@localhost ~]# pssh -i -h /etc/pssh_hosts "ls -l /tmp/hosts"
[1] 10:29:57 [SUCCESS] web1.jiajie.com 22
-rw-r--r-- 1 root root 202 10月 17 10:29 /tmp/hosts
[2] 10:29:57 [SUCCESS] web2.jiajie.com 22
-rw-r--r-- 1 root root 202 10月 17 10:29 /tmp/hosts
[3] 10:29:57 [SUCCESS] web3.jiajie.com 22
-rw-r--r-- 1 root root 202 10月 17 10:29 /tmp/hosts
[root@localhost ~]# pscp -r -h /etc/pssh_hosts /root/shell.sh/ /tmp/
[1] 10:33:18 [SUCCESS] web1.jiajie.com 22
[2] 10:33:18 [SUCCESS] web2.jiajie.com 22
[3] 10:33:18 [SUCCESS] web3.jiajie.com 22
<h3 id="pslurp-命令从远程主机复制到本地">pslurp 命令(从远程主机复制到本地。)
Usage: pslurp [OPTIONS] -h hosts.txt -o outdir remote local
-r --recursive recusively copy directories (OPTIONAL)
-L --localdir output directory for remote file copies
-h --hosts hosts file (each line "host[:port] [login]")
-l --user username (OPTIONAL)
-p --par max number of parallel threads (OPTIONAL)
-o --outdir output directory for stdout files (OPTIONAL)
-e --errdir output directory for stderr files (OPTIONAL)
-t --timeout timeout (secs) (-1 = no timeout) per host (OPTIONAL)
-v --verbose turn on warning and diagnostic messages (OPTIONAL)
-O --options SSH options (OPTIONAL)
Example: pslurp -h hosts.txt -L /tmp/outdir -l irb2
/home/irb2/foo.txt foo.txt
(编辑:开发网_开封站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!