zoukankan      html  css  js  c++  java
  • 批量执行工具之pssh

    pssh是一个python编写的工具,它比ansible更轻量级。支持命令的批量执行、文件批量拷贝。

    • pssh 在多个主机上并行运行命令
    • pscp 把文件并行复制到多个主机上
    • prsync 通过rsync协议把文件高效并行复制到多个主机上
    • pslurp 把文件并行地从多个远程主机复制到中心主机上
    • pnuke 并行地在多个远程主机上杀死进程

    1、pssh安装

    # 安装setuptools包,如果安装了跳过
    wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz --no-check-certificate
    tar -xf setuptools-0.6c11.tar.gz
    cd setuptools-0.6c11
    python setup.py build
    python setup.py install
    # 安装pssh
    cd -
    wget  http://www.theether.org/pssh/pssh-1.4.3.tar.gz
    cd pssh-1.4.3/
    python setup.py install
    

      

    2、pssh

    [root@node1]# pssh
    Usage: pssh [OPTIONS] -h hosts.txt prog [arg0] ..
    
      -h --hosts   hosts file (each line "host[:port] [user]")
      -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)
      -O --options SSH options (OPTIONAL)
      -v --verbose turn on warning and diagnostic messages (OPTIONAL)
      -P --print   print output as we get it (OPTIONAL)
      -i --inline  inline aggregated output for each server (OPTIONAL)
    
    Example: pssh -h nodes.txt -l irb2 -o /tmp/foo uptime
    

      

    3、pscp

    [root@node1 ~]# pscp
    Usage: pscp [OPTIONS] -h hosts.txt local remote
    
      -r --recursive recusively copy directories (OPTIONAL)
      -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: pscp -h hosts.txt -l irb2 foo.txt /home/irb2/foo.txt
    

      

    4、prsync

    要使用此命令,主机上必须要有rsync命令,否则执行不成功。

    [root@node1 ~]# prsync
    Usage: prsync [OPTIONS] -h hosts.txt local remote
    
      -r --recursive recusively copy directories (OPTIONAL)
      -a --archive   use rsync -a (archive mode) (OPTIONAL)
      -z --compress  use rsync compression (OPTIONAL)
      -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: prsync -r -h hosts.txt -l irb2 foo /home/irb2/foo
    

      

    5、pslurp

    [root@node1 ~]# 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
    

      

    6、pnuke

    [root@node1 ~]# pnuke
    Usage: pnuke [OPTIONS] -h hosts.txt pattern
    
      -h --hosts   hosts file (each line "host[:port] [user]")
      -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: pnuke -h hosts.txt -l irb2 java
    

      

    参考博客:

    1、批量执行工具PSSH详解

    2、pssh系列命令详解

  • 相关阅读:
    服务器运行jupyter,本地浏览器打开
    转载--对batch normalization的理解
    Deep Neural Networks for YouTube Recommendations YouTube的经典推荐框架
    IFrame与window对象(contentWindow)
    vue之watch的理解
    关于npm
    简单的输入法效果(类似百度输入时候的智能检索)
    Js屏蔽网页复制,不能使用右键菜单,禁止复制网页内容,不能选中内容,右键不让用,无法拖拽选择,这么多功能,用JS一句代码就搞定了
    移动端关于计算rem的flexible.js
    解决安卓手机在input获取焦点时候固定定位元素被输入键盘给顶到顶部
  • 原文地址:https://www.cnblogs.com/wufj/p/14873453.html
Copyright © 2011-2022 走看看