标签:java linux zookeeper hadoop 大数据
环境:
VirtualBox:5.1.6
Centos:7
Java:1.8
Zookeeper:3.4.9
VirtualBox搭建的三个Zookeeper环境。
三个虚拟机的单机模式都正常:
[root@centos_1 data]# zkServer.sh status ZooKeeper JMX enabled by default Using config: /opt/zookeeper-3.4.9/bin/../conf/zoo.cfg Mode: standalone
从centos_1(192.168.1.156)中 ping centos_2(192.168.1.158)正常:
[root@centos_1 data]# ping -c 2 192.168.1.158 PING 192.168.1.158 (192.168.1.158) 56(84) bytes of data. 64 bytes from 192.168.1.158: icmp_seq=1 ttl=64 time=0.603 ms 64 bytes from 192.168.1.158: icmp_seq=2 ttl=64 time=0.795 ms --- 192.168.1.158 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1000ms rtt min/avg/max/mdev = 0.603/0.699/0.795/0.096 ms
从centos_2(192.168.1.158)中 ping centos_3(192.168.1.159)正常:
[root@centos_2 data]# ping -c 2 192.168.1.159 PING 192.168.1.159 (192.168.1.159) 56(84) bytes of data. 64 bytes from 192.168.1.159: icmp_seq=1 ttl=64 time=0.561 ms 64 bytes from 192.168.1.159: icmp_seq=2 ttl=64 time=1.10 ms --- 192.168.1.159 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1000ms rtt min/avg/max/mdev = 0.561/0.830/1.100/0.271 ms
配置文件:
# The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/opt/zookeeper-3.4.9/data # 日志文件 dataLogDir=/opt/zookeeper-3.4.9/logs # the port at which the clients will connect clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance# # The number of snapshots to retain in dataDir #autopurge.snapRetainCount=3# Purge task interval in hours # Set to "0" to disable auto purge feature #autopurge.purgeInterval=1 server.1=centos_1:2888:3888server.2=centos_2:2888:3888server.3=centos_3:2888:3888
集群不能正常启动,下面是具体的log:
[root@centos_3 data]# cat zookeeper.out 2016-11-03 19:33:18,609 [myid:] - INFO [main:QuorumPeerConfig@124] - Reading configuration from: /opt/zookeeper-3.4.9/bin/../conf/zoo.cfg 2016-11-03 19:33:18,625 [myid:] - INFO [main:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_3 to address: centos_3/192.168.1.1592016-11-03 19:33:33,628 [myid:] - INFO [main:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_2 to address: centos_2/220.250.64.2252016-11-03 19:33:38,633 [myid:] - INFO [main:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_1 to address: centos_1/220.250.64.2252016-11-03 19:33:38,634 [myid:] - INFO [main:QuorumPeerConfig@352] - Defaulting to majority quorums 2016-11-03 19:33:38,643 [myid:1] - INFO [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 32016-11-03 19:33:38,646 [myid:1] - INFO [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 02016-11-03 19:33:38,646 [myid:1] - INFO [main:DatadirCleanupManager@101] - Purge task is not scheduled. 2016-11-03 19:33:38,663 [myid:1] - INFO [main:QuorumPeerMain@127] - Starting quorum peer 2016-11-03 19:33:38,678 [myid:1] - INFO [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:21812016-11-03 19:33:38,725 [myid:1] - INFO [main:QuorumPeer@1019] - tickTime set to 20002016-11-03 19:33:38,725 [myid:1] - INFO [main:QuorumPeer@1039] - minSessionTimeout set to -1 2016-11-03 19:33:38,725 [myid:1] - INFO [main:QuorumPeer@1050] - maxSessionTimeout set to -1 2016-11-03 19:33:38,725 [myid:1] - INFO [main:QuorumPeer@1065] - initLimit set to 102016-11-03 19:33:38,742 [myid:1] - INFO [main:QuorumPeer@533] - currentEpoch not found! Creating with a reasonable default of 0. This should only happen when you are upgrading your installation 2016-11-03 19:33:38,765 [myid:1] - INFO [main:QuorumPeer@548] - acceptedEpoch not found! Creating with a reasonable default of 0. This should only happen when you are upgrading your installation 2016-11-03 19:33:38,778 [myid:1] - INFO [ListenerThread:QuorumCnxManager$Listener@534] - My election bind port: centos_1/220.250.64.225:38882016-11-03 19:33:38,780 [myid:1] - ERROR [centos_1/220.250.64.225:3888:QuorumCnxManager$Listener@547] - Exception while listening java.net.BindException: Cannot assign requested address (Bind failed) at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387) at java.net.ServerSocket.bind(ServerSocket.java:375) at java.net.ServerSocket.bind(ServerSocket.java:329) at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener.run(QuorumCnxManager.java:537) 2016-11-03 19:33:38,784 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer@774] - LOOKING 2016-11-03 19:33:38,785 [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-11-03 19:33:38,790 [myid:1] - INFO [WorkerReceiver[myid=1]:FastLeaderElection@600] - Notification: 1 (message format version), 1 (n.leader), 0x0 (n.zxid), 0x1 (n.round), LOOKING (n.state), 1 (n.sid), 0x0 (n.peerEpoch) LOOKING (my state) 2016-11-03 19:33:39,782 [myid:1] - INFO [centos_1/220.250.64.225:3888:QuorumCnxManager$Listener@534] - My election bind port: centos_1/220.250.64.225:38882016-11-03 19:33:39,782 [myid:1] - ERROR [centos_1/220.250.64.225:3888:QuorumCnxManager$Listener@547] - Exception while listening java.net.BindException: Cannot assign requested address (Bind failed) at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387) at java.net.ServerSocket.bind(ServerSocket.java:375) at java.net.ServerSocket.bind(ServerSocket.java:329) at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener.run(QuorumCnxManager.java:537) 2016-11-03 19:33:40,784 [myid:1] - INFO [centos_1/220.250.64.225:3888:QuorumCnxManager$Listener@534] - My election bind port: centos_1/220.250.64.225:38882016-11-03 19:33:40,785 [myid:1] - ERROR [centos_1/220.250.64.225:3888:QuorumCnxManager$Listener@547] - Exception while listening java.net.BindException: Cannot assign requested address (Bind failed) at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387) at java.net.ServerSocket.bind(ServerSocket.java:375) at java.net.ServerSocket.bind(ServerSocket.java:329) at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener.run(QuorumCnxManager.java:537) 2016-11-03 19:33:41,785 [myid:1] - INFO [centos_1/220.250.64.225:3888:QuorumCnxManager$Listener@560] - Leaving listener 2016-11-03 19:33:41,786 [myid:1] - ERROR [centos_1/220.250.64.225:3888:QuorumCnxManager$Listener@562] - As I‘m leaving the listener thread, I won‘t be able to participate in leader election any longer: centos_1/220.250.64.225:38882016-11-03 19:33:43,795 [myid:1] - WARN [WorkerSender[myid=1]:QuorumCnxManager@400] - Cannot open channel to 2 at election address centos_2/220.250.64.225:3888java.net.SocketTimeoutException: connect timed out 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.toSend(QuorumCnxManager.java:354) at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:452) at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:433) at java.lang.Thread.run(Thread.java:745) 2016-11-03 19:33:43,796 [myid:1] - INFO [WorkerSender[myid=1]:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_2 to address: centos_2/220.250.64.2252016-11-03 19:33:43,797 [myid:1] - WARN [WorkerSender[myid=1]:QuorumCnxManager@400] - Cannot open channel to 3 at election address centos_3/192.168.1.159:3888java.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.toSend(QuorumCnxManager.java:354) at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:452) at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:433) at java.lang.Thread.run(Thread.java:745) 2016-11-03 19:33:43,798 [myid:1] - INFO [WorkerSender[myid=1]:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_3 to address: centos_3/192.168.1.1592016-11-03 19:33:48,802 [myid:1] - WARN [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@400] - Cannot open channel to 2 at election address centos_2/220.250.64.225:3888java.net.SocketTimeoutException: connect timed out 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) 2016-11-03 19:33:48,803 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_2 to address: centos_2/220.250.64.2252016-11-03 19:33:48,804 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 4002016-11-03 19:33:54,206 [myid:1] - WARN [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@400] - Cannot open channel to 2 at election address centos_2/220.250.64.225:3888java.net.SocketTimeoutException: connect timed out 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) 2016-11-03 19:33:54,208 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_2 to address: centos_2/220.250.64.2252016-11-03 19:33:54,209 [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 centos_3/192.168.1.159:3888java.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) 2016-11-03 19:33:54,212 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_3 to address: centos_3/192.168.1.1592016-11-03 19:33:54,212 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 8002016-11-03 19:34:00,021 [myid:1] - WARN [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@400] - Cannot open channel to 2 at election address centos_2/220.250.64.225:3888java.net.SocketTimeoutException: connect timed out 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) 2016-11-03 19:34:00,022 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_2 to address: centos_2/220.250.64.2252016-11-03 19:34:00,024 [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 centos_3/192.168.1.159:3888java.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) 2016-11-03 19:34:00,024 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@149] - Resolved hostname: centos_3 to address: centos_3/192.168.1.1592016-11-03 19:34:00,025 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@852] - Notification time out: 16002016-11-03 19:34:06,632 [myid:1] - WARN [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@400] - Cannot open channel to 2 at election address centos_2/220.250.64.225:3888java.net.SocketTimeoutException: connect timed out 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)
原因:
因为安装的是min版,所以,不能根据hostname正常解析ip.
本文出自 “lybing” 博客,请务必保留此出处http://lybing.blog.51cto.com/3286625/1869122
标签:java linux zookeeper hadoop 大数据
原文地址:http://lybing.blog.51cto.com/3286625/1869122