防火墙未开端口导致zookeeper集群异常,kafka起不来

湖蓝几何球体LinkedIn Banner.png
转载说明:如果您喜欢这篇文章并打算转载它,请私信作者取得授权。感谢您喜爱本文,请文明转载,谢谢。


问题描述:

主机信息:

IPhostname
10.0.0.10host10
10.0.0.12host12
10.0.0.13host13

在这三台主机上部署一套zookeeper&kafka集群环境的时候,zk集群进程和端口都起来了。然后在启动kafka的时候,报错了,提示连不上zk。
因为该环境要求必须开启防火墙,所以想到应该是因为2181端口没有开放,所以kafka去连zk,提示连不上。于是在修改了防火墙,打开了2181端口和kafka的9092端口:

[root@host10 ~]#  firewall-cmd --list-ports
2181/tcp  9092/tcp 
[root@host10 ~]#

然后重新启动kafka,依旧报错,报错信息如下:

[root@host10 ~]# /usr/local/kafka_2.11-0.11.0.0/bin/kafka-server-start.sh /usr/local/kafka_2.11-0.11.0.0/config/server.properties
[2018-06-15 11:33:25,244] INFO KafkaConfig values:
        advertised.host.name = null
......   省略若干信息
[2018-06-15 11:33:26,693] INFO Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-06-15 11:33:28,219] INFO Opening socket connection to server 10.0.0.12/10.0.0.12181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2018-06-15 11:33:28,221] INFO Socket connection established to 10.0.0.12/10.0.0.12181, initiating session (org.apache.zookeeper.ClientCnxn)
[2018-06-15 11:33:28,222] INFO Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-06-15 11:33:28,910] INFO Opening socket connection to server 10.0.0.13/10.0.0.13181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2018-06-15 11:33:28,911] INFO Socket connection established to 10.0.0.13/10.0.0.13181, initiating session (org.apache.zookeeper.ClientCnxn)
[2018-06-15 11:33:28,913] INFO Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-06-15 11:33:29,901] INFO Opening socket connection to server 10.0.0.10/10.0.0.10181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2018-06-15 11:33:29,902] INFO Socket connection established to 10.0.0.10/10.0.0.10181, initiating session (org.apache.zookeeper.ClientCnxn)
[2018-06-15 11:33:29,905] INFO Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-06-15 11:33:31,133] INFO Opening socket connection to server 10.0.0.12/10.0.0.12181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2018-06-15 11:33:31,135] INFO Socket connection established to 10.0.0.12/10.0.0.12181, initiating session (org.apache.zookeeper.ClientCnxn)
[2018-06-15 11:33:31,136] INFO Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-06-15 11:33:31,379] INFO Terminate ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)
[2018-06-15 11:33:31,553] INFO Session: 0x0 closed (org.apache.zookeeper.ZooKeeper)
[2018-06-15 11:33:31,555] FATAL Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server '10.0.0.10:2181,10.0.0.12:2181,10.0.0.13:2181' with timeout of 6000 ms
        at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:1233)
        at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:157)
        at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:131)
        at kafka.utils.ZkUtils$.createZkClientAndConnection(ZkUtils.scala:103)
        at kafka.utils.ZkUtils$.apply(ZkUtils.scala:85)
        at kafka.server.KafkaServer.initZk(KafkaServer.scala:338)
        at kafka.server.KafkaServer.startup(KafkaServer.scala:191)
        at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:38)
        at kafka.Kafka$.main(Kafka.scala:65)
        at kafka.Kafka.main(Kafka.scala)
[2018-06-15 11:33:31,555] INFO EventThread shut down for session: 0x0 (org.apache.zookeeper.ClientCnxn)
[2018-06-15 11:33:31,562] INFO shutting down (kafka.server.KafkaServer)
[2018-06-15 11:33:31,568] INFO shut down completed (kafka.server.KafkaServer)
[2018-06-15 11:33:31,568] FATAL Exiting Kafka. (kafka.server.KafkaServerStartable)
[2018-06-15 11:33:31,571] INFO shutting down (kafka.server.KafkaServer)

查看kafka的配置,并未发现任何异常。于是检查zk自身是否OK。但是进程、端口都一切正常。
使用./zkCli.sh去检查zk是否正常启动,出现了报错:

[root@host10 bin]# ./zkCli.sh
Connecting to localhost:2181
2018-06-15 14:44:05,215 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT
......    #省略若干信息
2018-06-15 14:44:05,225 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@1a86f2f1
Welcome to ZooKeeper!
2018-06-15 14:44:05,255 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2018-06-15 14:44:05,334 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@876] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2018-06-15 14:44:05,348 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1158] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
[zk: localhost:2181(CONNECTING) 0] 2018-06-15 14:44:05,564 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-06-15 14:44:05,565 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@876] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2018-06-15 14:44:05,573 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1158] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2018-06-15 14:44:07,626 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-06-15 14:44:07,627 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@876] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2018-06-15 14:44:07,629 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1158] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2018-06-15 14:44:07,929 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-06-15 14:44:07,930 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@876] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2018-06-15 14:44:07,932 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1158] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2018-06-15 14:44:09,329 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-06-15 14:44:09,330 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@876] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2018-06-15 14:44:09,332 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1158] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect
2018-06-15 14:44:09,464 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)

分析:

查看了网上很多的文章,有以下几种说法:
1、zk的myid文件和配置文件server.xx的编号对不上:
2、zk只启动了一个节点,其他节点没有起来

排查:
1、检查myid编号和配置文件,是OK的,能对上:

[root@host10 ~]# cat /data/zookeeper/myid
1
[root@host10 ~]#
[root@host10 ~]# vim /usr/local/zookeeper-3.4.10/conf/zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
......  #省略若干
server.1=10.0.0.10:2888:3888   #server.1和myid文件的1是能对上的
server.2=10.0.0.12:2888:3888
server.3=10.0.0.13:2888:3888

2、zookeeper的配置文件zoo.cfg里面配置了三个server,实际上其他两个节点没有起来,因此根据zookeeper的选举算法,当整个集群超过半数机器宕机,zookeeper会认为集群处于不可用状态。

检查了三个节点的服务,都是起来了的。
试着将其中一台zk节点10.0.0.10,修改zoo.cfg,注释掉配置的其他两个server,只留本机的server配置:

[root@host10 ~]# vim /usr/local/zookeeper-3.4.10/conf/zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
......  #省略若干
server.1=10.0.0.10:2888:3888   #注释掉server.2和server.3,只剩下本机节点
#server.2=10.0.0.12:2888:3888
#server.3=10.0.0.13:2888:3888

然后使用zkCli.sh去检测zk状态,就是OK的:

[root@host10 ~]# cd /usr/local/zookeeper-3.4.10/bin/
[root@host10 bin]# ./zkCli.sh
Connecting to localhost:2181
2018-06-15 15:58:10,586 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT
......  #省略若干
2018-06-15 15:58:10,597 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@1a86f2f1
Welcome to ZooKeeper!
2018-06-15 15:58:10,627 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2018-06-15 15:58:10,708 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@876] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
[zk: localhost:2181(CONNECTING) 0] 2018-06-15 15:58:10,733 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x164023cac190003, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

[zk: localhost:2181(CONNECTED) 0]

于是想到是防火墙只开了zookeeper的2181端口。zk有三个端口:
3个端口的作用
1、2181:对cline端提供服务
2、3888:选举leader使用
3、2888:集群内机器通讯使用(Leader监听此端口)

因为防火墙的作用,三个节点之间2888和3888端口都是互相不通的,因此集群之前没有办法通信,可能就会以为是剩下两个节点都挂掉了。于是就出现了上面的报错

解决:

1、重新修改防火墙,打开2888和3888端口

[root@host10 ~]#  firewall-cmd --list-ports
 3888/tcp 2181/tcp 2888/tcp  9092/tcp 
[root@host10 ~]#

2、为保证万一,把整个zk集群全部按照顺序重启了一遍
3、三个几点依次都用zkCli.sh去连了一下,状态都是OK的
4、重新启动kafka,就OK啦

备注:本文为迁移博文,非近期遇到的故障

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/287008.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

工程化态势感知的困难

工程化态势感知的困难在于数据整合、大数据处理和分析、领域知识和模型构建、实时性和准确性要求以及安全和隐私问题。解决这些困难需要技术和专业知识的结合&#xff0c;以及各方面的合作和努力。 多源异构数据的整合&#xff1a;工程化态势感知需要从各种数据源获取数据&…

Java动态代理与反射

动态代理 反射 原理 ​​​​ 类加载五个阶段&#xff1a; 使用 1.获取class字节码 2. 获取构造函数、构造函数修饰符、构造函数参数&#xff08;字段、方法类似&#xff09; 方法&#xff1a; 方法执行 应用 总结

Matlab论文插图绘制模板第133期—函数极坐标折线图

在之前的文章中&#xff0c;分享了Matlab函数折线图的绘制模板&#xff1a; 函数三维折线图&#xff1a; 函数网格曲面图&#xff1a; 函数曲面图&#xff1a; 函数等高线图&#xff1a; 函数等高线填充图&#xff1a; 进一步&#xff0c;再来分享一下函数极坐标折线图。 先来…

机器学习与深度学习——使用paddle实现随机梯度下降算法SGD对波士顿房价数据进行线性回归和预测

文章目录 机器学习与深度学习——使用paddle实现随机梯度下降算法SGD对波士顿房价数据进行线性回归和预测一、任务二、流程三、完整代码四、代码解析五、效果截图 机器学习与深度学习——使用paddle实现随机梯度下降算法SGD对波士顿房价数据进行线性回归和预测 随机梯度下降&a…

【WPF.NET开发】WPF中的输入

本文内容 输入 API事件路由处理输入事件文本输入触摸和操作侧重点鼠标位置鼠标捕获命令输入系统和基元素 Windows Presentation Foundation (WPF) 子系统提供了一个功能强大的 API&#xff0c;用于从各种设备&#xff08;包括鼠标、键盘、触摸和触笔&#xff09;获取输入。 本…

orange3,一个无敌的 Python 库!

更多Python学习内容&#xff1a;ipengtao.com 大家好&#xff0c;今天为大家分享一个无敌的 Python 库 - orange3。 Github地址&#xff1a;https://github.com/biolab/orange3 数据科学和机器学习是当今科技领域的重要组成部分&#xff0c;而数据分析和建模通常是其中的关键步…

【数据分析】指数移动平均线的直观解释

slavahead 一、介绍 在时间序列分析中&#xff0c;通常需要通过考虑先前的值来了解序列的趋势方向。序列中下一个值的近似可以通过多种方式执行&#xff0c;包括使用简单基线或构建高级机器学习模型。 指数&#xff08;加权&#xff09;移动平均线是这两种方法之间的稳健权衡。…

【Unity中的A星寻路】Navigation导航寻路系统四大页签详解

&#x1f468;‍&#x1f4bb;个人主页&#xff1a;元宇宙-秩沅 &#x1f468;‍&#x1f4bb; hallo 欢迎 点赞&#x1f44d; 收藏⭐ 留言&#x1f4dd; 加关注✅! &#x1f468;‍&#x1f4bb; 本文由 秩沅 原创 &#x1f468;‍&#x1f4bb; 收录于专栏&#xff1a;Uni…

STL map容器与pair类模板(解决扫雷问题)

CSTL之Map容器 - 数据结构教程 - C语言网 (dotcpp.com)https://www.dotcpp.com/course/118CSTL之Pair类模板 - 数据结构教程 - C语言网 (dotcpp.com)https://www.dotcpp.com/course/119 刷到一个扫雷的题目&#xff0c;之前没有玩怎么过扫雷&#xff0c;于是我就去玩了玩…

M3u8视频地址如何转为mp4视频

在当今数字化的时代&#xff0c;视频格式的转换已成为日常需求。M3u8格式的视频由于其分段的特性&#xff0c;常常给播放和编辑带来不便。而MP4格式则因其通用性和高质量而广受欢迎。那么&#xff0c;如何将M3u8视频地址转换为MP4格式呢&#xff1f;接下来&#xff0c;我们将为…

网络安全B模块(笔记详解)- 数字取证

数据分析数字取证-attack 1.使用Wireshark查看并分析Windows 7桌面下的attack.pcapng数据包文件,通过分析数据包attack.pcapng找出恶意用户的IP地址,并将恶意用户的IP地址作为Flag(形式:[IP地址])提交; 解析:http.request.method==POST ​ Flag:[172.16.1.102] 2.继续…

This is probably not a problem with npm.

项目场景&#xff1a; 新创建的vue3项目&#xff0c;根据elementplus官网安装步骤进行按需导入安装&#xff0c;运行项目报错 This is probably not a problem with npm.There is likely additional logging output above. 原因分析&#xff1a; 是elementplus安装版本和自动…

克隆clone github上某个项目的子目录

有时会遇到只需要克隆github某个项目的子目录&#xff0c;此时可以使用以下方法实现&#xff1a; 需求示例&#xff1a; 现需要克隆&#xff1a;https://github.com/SingleZombie/DL-Demos项目中的ddim项目 注&#xff1a;ddim项目的地址为&#xff1a;https://github.com/Sing…

Pytorch上采样

文章目录 Upsample特殊上采样 Upsample 所谓上采样&#xff0c;实则是一个插值过程。所以上采样对象在初始化时&#xff0c;需要指定一个插值类型&#xff0c;Upsample是torch.nn中最基础的上采样类&#xff0c;初始化参数如下 Upsample(sizeNone, scale_factorNone, modenea…

Django(五)

员工管理系统 1.新建项目 2.创建app python manage.py startapp app012.1 注册app 3. 设计表结构&#xff08;django&#xff09; from django.db import modelsclass Department(models.Model):""" 部门表 """title models.CharField(verbos…

AJAX(一)

一、AJAX简介 AJAX全称为 Asynchronous JavaScript And XML,就是异步的JS和XML。 通过AJAX可以在浏览器中向服务器发送异步请求&#xff0c;最大的优势&#xff1a;无刷新获取数据 AJAX不是新的编程语言&#xff08;使用的js)&#xff0c;而是一种将现有的标准组合在一起使用的…

【Apache-2.0】springboot-openai-chatgpt超级AI大脑产品架构图

springboot-openai-chatgpt: 一个基于SpringCloud的Chatgpt机器人&#xff0c;已对接GPT-3.5、GPT-4.0、百度文心一言、stable diffusion AI绘图、Midjourney绘图。用户可以在界面上与聊天机器人进行对话&#xff0c;聊天机器人会根据用户的输入自动生成回复。同时也支持画图&a…

解决json.decoder.JSONDecodeError: Extra data: line 1 column 721 (char 720)问题

python中将字符串序反列化成json格式时报错 fn result_json[0].decode(utf-8).strip(\00) json_object json.loads(fn) print(type(json_object))排查了以下原因应该是序列化的字符串全都在一行&#xff0c;json库不能一次性处理这么长的序列

每天刷两道题——第三天

1.1两两交换链表中的节点 给你一个链表&#xff0c;两两交换其中相邻的节点&#xff0c;并返回交换后链表的头节点。你必须在不修改节点内部的值的情况下完成本题&#xff08;即&#xff0c;只能进行节点交换&#xff09; 输入&#xff1a;[1,2,3,4] 输出&#xff1a;[2,1,4,3…

摄像头监控系统/视频监控云平台EasyCVR鼠标指示故障,该如何解决?

安防视频监控/视频集中存储/云存储/磁盘阵列EasyCVR平台可拓展性强、视频能力灵活、部署轻快&#xff0c;可支持的主流标准协议有国标GB28181、RTSP/Onvif、RTMP等&#xff0c;以及支持厂家私有协议与SDK接入&#xff0c;包括海康Ehome、海大宇等设备的SDK等。平台既具备传统安…
最新文章