目录
1.错误1
1.1查看集群状态
今天在阿里云服务器centos单机搭建zookeeper集群
查看集群状态的时候,总是提示:
Error contacting service. It is probably not running.
可是明明已经提示启动成功了啊????
1.2.查看日志
查看zookeeper01/bin/zookeeper.log,出现以下错误:
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:368)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:402)
at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:840)
at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:762)
2018-08-24 00:21:12,616 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2182:FastLeaderElection@849] - Notification time out: 60000
1.3分析
1.3.1端口没开
一直提示连接被拒绝,连接被拒绝难道是我端口没开,导致三个zookeeper之间无法通信????
好吧,我去开启linux端口,开启阿里云服务器安全组。
什么????还提示Connection refused,难道是我端口没开成功????
我百度在线扫描端口,扫描那9个端口,发现真的没开启,然后我直接关了防火墙
临时关闭防火墙
/etc/init.d/iptables stop
查看防火墙状态
/etc/init.d/iptables status
嗯,这回端口肯定打开了把,但是用工具扫描还是显示没开(其实已经开了)
只要提示:iptables: Firewall is not running.所有端口就开放了
只要防火墙关了,安全组设置了,就跟端口这些东西无关了
1.3.2检查配置文件
检查每个集群节点下的zoo.cfg文件
下面这个是我的
如果是虚拟机,则填写虚拟机ip即可
如果是公网服务器,一定要配置0.0.0.0,不要写公网ip,或者127.0.0.0之类的。
server.1=0.0.0.0:2881:3881
server.2=0.0.0.0:2882:3882
server.3=0.0.0.0:2883:3883
我就是坑在这里了,把ip改成0.0.0.0之后就启动成功了
2.错误2
2.1查看集群状态
查看集群状态的时候,总是提示:
Error contacting service. It is probably not running.
可是明明已经提示启动成功了啊????
2.2查看日志
java.net.UnknownHostException: localhost.localdomain.localdomain: localhost.localdomain.localdomain: Name or service not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:204)
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:368)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:341) at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:449)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:430)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.UnknownHostException: localhost.localdomain.localdomain: Name or service not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
at java.net.InetAddress.getLocalHost(InetAddress.java:1500)
2.3解决
修改 /etc/sysconfig/network中HOSTNAME的值为localhost
重启服务
/etc/rc.d/init.d/network restart
来源:CSDN
作者:最后的轻语_dd43
链接:https://blog.csdn.net/pdsu161530247/article/details/81983688