关于sshbatch

sshbatch是用perl写了非常方便操作管理集群的一个工具,项目的源码在GitHub托管。

关于sshbatch以及其详细的使用方法,春哥在GitHub上介绍的非常详细了,详情可以前往sshbatch主页查询。

安装

源码安装

可以在从GitHub下载源码,并使用源码安装,安装步骤如下

perl Makefile.PL
make
make test
sudo make install

cpan安装

sshbatch是perl语言写,在Perl程序库CPAN里也存在,我们也可以使用cpan命令来快速安装

首先你要确定下你机器上是否有安装了cpan,可以在命令行中直接输入cpan来查看是安装

 $ cpan
-bash: cpan: command not found

若果出现上面提示,说明机器上还没有安装cpan命令

你可以使用  sudo yum install cpan 进行安装cpan(centos机器安装命令,其他机器使用相应命令下载)

 ➜  ~ cpan
Terminal does not support AddHistory. cpan shell -- CPAN exploration and modules installation (v2.)
Enter 'h' for help. cpan[]>

如果出现以上提示,证明机器上安装了cpan

这时我们就可以使用 sudo cpan SSH::Batch 进行安装sshbatch了

若果sshbatch所以来的包都存在,此时都会出现以下提示

 Running make install
Installing /usr/local/share/perl5/SSH/Batch.pm
Installing /usr/local/share/perl5/SSH/Batch/ForNodes.pm
Installing /usr/local/share/man/man1/fornodes.
Installing /usr/local/share/man/man1/key2nodes.
Installing /usr/local/share/man/man1/tonodes.
Installing /usr/local/share/man/man1/atnodes.
Installing /usr/local/share/man/man3/SSH::Batch::ForNodes.3pm
Installing /usr/local/share/man/man3/SSH::Batch.3pm
Installing /usr/local/bin/fornodes
Installing /usr/local/bin/key2nodes
Installing /usr/local/bin/tonodes
Installing /usr/local/bin/atnodes
Appending installation info to /usr/lib64/perl5/perllocal.pod
AGENT/SSH-Batch-0.030.tar.gz
/bin/make install -- OK

说明我们已经安装成功了,可以拿我们最常用的atnodes命令来测试下是否正确安装(可能由于某种原因你还需要使用绝对路径/usr/local/bin/atnodes来使用atnodes)

 atnodes -h
USAGE: atnodes [OPTIONS] COMMAND... -- HOST_PATTERN... [OPTIONS]
atnodes [OPTIONS] COMMAND HOST_PATTERN... [OPTIONS] OPTIONS:
-c <num> Set SSH concurrency limit. (default: ,
when -tty is on, this setting will no use)
-h Print this help.
-l List the hosts and do nothing else.
-L Use the line-mode output format, i.e., prefixing
every output line with the machine name.
(could be controlled by the env SSH_BATCH_LINE_MODE)
-p <port> Port for the remote SSH service.
-ssh <path> Specify an alternate ssh program.
(This overrides the SSH_BATCH_SSH_CMD environment.)
-t <timeout> Specify timeout for net traffic.
-u <user> User account for SSH login.
-v Be verbose.
-w Prompt for password (used for both login and sudo,
could be privided by SSH_BATCH_PASSWORD).
-W Prompt for password (just for sudo),
should not be used with -w.
-P Prompt for passphrase (used for login,
could be privided by SSH_BATCH_PASSPHRASE).
-tty Pseudo-tty.
-q Run SSH in quiet mode

可见现在我们已经可以正常使用atnodes了

问题列表

可是现实往往不是这样的,无论你是用源码安装还是用cpan安装,你都有可能遇到各种各样的问题,不然你也不会看到这篇文章,下面是我安装时遇到的一些问题,记录下来,方便自己以后安装此工具

问题1

命令

sudo cpan SSH::Batch

问题

 Test Summary Report
-------------------
t/atnodes.t (Wstat: Tests: Failed: )
Failed tests: , , , , -, , -,
Non-zero exit status:
t/fornodes.t (Wstat: Tests: Failed: )
Failed tests: , , -, -, , -, -, -
-, , , , -
Non-zero exit status:
t/tonodes.t (Wstat: Tests: Failed: )
Failed tests: , , , , , -, -, , -
, -, , -, -, -
Non-zero exit status:
Files=, Tests=, wallclock secs ( 0.06 usr 0.01 sys + 0.94 cusr 0.29 csys = 1.30 CPU)
Result: FAIL
Failed / test programs. / subtests failed.
make: *** [test_dynamic] Error
AGENT/SSH-Batch-0.030.tar.gz
dependencies missing (File::HomeDir,Net::OpenSSH); additionally test harness failed
/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports AGENT/SSH-Batch-0.030.tar.gz
Running make install
make test had returned bad status, won't install without force

从第19行可以看出,sshbatch依赖的两个包不存在,安装失败,那我们只能缺什么安装什么了,

解决方法

 sudo cpan File::HomeDir
sudo cpan Net::OpenSSH

问题2

安装File::HomeDir时,提示依赖包File::Which不存在,使用cpan安装File::Which

命令

sudo cpan File::Which

问题

 t/00_diag.t ..... ok
t/01_compile.t .. ok
t/02_all.t ...... Can't locate Env.pm in @INC (@INC contains: /root/.cpan/build/File-Which-1.22-7sw4CO/blib/lib /root/.cpan/build/File-Which-1.22-7sw4CO/blib/arch /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at t/02_all.t line 3.
BEGIN failed--compilation aborted at t/02_all.t line .
t/02_all.t ...... Dubious, test returned (wstat , 0x200)
No subtests run
t/03_simple.t ... Can't locate Env.pm in @INC (@INC contains: /root/.cpan/build/File-Which-1.22-7sw4CO/blib/lib /root/.cpan/build/File-Which-1.22-7sw4CO/blib/arch /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at t/03_simple.t line 6.
BEGIN failed--compilation aborted at t/03_simple.t line .
# Looks like your test exited with before it could output anything.
t/03_simple.t ... Dubious, test returned (wstat , 0x200)
Failed / subtests
t/04_pwhich.t ... ok Test Summary Report
-------------------
t/02_all.t (Wstat: Tests: Failed: )
Non-zero exit status:
Parse errors: No plan found in TAP output
t/03_simple.t (Wstat: Tests: Failed: )
Non-zero exit status:
Parse errors: Bad plan. You planned tests but ran .
Files=, Tests=, wallclock secs ( 0.02 usr 0.01 sys + 0.28 cusr 0.03 csys = 0.34 CPU)
Result: FAIL
Failed / test programs. / subtests failed.
make: *** [test_dynamic] Error
PLICEASE/File-Which-1.22.tar.gz
/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports PLICEASE/File-Which-1.22.tar.gz
Running make install
make test had returned bad status, won't install without force

解决方法

从Test Summary Report中可以看到(16~21行),这次是由于安装前的test没有全部成功导致的,其中t/02_all.t和t/03_simple.t两个test失败。

从第3行和第7行可以看出我们机器上还是少了点什么?虽然少什么我看不明白,但我会google啊,原来获取Env.pm需要使用perl-Env包

解决办法

sudo yum install perl-Env -y

问题总结

以前没有用过perl也没有使用cpan安装过perl程序,在遇到这个问题时,自己根本没有认真看错误的原因,扫了眼看到了

Parse errors: No plan found in TAP output

以为是这就是根本原因,就使用这个关键字在使用google,自然白忙活一阵,也没有找到解决办法。所以以后要认真看下错误提示,找到根本原因。

问题3

安装完perl-Env后,我们就可以很顺利的把File::HomeDir以及他的依赖程序安装完成,在安装Net::OpenSSH时,又出现一下问题

问题

 t/1_run.t .... Can't locate Digest/MD5.pm in @INC (@INC contains: ./t /root/.cpan/build/Net-OpenSSH-0.77-rRapXd/blib/lib /root/.cpan/build/Net-OpenSSH-0.77-rRapXd/blib/arch /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /root/.cpan/build/Net-OpenSSH-0.77-rRapXd/blib/lib/Net/OpenSSH.pm line 23.
BEGIN failed--compilation aborted at /root/.cpan/build/Net-OpenSSH-0.77-rRapXd/blib/lib/Net/OpenSSH.pm line .
Compilation failed in require at t/1_run.t line .
BEGIN failed--compilation aborted at t/1_run.t line .
t/1_run.t .... Dubious, test returned (wstat , 0x200)
No subtests run
t/quoting.t .. # unable to exec csh -c echo good
# unable to exec tcsh -c echo good
# unable to exec ksh -c echo good
# unable to exec dash -c echo good
# unable to exec ash -c echo good
# unable to exec pdksh -c echo good
# unable to exec mksh -c echo good
# unable to exec zsh -c echo good
# unable to exec fish -c echo good
# running tests for shells sh bash
t/quoting.t .. ok
t/uri.t ...... Can't locate Digest/MD5.pm in @INC (@INC contains: /root/.cpan/build/Net-OpenSSH-0.77-rRapXd/blib/lib /root/.cpan/build/Net-OpenSSH-0.77-rRapXd/blib/arch /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /root/.cpan/build/Net-OpenSSH-0.77-rRapXd/blib/lib/Net/OpenSSH.pm line 23.
BEGIN failed--compilation aborted at /root/.cpan/build/Net-OpenSSH-0.77-rRapXd/blib/lib/Net/OpenSSH.pm line .
Compilation failed in require at t/uri.t line .
BEGIN failed--compilation aborted at t/uri.t line .
t/uri.t ...... Dubious, test returned (wstat , 0x200)
No subtests run Test Summary Report
-------------------
t/1_run.t (Wstat: Tests: Failed: )
Non-zero exit status:
Parse errors: No plan found in TAP output
t/uri.t (Wstat: Tests: Failed: )
Non-zero exit status:
Parse errors: No plan found in TAP output
Files=, Tests=, wallclock secs ( 0.07 usr 0.01 sys + 0.58 cusr 0.67 csys = 1.33 CPU)
Result: FAIL
Failed / test programs. / subtests failed.
make: *** [test_dynamic] Error
SALVA/Net-OpenSSH-0.77.tar.gz
/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports SALVA/Net-OpenSSH-0.77.tar.gz
Running make install
make test had returned bad status, won't install without force

解决办法

跟问题2类似,我们使用强大的google很快就能找到解决方案

sudo yum install perl-Digest-MD5 -y

参考

https://github.com/agentzh/sshbatch

http://blog.51cto.com/wanglq/872463

https://superuser.com/questions/1181310/perl-script-cant-locate-env-pm-in-inc

https://stackoverflow.com/questions/34248737/cant-locate-digest-md5-pm-directadmin

安装ssh-batch工具的更多相关文章

  1. Ubuntu安装SSH服务器故障分析及解决办法(错误1:E:软件包 openssh-server 还没有可供安装的候选者,错误2:E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系)

    •    微博: 小样儿老师2015 Windows下做Linux开发需要SSH强大功能的支持.安装SSH的过程会出现了很多问题,看完这篇文章可以让你少走些弯路,PS:折腾一下午的成果. Ubuntu ...

  2. 关于ubuntu服务器上部署postgresql 以及安装pgadmin4管理工具(web版)

    进入目录:cd pgadmin4   source bin/activate     cd pgadmin4-1.6/ 启动pgadmin4:python web/pgAdmin4.py pgadmi ...

  3. ubuntu14.04安装ssh和ftp

    1.安装SSH >1.先使用netstat -tl或service ssh status查看ssh服务是否开启,如果没有开启,用service ssh restart开启,如果没有安装,使用su ...

  4. centos 6.3安装ssh

    centos 6.3安装ssh   安装ssh服务器端软件 yum install openssh-server   安装ssh客户端软件   yum install openssh-clients ...

  5. ubuntu下查询SSH状态和安装SSH服务

    1.查询SSH的安装状态 rpm -qa |grep ssh 上面的命令可能出现提示说rpm未安装,可以使用下面这命令进行安装 sudo apt-get install rpm 某些帖子上也可以使用y ...

  6. Ubuntu-18.04 下修改root用户密码,安装SSH服务,允许root用户远程登录,安装vsftp服务器

    修改root用户密码 打开终端,输入 sudo passwd root 指令: 安装SSH服务 ssh默认端口号是22,可以在/etc/ssh/sshd_config文件中修改 查看服务器否开启:ne ...

  7. 一个优秀的SSH远程终端工具

    SSH远程终端工具是一款在Windows界面下用来访问远端不同系统下的服务器,从而比较好的达到远程控制终端的目的.向我们操控集群的时候,如果每台机器都安装一个显示器和键盘也是一个不小的花费,而远程终端 ...

  8. sshd服务安装-ssh命令使用方法

    SSHD服务概述 介绍:SSH协议:安全外壳协议.为 Secure Shell的缩写.SSH 为建立在应用层和传输层基础上的安全协议. 作用:SSHD服务使用SSH协议可以用来进行远程控制,或在计算机 ...

  9. 解决ubuntu安装ssh服务无法打开解析包问题

    Windows下做Linux开发需要SSH强大功能的支持.安装SSH的过程会出现了很多问题,看完这篇文章可以让你少走些弯路,PS:折腾一下午的成果. Ubuntu的apt-get工具的牛逼之处简直无人 ...

  10. SSH客户端工具连接Linux(有的也可以连接Windows、mac、iOS等多系统平台)

    要远程操作Linux的话还是得靠SSH工具,一般来说,Linux是打开了默认22端口的SSH的服务端,如果我们要远程它的话,就需要一个SSH客户. 我对一款好用的工具主要需要满足以下几点. (1)连接 ...

随机推荐

  1. SQLServer2005 没有日志文件(*.ldf) 只有数据文件(*.mdf) 恢复数据库的方法

    代码如下: exec sp_attach_db exun,'d:\exun2.mdf' (可能执行一次不能成功,测试了下,有时候需要执行2次以上命令才行) 执行了之后,记得刷新数据库,不然是不会显示的

  2. 怎么使用mysqlreplicate快速搭建MySQL主从呢?

    用其中的mysqlreplicate工具来快速搭建MySQL主从环境. HE1:192.168.1.248 slave HE3:192.168.1.250 master 实战 Part1:安装mysq ...

  3. Linux之源码包

    暂时感觉用不上,到时需要了解的时候再补上

  4. could not insert: [com.trs.om.bean.UserLog] The user specified as a definer ('root'@'127.0.0.1') does not exist

    2019-07-01 11:24:09,315 [http-8080-24] org.hibernate.util.JDBCExceptionReporter logExceptionsWARN: S ...

  5. Oracle存储过程基本语法及基础教程

    存储过程 1 CREATE OR REPLACE PROCEDURE 存储过程名 2 IS 3 BEGIN 4 NULL; 5 END; 行1: CREATE OR REPLACE PROCEDURE ...

  6. Notepad++搜索中的正则应用

    假设要查找文件中所有tppabs="*****" 类型的代码 tppabs="http://www.******.com/templates/Alen/Css/Main. ...

  7. OpenTelemetry-可观察性的新时代

    有幸在2019KubeCon上海站听到Steve Flanders关于OpenTelemetry的演讲,之前Ops领域两个网红项目OpenTracing和OpenCensus终于走到了一起,可观察性统 ...

  8. spring boot 2.X上传文件限制大小

    Spring Boot 1.3.x multipart.maxFileSize multipart.maxRequestSize Spring Boot 1.4.x and 1.5.x spring. ...

  9. python HTTP请求过程

  10. 【数据库】sql2008卸载和默认实例的删除 标签: 数据库 2014-11-16 15:15 5878人阅读 评论(30)

    在安装sql2008的时候,会碰到这一步,要求创建实例,可以选择默认实例和命名实例,如果是第一次安装的话,可以选择默认实例,但是如果是第二次甚至更多次安装的 话,很多时候会出现不能用默认实例,只能自己 ...