zookeeper集群启动成功,用zkCli也可以正常连,但还是报错:java.net.ConnectException: Connection refused,等了半小时还是拒绝连接,用户间已经可以用ssh无密码登录,我用的是虚拟机装的3台机器做的

wangxiaolei

赞同来自:

不太明白你说的用zkCli也可以正常连,但还是报错:java.net.ConnectException:

wemike

赞同来自:

我按照顺序启动 zoo1,zoo2,zoo3 这3台机器,使用命令   /usr/local/zookeeper/bin/zkCli.sh -server zoo2:2181 输出:Connecting to zoo2:2181 Welcome to ZooKeeper! JLine support is enabled [zk: zoo2:2181(CONNECTING) 0], 但是使用命令 /usr/local/zookeeper/bin/zkServer.sh status 输出Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Error contacting service. It is probably not running.   说明服务器可以连接但是服务器没有启动,3台机器间一直报错连接拒绝,日志啥也不报,如何是好!!!

wangxiaolei

赞同来自:

查看下zookeeper.out文件内容,提示信息是什么。

wemike

赞同来自:

日志如下: 2016-04-12 09:00:41,492 [myid:] - INFO  [main:QuorumPeerConfig@103] - Reading configuration from: /usr/local/zookeeper/bin/../conf/zoo.cfg 2016-04-12 09:00:41,536 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolved hostname: zoo3 to address: zoo3/192.168.128.106 2016-04-12 09:00:41,536 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolved hostname: zoo2 to address: zoo2/192.168.128.104 2016-04-12 09:00:41,537 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolved hostname: zoo1 to address: zoo1/192.168.128.103 2016-04-12 09:00:41,537 [myid:] - INFO  [main:QuorumPeerConfig@331] - Defaulting to majority quorums 2016-04-12 09:00:41,541 [myid:1] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3 2016-04-12 09:00:41,542 [myid:1] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 1 2016-04-12 09:00:41,553 [myid:1] - INFO  [main:QuorumPeerMain@127] - Starting quorum peer 2016-04-12 09:00:41,566 [myid:1] - INFO  [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181 2016-04-12 09:00:41,574 [myid:1] - INFO  [main:QuorumPeer@1019] - tickTime set to 2000 2016-04-12 09:00:41,574 [myid:1] - INFO  [main:QuorumPeer@1039] - minSessionTimeout set to -1 2016-04-12 09:00:41,574 [myid:1] - INFO  [main:QuorumPeer@1050] - maxSessionTimeout set to -1 2016-04-12 09:00:41,574 [myid:1] - INFO  [main:QuorumPeer@1065] - initLimit set to 10 2016-04-12 09:00:41,586 [myid:1] - INFO  [PurgeTask:DatadirCleanupManager$PurgeTask@138] - Purge task started. 2016-04-12 09:00:41,604 [myid:1] - INFO  [PurgeTask:DatadirCleanupManager$PurgeTask@144] - Purge task completed. 2016-04-12 09:00:41,613 [myid:1] - INFO  [ListenerThread:QuorumCnxManager$Listener@534] - My election bind port: zoo1/192.168.128.103:3888 2016-04-12 09:00:41,619 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer@774] - LOOKING 2016-04-12 09:00:41,620 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@818] - New election. My id =  1, proposed zxid=0x0 2016-04-12 09:00:41,625 [myid:1] - INFO  [WorkerReceiver[myid=1]:FastLeaderElection@600] - Notification: 1 (message format version), 1 (n.leader), 0x0 (n.zxid), 0x1 (n.round), LOOKING (n.stat e), 1 (n.sid), 0x0 (n.peerEpoch) LOOKING (my state)2016-04-12 09:00:41,626 [myid:1] - WARN  [WorkerSender[myid=1]:QuorumCnxManager@400] - Cannot open channel to 2 at election address zoo2/192.168.128.104:3888 java.net.ConnectException: Connection refused   之后就一直 Connection refused了,基本上啥也没说

wangxiaolei

赞同来自:

日志的时间怎么是昨天的 zoo.cfg内容是啥 还有/etc/hosts文件配置的ip和主机名映射对不对。zoo2/192.168.128.104  

wemike

赞同来自:

/etc/hosts是对的,因为访问都没问题,是不是版本问题,我装的jdk版本是1.8,python版本是2.7,zookeeper版本是3.4.8 zoo.cfg内容如下,我把注释都给删了 tickTime=2000 initLimit=10 syncLimit=5 dataDir=/home/storm/data/zookeeper clientPort=2181 autopurge.purgeInterval=1 server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888  

wangxiaolei

赞同来自:

虚机的ip是自动分配的? /etc/hosts配置的和当前机器ip可以对应上么

wangxiaolei

赞同来自:

在zoo2上查看下QuorumPeerMain的进程id,然后执行下netstat -antp | fgrep 进程id 看看输出什么

wemike

赞同来自:

1. 虚拟的IP是制定的,ifconfig eth0 192.168.128.104这样   /etc/hosts肯定能对上scp都是根据 zoo2,zoo3这样传的,没有指定IP   2.执行netstat -antp | fgrep 进程id结果如下 [storm@localhost local]$ netstat -antp | fgrep 4704 tcp        0      0 :::2181                     :::*                        LISTEN      4704/java            tcp        0      0 :::51829                    :::*                        LISTEN      4704/java    

wangxiaolei

赞同来自:

storm@localhost这个没有zoo2主机名 执行hostname显示什么

wemike

赞同来自:

执行hostname显示localhost.localdomain,难道是主机名的问题导致的连接问题???我试试直接写IP地址试试

wemike

赞同来自:

把机器名字换了就好了,谢谢

要回复问题请先登录注册