psdh (Parallel Distributed Shell)是一个高性能、并行的远程shell实用程序
安装
pdsh 在 epel 源中
yum install -y pdsh
help
$ pdsh -h
Usage: pdsh [-options] command ...
-S return largest of remote command return values
-h output usage menu and quit
-V output version information and quit
-q list the option settings and quit
-b disable ^C status feature (batch mode)
-d enable extra debug information from ^C status
-l user execute remote commands as user
-t seconds set connect timeout (default is 10 sec)
-u seconds set command timeout (no default)
-f n use fanout of n nodes
-w host,host,... set target node list on command line
-x host,host,... set node exclusion list on command line
-R name set rcmd module to name
-M name,... select one or more misc modules to initialize first
-N disable hostname: labels on output lines
-L list info on all loaded modules and exit
-j jobid,... Run on nodes allocated to SLURM job(s) ("all" = all jobs)
-P partition,... Run on nodes contained in SLURM partition
available rcmd modules: ssh,exec (default: ssh)
demo
使用前提是配置无密码登录
pdsh -w 192.168.0.1 -w master date
pdsh -w 192.168.0.[1-5] -w master date
# 对 c01-c10 主机执行 date 命令
pdsh -w c[01-10] date
pdsh -w c[01-10] -x c02 date # 排除 c02
pdsh -w c[01-10] -l test date # 使用test用户执行
# 以下两条命令执行是相同的
pdsh -w c01,c10 date
pdsh -w c[01,10] date
类似的工具
- pssh/pscp : yum install -y pssh
- prsync
- dsh