赞
踩
一、最近在用zookeeper搭建集群改造配置中心的单点故障问题:使用"四字命令"echo ruok|nc localhost 2181时报错:发现命令无法被识别:
[root@centos6 bin]# echo ruok|nc localhost 2181
-bash: nc: command not found
从提示信息中我们可以知道,是由于nc命令无法被找到。出现该情况有两种可能:
(1)没有配置nc命令的环境变量;
(2)该系统没有安装nc命令;
我查看了一下在/usr/bin目录中并没有nc命令,所以我可以认为出现该情况的原因是第二种情况
二、安装
2.1、配置yum
yum是一种在线安装和更新软件的工具,使用该工具要保证网络连接,还要有一个可用的软件源,可以使用163或sohu的软件源,软件源地址如下:
a:163的网址:http://mirrors.163.com/ ,进入后点击右列的“fedora使用帮助”,有使用说明
b:sohu的网址:http://mirrors.sohu.com/
c: Centos自带的源
在此我使用的是163的源,使用163下载源,则步骤如下:
a:下载fedora-163.repo和fedora-updates-163.repo, 通过winCP放入Linux中/etc/yum.repos.d/目录
b:运行以下命令生成缓存:yum clean all、yum makecache
2.2、执行yum install -y nc在线安装nc
[root@centos6 bin]# yum install -y nc
再次执行nc命令可得状态信息
# 再次执行 echo stat | nc localhost 2181
[root@centos6 bin]# echo stat | nc localhost 2181
Zookeeper version: 3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT
Clients:
/0:0:0:0:0:0:0:1:55071[0](queued=0,recved=1,sent=0)
Latency min/avg/max: 0/0/0
Received: 1
Sent: 0
Connections: 1
Outstanding: 0
Zxid: 0xa00000001
Mode: follower
Node count: 5
2.3、安装远程命令telnet
执行命令:yum list telnet*;查看telnet相关的安装包,结果如下:
telnet.x86_64表示客户端,telnet-server.x86_64表示服务端。我们需要的是客户端,安装telnet.x86_64即可。
执行命令 yum install telnet.x86_64安装即可
[root@centos6 bin]# yum install telnet.x86_64
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package telnet.x86_64 1:0.17-48.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================
Installing:
telnet x86_64 1:0.17-48.el6 base 58 k
Transaction Summary
======================================================================================================================================
Install 1 Package(s)
Total download size: 58 k
Installed size: 109 k
Is this ok [y/N]: y
Downloading Packages:
telnet-0.17-48.el6.x86_64.rpm | 58 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 1:telnet-0.17-48.el6.x86_64 1/1
Verifying : 1:telnet-0.17-48.el6.x86_64 1/1
Installed:
telnet.x86_64 1:0.17-48.el6
Complete!
验证执行命令 telnet --help ,如下所示安装成功
[root@centos6 bin]# telnet --help
telnet: invalid option -- '-'
Usage: telnet [-8] [-E] [-L] [-S tos] [-a] [-c] [-d] [-e char] [-l user]
[-n tracefile] [-b hostalias ] [-r]
[host-name [port]]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。