首页 > 其他 > 详细

PSSH工具

时间:2019-10-07 23:55:14      阅读:154      评论:0      收藏:0      [点我收藏+]

PSSH工具

?? Written by Zak Zhu

参考

  • Dicky_Zhang/运维自动化轻量级工具pssh(https://www.cnblogs.com/Dicky-Zhang/p/5988415.html)

PSSH工具的介绍

pssh是python写的可以并发在多台机器上批量执行命令的工具, 它的用法可以媲美ansible的一些简单用法, 执行起来速度比ansible快. 它支持文件并行复制, 远程命令执行, 杀掉远程主机上的进程等

PSSH工具的使用

在使用pssh之前, 建议跳板机和远程主机做好ssh公钥认证

安装

wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/parallel-ssh/pssh-2.3.1.tar.gz
tar -zxvf pssh-2.3.1.tar.gz
cd pssh-2.3.1
python setup.py install 

pssh命令

在远程多台主机上并行执行命令

pssh [OPTIONS] command
Options:
    --help  # show this help message and exit
    -h HOST_FILE    # host file (each line "user@host[:port]")
    -i  # inline aggregate output and error for each server
    -o OUTDIR   # output dir for stdout files, OUTDIR is on the local host
    -e ERRDIR   # output dir for stderr files , ERRDIR is on the local host

简单用法示例:

vi /tmp/host_file   # host file (each line "user@root[:port]")
pssh -h /tmp/host_file -i ls -l /root

技术分享图片

技术分享图片

pscp命令

把文件并行复制到多台远程主机上

pscp [OPTIONS] local remote
Options:
    --help  # show this help message and exit
    -h HOST_FILE    # host file (each line "user@host[:port]")
    -r  # recursively copy dir
    -o OUTDIR   # output dir for stdout files, OUTDIR is in the local host
    -e ERRDIR   # output dir for stderr files , ERRDIR is on the local host

简单用法示例:

pscp -h /tmp/host_file /tmp/test /tmp/

技术分享图片

pslurp命令

把文件从远程多台主机上复制到本地主机上

pslurp [OPTIONS] remote local
Options:
    --help  # show this help message and exit
    -h HOST_FILE    # host file (each line "user@host[:port]")
    -r  # recursively copy dir
    -L LOCALDIR # output dir for remote file copies
    -o OUTDIR   # output dir for stdout files, OUTDIR is in the local host
    -e ERRDIR   # output dir for stderr files , ERRDIR is on the local host

简单用法示例:

pslurp -h /tmp/host_file -L /tmp/ /tmp/test test
# 上边是, 将/tmp/host_file写的远程主机上的/tmp/test文件复制到本地主机/tmp/目录下, 并且重新命名为test文件

技术分享图片

技术分享图片

pnuke命令

在远程多台主机上并行killall某一进程

pnuke [OPTIONS] pattern
Options:
    --help  # show this help message and exit
    -h HOST_FILE    # host file (each line "user@host[:port]")
    -o OUTDIR   # output dir for stdout files, OUTDIR is in the local host
    -e ERRDIR   # output dir for stderr files , ERRDIR is on the local host

简单用法示例:

pnuke -h /tmp/host_file java

PSSH工具

原文:https://www.cnblogs.com/zakzhu/p/11633004.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!