Cannot open channel to 3 at election address :3888 java.net.ConnectException: Connection refused (Connection refused)
关于Linux中搭建分布式时可能遇到的问题
这个问题来自于今天安装zookeeper时踩的一个大坑,害的我花了一天时间。在搭建zookeeper的分布式时,往往要进行这样的配置:
server.1=hadoop01:2888:3888
server.2=hadoop02:2888:3888
server.3=hadoop03:2888:3888
一开始我是按照这样的配置来做的,后来死活不成功,zookeeper.out中的信息如下:
2017-04-21 06:05:34,385 [myid:1] - WARN [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@400] - Cannot open channel to 3 at election address hadoop05/192.168.31.155:3888
java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:381)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:426)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:843)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:822)
先不要关心日志的时间(其实你们也不会关注的,这个是没有配时间,所以显示早上六点,哪个傻叉会6点起来)。
对于这个错误,网上大多数说的是zookeeper启动顺序导致开始选举不稳定引起的,不用担心,过一会儿就会好的,可是对于我来说并不管用。然后就是什么主机映射之类的,就算配了主机映射,三台虚拟机都可以相互ping通,似乎也没什么卵用。继续查资料,发现又有这样的一种配置:
server.1=192.168.31.151:2888:3888
server.2=192.168.31.152:2888:3888
server.3=192.168.31.153:2888:3888
然后我又照着这种配置又配了一遍,发现这样居然可以,leader和follower都选出来了。激动之余,尼玛问题究竟出在哪儿,这样两种配置有啥不一样,这又让我寝食难安,百度了一圈毛都没发现。然后就google去了,反正就是在一个犄角旮旯找到了一个问答,发现别人也是有这种问题,链接在此:
https://unix.stackexchange.com/questions/240506/zookeeper-dns-name-problems-with-leader-elections-when-migrating-from-windows-to
问的题目是:
Zookeeper DNS name problems with leader elections when migrating from Windows to Debian
回答的人就说了:
The "smoking gun" was this line in my zookeeper log:
2015-11-26 20:48:31,439 [myid:1] - INFO
[Thread-2:QuorumCnxManager$Listener@504] - My election bind port:
spring-xd-1/127.0.0.1:3888
So, why was Zookeeper binding the election port on the loopback interface? Well...
My /etc/hosts on one of the VMs looked like this:
127.0.0.1 spring-xd-1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain
localhost6 localhost6.localdomain6 ## vagrant-hostmanager-start
172.28.128.3 spring-xd-1
172.28.128.4 spring-xd-2
172.28.128.7 spring-xd-3
## vagrant-hostmanager-end
I removed the hostname from the 127.0.0.1 line in /etc/hosts and bounced the zookeeper service on all 3 nodes, and BAM! everything came up roses. So, now the host file on each machine looks like this:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain
localhost6 localhost6.localdomain6 ## vagrant-hostmanager-start
172.28.128.3 spring-xd-1
172.28.128.4 spring-xd-2
172.28.128.7 spring-xd-3
## vagrant-hostmanager-end
最后一段有点启发意义:
EDIT: According to
http://ccl.cse.nd.edu/operations/condor/hostname.shtml, this seems to
be a fairly common problem with clustered apps on Linux, and
recommends editing the hosts file as I've described above. However,
the Zookeeper documentation on cluster setup doesn't mention it.
想去访问这个说明这个问题的网址,可惜访问不了,mmp!
P.S. 搭zookeeper这个硬是要搞出人命
Cannot open channel to 3 at election address :3888 java.net.ConnectException: Connection refused (Connection refused)的更多相关文章
- zookeeper 集群 Cannot open channel to X at election address Error contacting service. It is probably not running.
zookeeper集群 启动 1.问题现象. 启动每一个都提示 STARTED 但是查看 status时全部节点都报错 [root@ip-172-31-19-246 bin]# sh zkSer ...
- 报错:WARN [WorkerSender[myid=1]:QuorumCnxManager@584] - Cannot open channel to 2 at election address /x.x.x.x:3888
报错背景: zookeeper安装完成之后,启动之后正常,但是查看log文件zookeeper.log时发现报错. 报错现象: -- ::, [myid:] - INFO [WorkerSender[ ...
- zookeeper 集群配置采坑 Connection refused WARN [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@584] - Cannot open channel to 3 at election address slave2/192.168.127.133:3888
坑一: Cannot open channel to at election address slave1/ java.net.ConnectException: Connection refused ...
- [异常笔记] zookeeper集群启动异常: Cannot open channel to 2 at election address ……
- ::, [myid:] - WARN [WorkerSender[myid=]:QuorumCnxManager@] - Cannot open channel to at election ad ...
- WARN [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@584] - Cannot open channel to 4 at election address Slave3.Hadoop/xxx.xxx.xxx.xxx
这些日子为这个错误苦恼很久了,网上找到的各种方法都试了一遍,还是没能解决. 安装好zookeeper后,运行zkServer.sh start 显示正常启动,但运行zkServer.sh status ...
- zookeeper启动时报Cannot open channel to X at election address Error contacting service. It is probably not running.
配置storm集群的时候出现如下异常: 2016-06-26 14:10:17,484 [myid:1] - WARN [SyncThread:1:FileTxnLog@334] - fsync-in ...
- How to support both ipv4 and ipv6 address for JAVA code.
IPv6 have colon character, for example FF:00::EEIf concatenate URL String, IPv6 URL will like: http: ...
- Zookeeper 启动错误
启动后日志如下 : 2016-09-14 05:51:19,449 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeade ...
- Zookeeper- Error contacting service. It is probably not running解决方案和原理
搭建启动Zookeeper集群出现Error contacting service. It is probably not running解决方案和原理 1.关闭防火墙 [root@srv01 bi ...
随机推荐
- JavaEE目录
第一章: Spring介绍 Spring项目搭建 Spring概念 第二章: Sprin配置详解 属性注入(构造方法注入,设值注入) 实例化(构造器(空参构造器),静态工厂,工厂方法) 装配(xml方 ...
- 分享最新申请IDP账号的过程,包含duns申请的分享(2013年6月)
5月份接到公司要申请开发者账号的任务,就一直在各个论坛找申请的流程,但都是一些09年10年的比较旧的流程,现在都已经不适用了,好不容易找到2012年分享的流程吧,才发现申请过程中少了DUNS编码的步骤 ...
- lock参数变化吗
多线程应用中经常使用lock,在使用这个关键字的时候,经常有个疑问,如果更改了当时的入参,那么是否会变化呢,下面通过代码实例测试一把 class Program { static void Main( ...
- [Android Traffic] 让android应用在传输网络数据的时候更省电
到今年6月,我国的手机网民已经达到了3.88亿,超过了电脑终端.相信有智能机的同学都用过手机上网冲浪.但是手机的电量很快被用光了恐怕是每个人都不能忍受的一件事情.而打开数据连接进行网络数据的传输是很耗 ...
- [置顶]
kubernetes-kubectl命令说明
kubectl kubectl controls the K8S cluster manager. Find more information at https://github.com/K8S/K8 ...
- win10 下常用shell命令
shell脚本命令 单行过长如何换行 在一行的结尾加上^即可 , 打印当前目录 %cd%
- Java:集合类的区别详解
Java中集合类的区别 Array是数组,不在集合框架范畴之内,一旦选定了,它的容量大小就不能改变了,所以通常在编程中不选用数组来存放. 集合 : 集合对象:用于管理其他若干对象的对象 数组:长度不可 ...
- Python 最火 IDE 最受欢迎(转载)
来自:开源中国社区 链接:https://www.oschina.net/news/86973/packt-skill-up-2017 电子书网站 Packt 刚刚发布了第三届 “Skill UP” ...
- Hive错误记录
创建表报错 Error: Error while processing statement: FAILED: Execution Error, return code 1 from org.apach ...
- ASP.NET MVC学习---(一)ORM框架,EF实体数据模型简介
现如今 对象关系映射(ORM)框架 被大量的使用于企业级应用的开发 为什么要使用ORM? ADO.NET操作数据库不好吗? 我们可以仔细想想 当我们使用ADO.NET操作数据库的时候 我们需要先获取连 ...