pdsh配置及应用

1、下载和安装

可以在官网http://sourceforge.net/projects/pdsh/下载。

wget http://nchc.dl.sourceforge.net/project/pdsh/pdsh/pdsh-2.26/pdsh-2.26.tar.bz2
tar jxvf pdsh-2.26.tar.bz2
cd pdsh-2.26
./configure
make
make install

2、安装好以后,可以先看下pdsh的参数

hadoop@master:~/pdsh-2.26$ pdsh --help
pdsh: invalid option -- '-'
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
available rcmd modules: rsh,exec (default: rsh)

3、远程执行命令

hadoop@master:~/pdsh-2.26$ pdsh -d -R exec -w hadoop@slave[1-4] ssh -x %h "hostname"
slave3: slave3
slave2: slave2
slave1: slave1
slave4: slave4
Connect time:  Avg: 0 sec, Min: 0 sec,  Max: 0 sec
Command time:  Avg: 1 sec, Min: 1 sec,  Max: 1 sec
Failures:      0

需要执行其他命令的时候,只需要把引号里面的换成其他命令就行了。

原文地址:https://www.cnblogs.com/dgy5554/p/3973412.html