格式化zookeeper时报错:拒绝连接

首先启动zookeeper集群:在每个节点的Zookeeper安装目录的bin目录下执行命令:

sh zkServer.sh start

jps命令查看启动后的节点:

格式化zookeeper时报错:拒绝连接_第1张图片

zookeeper集群启动后,在zk的leader节点上执行:这个指令的作用是在zookeeper集群上生成ha节点(ns节点)

hdfs zkfc -formatZK

报如下错误:

20/04/10 14:58:47 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: 拒绝连接
	at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
	at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
	at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
	at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
20/04/10 14:58:47 INFO zookeeper.ClientCnxn: Opening socket connection to server hadoop03/192.168.254.24:2181. Will not attempt to authenticate using SASL (unknown error)
20/04/10 14:58:47 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: 拒绝连接
	at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
	at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
	at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
	at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
20/04/10 14:58:48 INFO zookeeper.ClientCnxn: Opening socket connection to server hadoop02/192.168.254.23:2181. Will not attempt to authenticate using SASL (unknown error)

格式化zookeeper时报错:拒绝连接_第2张图片

 

格式化zookeeper时报错:拒绝连接_第3张图片

 

分析原因:

  • 首先,查看防火墙时候关闭

CentOS 6.5
service iptables start;#立即开启防火墙,但是重启后失效。
service iptables stop;#立即关闭防火墙,但是重启后失效。

chkconfig iptables on;#开启防火墙,重启后生效
chkconfig iptables off;#关闭防火墙,重启后生效 

CentOS 7
systemctl stop firewalld.service #关闭防火墙
systemctl disable firewalld.service #禁止启动防火墙


 

  • 然后,查看是否是网卡和网络问题

可以用 ip addr 或是 ifconfig 命令查看IP

重启网卡命令:service network restart

ping一下其他节点,验证网络没有故障:ping 192.168.254.23

 

 

  • 最后,查看是否是配置问题

  1. zoo.cfg文件
  2. myid文件

zoo.cfg文件配置如下:

dataDir=/home/hadoop/hadoop/zookeeper-3.4.7/tmp
server.1=192.168.254.22:2888:3888
server.2=192.168.254.23:2888:3888
server.3=192.168.254.24:2888:3888

新建一个tmp文件夹,把myid放在tmp文件夹下:

[root@hadoop01 zookeeper-3.4.7]# mkdir tmp
[root@hadoop01 zookeeper-3.4.7]# cd tmp
[root@hadoop01 tmp]# vim myid

myid中内容要与server.x的x一致,例如:这里要在三个节点的myid里填入1、2、3

 

 

重新执行:hdfs zkfc -formatZK

出现如下界面证明排错成功:


 

你可能感兴趣的:(#,大数据学习报错集合,zookeeper,hadoop,linux,centos,大数据)