比较
语言 | 版本 | 日期 | 许可 | 网站 | |
---|---|---|---|---|---|
#pdsh | C | 2.28 | 2012-02-11 | GNU GPL v2 | pdsh |
#clusterssh | Perl | 4.01_01 | 2011-12-09 | GNU GPL | ClusterSSH |
#mussh | Bourne-Again Shell | 1.0 | 2011-11-03 | GNU GPL | MUltihost SSH Wrapper |
#pssh | Python | 2.3.1 | 2012-02-02 | New BSD License | PSSH |
#sshpt | Python 2.5+ | 1.2.0 | 2011-08-14 | GNU GPL v3 | SSH Power Tool |
#tentakel | Python | 2.2 | 2005-03-20 | unknown | tentakel |
#massh | Bourne-Again Shell | 2.0-58 | 2011-07-29 | GNU GPL | Massh |
#PyDSH | Python 2.7 | 0.6 | 2011-09-20 | GNU GPL | The Python Distributed Shell |
#ClusterShell | Python 2.4+ | 1.6 | 2012-04-08 | CeCILL-C | ClusterShell |
#xargs | C | n/a | n/a | GNU GPL | n/a |
#GNU Parallel | Perl | 20120422 | 2012-04-22 | GNU GPL | GNU Parallel |
#PPSS | Bourne-Again Shell | 2.97 | 2011-12-30 | GNU GPL v3 | Parallel Processing Shell Script |
分布命令执行 | 分布文件复制 | 主机范围声明 | 主机分组 | 支持其它连接协议 | 远程执行本地脚本 | SSH Key管理 | 输出格式化 | 支持密码登录 | |
---|---|---|---|---|---|---|---|---|---|
#pdsh | Yes | Yes(1)(2) | Yes(3) | Yes(3) | Yes(4) | No | No | Yes(5) | No |
#clusterssh | - | - | - | - | - | - | - | - | - |
#mussh | Yes | No | No | Yes(6) | No | Yes | Yes(7) | Yes | No |
#pssh | Yes | Yes(8) | No | Yes(6) | No | No | No | Yes(9) | No |
#sshpt | Yes | Yes(12) | No | Yes(6) | No | Yes(11) | No | Yes(10) | Yes |
#tentakel | - | - | - | - | - | - | - | - | - |
#massh | Yes | Yes(15) | Yes(13) | Yes(13)(6) | No | Yes | No | Yes(14) | No |
#PyDSH | Yes | Yes | Yes | Yes(6) | Yes(16) | No | Yes(17) | No | No |
#ClusterShell(18) | Yes | Yes | Yes(20) | Yes(20) | No | No | No | Yes(19) | No |
#xargs | Yes | ||||||||
#GNU Parallel | Yes | ||||||||
#PPSS | Yes |
1. 用pdcp复制文件要求两端服务器都要安装pdcp
2. rpdcp用于反向复制文件
3. 加载misc类型的模块,生成主机列表和过滤
4. 加载rcmd类型的模块,实现不同方式的远程连接
5. 用dshbak命令将输出内容按主机分组
6. 加载主机列表文件
7. 使用ssh-agent
8. prsync 同步文件, pscp 复制文件, pslurp 下载文件
9. 默认只显示一个最终的执行结果,没有屏幕输出
10. 生成cvs报告
11. 远程执行本地脚本其实是通过sftp复制过去然后执行
12. 只能复制到目标服务器,不能下载文件
13. 依赖该作者自己开发的ambit脚本,生成主机名列表和分组。也可加载主机列表文件
14. terse 只显示执行结果,worked 只显示成功的主机名,bombed 只显示失败的主机名
15. 能上传、下载一个文件
16. 支持RSH, Telnet
17. 可以生成、安装、卸载SSH key
18. 指clush,clubak等命令
19. 用clubak命令将输出内容按主机分组
20. 用nodeset工具
pdsh
介绍:
Pdsh is a high-performance, parallel remote shell utility. It uses a sliding window of threads to execute remote commands, conserving socket resources while allowing some connections to timeout if needed. It was originally written as a replacement for IBM's DSH on clusters at LLNL.
The core functionality of pdsh is supplemented by many available dynamically loadable modules. The modules may implement a new connection protocol, target host filtering (e.g. removing hosts that are "down" from the target host list) and/or other host selection options (e.g. -a selects all hosts from a config file).
The pdsh distribution also contains a parallel remote copy utility (pdcp - copy from local host to a group of remote hosts in parallel), reverse parallel remote copy (rpdcp, copy from a group of hosts to localhost in parallel), and a script dshbak for formatting and demultiplexing pdsh output.
文档:
程序:
- pdsh 并行执行
- pdcp 复制文件
- rpdcp 反向复制文件
- dshbak Perl脚本
安装:
make clean ./configure --with-ssh --with-netgroup --with-readline make make check make install
举例:
并行执行命令:
# pdsh -f 2 -R exec -w 10.10.100.193,10.10.100.194,10.10.100.195 ssh -x -l %u %h "date;hostname;sleep 3;date" 10.10.100.193: Tue May 1 15:22:44 CST 2012 10.10.100.193: vm-10-10-100-193.company.com 10.10.100.194: Tue May 1 15:22:44 CST 2012 10.10.100.194: vm-10-10-100-194.company.com 10.10.100.193: Tue May 1 15:22:47 CST 2012 10.10.100.194: Tue May 1 15:22:47 CST 2012 10.10.100.195: Tue May 1 15:22:47 CST 2012 10.10.100.195: vm-10-10-100-195.company.com 10.10.100.195: Tue May 1 15:22:50 CST 2012
用dshbak格式化屏幕输出:
# pdsh -f 2 -R exec -w 10.10.100.193,10.10.100.194,10.10.100.195 ssh -x -l %u %h "date;hostname;sleep 3;date" | dshbak ---------------- 10.10.100.193 ---------------- Tue May 1 15:23:34 CST 2012 vm-10-10-100-193.company.com Tue May 1 15:23:37 CST 2012 ---------------- 10.10.100.194 ---------------- Tue May 1 15:23:34 CST 2012 vm-10-10-100-194.company.com Tue May 1 15:23:37 CST 2012 ---------------- 10.10.100.195 ---------------- Tue May 1 15:23:37 CST 2012 vm-10-10-100-195.company.com Tue May 1 15:23:40 CST 2012
并行复制文件:
# pdcp -R ssh -w 10.10.100.193 -p /u01/oracle/deploy/bin/halvs-upgrade.sh /tmp/halvs-upgrade.sh 10.10.100.193: bash: /usr/local/bin/pdcp: No such file or directory pdcp@xpt01: 10.10.100.193: ssh exited with exit code 127
目标服务器需要pdcp可执行命令
用netgroup给主机分组:
cat >/etc/netgroup <<'EOF' cp-test (10.10.100.193,,) (10.10.100.194,,) cp-all @cp-test EOF vi /etc/nsswitch.conf netgroup: files nisplus getent netgroup cp-test pdsh -g cp-test -q pdsh -R ssh -g cp-test hostname
clusterssh
介绍:
ClusterSSH controls a number of xterm windows via a single graphical console window to allow commands to be interactively run on multiple servers over an ssh connection.
功能:
- 图形界面的
- 依赖一堆Perl模块
安装:
perl Build.PL ./Build ./Build test ./Build install
依赖的Perl模块
# perl Build.PL Checking prerequisites... requires: ! Exception::Class is not installed ! Tk is not installed ! X11::Protocol is not installed build_requires: ! File::Which is not installed ! Readonly is not installed ! Test::DistManifest is not installed ! Test::Pod is not installed ! Test::Pod::Coverage is not installed ! Test::Trap is not installed
因cpan install Tk执行失败,就没再试
mussh
介绍:
Mussh is a shell script that allows you to execute a command or script over ssh on multiple hosts with one command. When possible mussh will use ssh-agent and RSA/DSA keys to minimize the need to enter your password more than once.
程序
- mussh 并行执行
功能:
- 设置并行度(-m)
安装:
cp -p mussh /usr/local/bin/ cp -p mussh.1 /usr/local/man/man1/
举例:
并行执行命令:
# mussh -A -m 2 -h 10.10.100.193 10.10.100.194 10.10.100.195 -c "date;hostname;sleep 3;date" 10.10.100.193: Tue May 1 15:21:33 CST 2012 10.10.100.193: vm-10-10-100-193.company.com 10.10.100.194: Tue May 1 15:21:34 CST 2012 10.10.100.194: vm-10-10-100-194.company.com 10.10.100.193: Tue May 1 15:21:36 CST 2012 10.10.100.195: Tue May 1 15:21:36 CST 2012 10.10.100.195: vm-10-10-100-195.company.com 10.10.100.194: Tue May 1 15:21:37 CST 2012 10.10.100.195: Tue May 1 15:21:39 CST 2012
格式化输出:
# mussh -b -A -m 2 -h 10.10.100.193 10.10.100.194 10.10.100.195 -c "date;hostname;sleep 3;date" 10.10.100.193: Tue May 1 15:25:04 CST 2012 10.10.100.193: vm-10-10-100-193.company.com 10.10.100.193: Tue May 1 15:25:07 CST 2012 10.10.100.194: Tue May 1 15:25:05 CST 2012 10.10.100.194: vm-10-10-100-194.company.com 10.10.100.194: Tue May 1 15:25:08 CST 2012 10.10.100.195: Tue May 1 15:25:07 CST 2012 10.10.100.195: vm-10-10-100-195.company.com 10.10.100.195: Tue May 1 15:25:10 CST 2012
远程执行本地脚本:
# cat >/tmp/hello.sh <<EOF > echo 'hello world!' > EOF # mussh -A -m 2 -h 10.10.100.193 10.10.100.194 10.10.100.195 -C /tmp/hello.sh 10.10.100.193: hello world! 10.10.100.194: hello world! 10.10.100.195: hello world!
pssh
介绍:
PSSH provides parallel versions of OpenSSH and related tools. Included are pssh, pscp, prsync, pnuke, and pslurp. The project includes psshlib which can be used within custom applications.
程序:
- pnuke 杀进程
- prsync 同步文件
- pscp 复制文件
- pslurp 下载文件
- pssh 并行执行
- pssh-askpass
安装:
python setup.py install
举例:
执行命令:
# pssh -P -p 2 -H 10.10.100.193 -H 10.10.100.194 -H 10.10.100.195 "date;hostname;sleep 3;date" 10.10.100.193: Tue May 1 15:48:42 CST 2012 10.10.100.194: Tue May 1 15:48:42 CST 2012 10.10.100.193: vm-10-10-100-193.company.com 10.10.100.194: vm-10-10-100-194.company.com 10.10.100.193: Tue May 1 15:48:45 CST 2012 [1] 15:48:45 [SUCCESS] 10.10.100.193 10.10.100.194: Tue May 1 15:48:45 CST 2012 [2] 15:48:45 [SUCCESS] 10.10.100.194 10.10.100.195: Tue May 1 15:48:46 CST 2012 10.10.100.195: vm-10-10-100-195.company.com 10.10.100.195: Tue May 1 15:48:49 CST 2012 [3] 15:48:49 [SUCCESS] 10.10.100.195
格式化输出:
# pssh -i -p 2 -H 10.10.100.193 -H 10.10.100.194 -H 10.10.100.195 "date;hostname;sleep 3;date" [1] 15:51:14 [SUCCESS] 10.10.100.193 Tue May 1 15:51:11 CST 2012 vm-10-10-100-193.company.com Tue May 1 15:51:14 CST 2012 [2] 15:51:14 [SUCCESS] 10.10.100.194 Tue May 1 15:51:11 CST 2012 vm-10-10-100-194.company.com Tue May 1 15:51:14 CST 2012 [3] 15:51:17 [SUCCESS] 10.10.100.195 Tue May 1 15:51:14 CST 2012 vm-10-10-100-195.company.com Tue May 1 15:51:17 CST 2012
sshpt
介绍:
The SSH Power Tool (sshpt) enables you to execute commands and upload files to many servers simultaneously via SSH without using pre-shared keys. Uploaded files and commands can be executed directly or via sudo. Connection and command execution results are output in standard CSV format for easy importing into spreadsheets, databases, or data mining applications.
程序:
- sshpt.py 并行执行
功能:
- 无需ssh key
- 依赖Paramiko和pycrypto这两个Python模块
- Python 2.5+ (not 3.0+ yet)
安装:
rpm -Uvh python-crypto-2.0.1-1.el5.rf.x86_64.rpm rpm -Uvh python-paramiko-1.7.6-1.el5.rf.noarch.rpm cp -p sshpt.py /usr/local/bin/
举例:
并行执行命令:
echo "10.10.100.193 10.10.100.194 10.10.100.195" | sshpt.py -S -t 2 -u someone -P "secret" "date;hostname;sleep 3;date"
RHEL5系统自带Python版本较低,是2.4版本,因此没有继续再试
tentakel
As of 2011-04-07, this project is no longer under active development.
版本太老了,就不试了
massh
介绍:
Massh makes it possible to perform the following on hundreds, or even thousands of hosts in a parallelized fashion:
- Run Remote Commands
- Push and Execute Pre-Written Scripts
- Push Files
- Pull Files
Massh uses Ambit to enumerate a list of targets for which it will execute one of the aforementioned operations. Hosts can be logically grouped and dynamically managed allowing for consistent operational changes and overall management of identically purposed hosts.
Massh can display the full output resulting from its various operations or it can be set to display an operation's success or failure for individual target hosts. The full ouput produced by Massh is completely organized and labeled by host, regardless of what order output is returned from target hosts.
Starting with version 2.x Massh combines flexible option control management and a simplified command + subcommand sytax. This reduces the complexity of typical Massh commands and makes it much easier to learn how to perform specific operations with specific options with Massh.
程序:
- /etc/massh/massh.conf
- /usr/bin/massh
- /usr/bin/masshfilesupdate
- /usr/lib/massh/libmassh.sh
- /usr/share/man/man1/massh.1.gz
- --以下是ambit的程序--
- /etc/ambit/ambit.conf
- /usr/bin/ambit
- /usr/lib/ambit/libambit.sh
- /usr/share/man/man1/ambit.1.gz
- /var/ambit/hosts/down
功能:
- 设置连接超时
- 设置并行度。脚本有问题,${wc}应该是wc,还有${dirname}
安装:
rpm -Uvh ambit-2.0-40.noarch.rpm rpm -Uvh massh-2.0-58.noarch.rpm
举例:
修改massh配置:
# massh list options System Default Options ---------------------- Debug="no" ForcePseudoTTY="no" SyslogMassh="yes" SSHLogLevel="quiet" TimeOut="30" Parallel="30" Random="$RANDOM" ControlPath="$HOME/.ssh/masshter-%r@%h:%p" ControlMaster="no" ControlPersist="300" HostsFrom="ambit" Separator="no" SubCommand="" User Specified Options ---------------------- NONE # echo 2 | massh ed opt Parallel Updating Option : Parallel Current Value : 30 Parallel="2"
并行执行命令:
# massh 10.10.100.19[3..5] verbose "date;hostname;sleep 3;date" 10.10.100.193 : Tue May 1 19:16:58 CST 2012 10.10.100.193 : vm-10-10-100-193.company.com 10.10.100.193 : Tue May 1 19:17:01 CST 2012 10.10.100.194 : Tue May 1 19:16:58 CST 2012 10.10.100.194 : vm-10-10-100-194.company.com 10.10.100.194 : Tue May 1 19:17:01 CST 2012 10.10.100.195 : Tue May 1 19:17:01 CST 2012 10.10.100.195 : vm-10-10-100-195.company.com 10.10.100.195 : Tue May 1 19:17:04 CST 2012
执行脚本:
# cat >/tmp/hello.sh <<EOF > echo 'hello world!' > EOF # massh 10.10.100.19[3..5] execute /tmp/hello.sh 10.10.100.193 : hello world! 10.10.100.194 : hello world! 10.10.100.195 : hello world!
PyDSH
介绍:
PyDSH is a remote administration tool, consisting of pydsh and pydcp. Pydsh allows you to run a command on multiple hosts in parallel over RSH, SSH or Telnet, OR manage your SSH public keys. The pydcp command allows copying files to/from multiple hosts.
文档:
功能:
- 设置连接超时
- 设置并行度
- 加载主机列表文件
- 依赖Pexpect 0.999
- 远程执行本地脚本
- 能上传、下载一个文件
安装:
cd pexpect-2.3 python ./setup.py install cd .. cd pydsh-0.6 ./install.sh --install
需要Python 2.7,系统自带版本是2.4的,就没再试
ClusterShell
介绍:
ClusterShell is an event-driven open source Python library, designed to run local or distant commands in parallel on server farms or on large Linux clusters. It will take care of common issues encountered on HPC clusters, such as operating on groups of nodes, running distributed commands using optimized execution algorithms, as well as gathering results and merging identical outputs, or retrieving return codes. ClusterShell takes advantage of existing remote shell facilities already installed on your systems, like SSH.
ClusterShell's primary goal is to improve the administration of high-performance clusters by providing a lightweight but scalable Python API for developers. It also provides clush, clubak and nodeset, three convenient command-line tools that allow traditional shell scripts to benefit from some of the library features.
文档:
- https://github.com/cea-hpc/clustershell/wiki
- https://github.com/cea-hpc/clustershell/wiki/UserAndProgrammingGuide
程序:
- /etc/clustershell/clush.conf
- /etc/clustershell/groups
- /etc/clustershell/groups.conf
- /etc/clustershell/groups.conf.d/
- /usr/bin/clubak
- /usr/bin/clush
- /usr/bin/nodeset
安装:
rpm -Uvh clustershell-1.6-1.el5.noarch.rpm rpm -Uvh vim-clustershell-1.6-1.el5.noarch.rpm
举例:
xargs
系统自带
-P参数表示并行度
举例:
# echo 10.10.100.19{3..5}|tr ' ' '\n'|xargs -n1 -P2 -I{} ssh root@{} "sh -c 'date;hostname;sleep 3;date'|sed 's/^/{}: /'" 10.10.100.194: Tue May 1 23:05:59 CST 2012 10.10.100.194: vm-10-10-100-194.company.com 10.10.100.194: Tue May 1 23:06:02 CST 2012 10.10.100.193: Tue May 1 23:05:59 CST 2012 10.10.100.193: vm-10-10-100-193.company.com 10.10.100.193: Tue May 1 23:06:02 CST 2012 10.10.100.195: Tue May 1 23:06:03 CST 2012 10.10.100.195: vm-10-10-100-195.company.com 10.10.100.195: Tue May 1 23:06:06 CST 2012
GNU Parallel
介绍:
GNU parallel is a shell tool for executing jobs in parallel using one or more computers. A job is can be a single command or a small script that has to be run for each of the lines in the input. The typical input is a list of files, a list of hosts, a list of users, a list of URLs, or a list of tables. A job can also be a command that reads from a pipe. GNU parallel can then split the input and pipe it into commands in parallel.
If you use xargs and tee today you will find GNU parallel very easy to use as GNU parallel is written to have the same options as xargs. If you write loops in shell, you will find GNU parallel may be able to replace most of the loops and make them run faster by running several jobs in parallel.
GNU parallel makes sure output from the commands is the same output as you would get had you run the commands sequentially. This makes it possible to use output from GNU parallel as input for other programs.
For each line of input GNU parallel will execute command with the line as arguments. If no command is given, the line of input is executed. Several lines will be run in parallel. GNU parallel can often be used as a substitute for xargs or cat | bash.
文档:
PPSS
介绍:
PPSS is a Bash shell script that executes commands, scripts or programs in parallel. It is designed to make full use of current multi-core CPUs. It will detect the number of available CPUs and start a separate job for each CPU core. It will also use hyper threading by default.
PPSS can be run on multiple hosts, processing a single group of items, like a cluster.
文档:
No comments:
Post a Comment