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

news2024/11/20 15:16:44

湖蓝几何球体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.coloradmin.cn/o/1351309.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

k8s的声明式资源管理(yaml文件)

1、声明式管理的特点 &#xff08;1&#xff09;适合对资源的修改操作 &#xff08;2&#xff09;声明式管理依赖于yaml文件&#xff0c;所有的内容都在yaml文件当中 &#xff08;3&#xff09;编辑好的yaml文件&#xff0c;还是要依靠陈述式的命令发布到k8s集群当中 kubect…

如何在ArcGIS Pro中指定坐标系

在进行制图的时候&#xff0c;为了实现某些特定的效果&#xff0c;需要指定特定的坐标系&#xff0c;但是现有的数据可能不是所需要的坐标系&#xff0c;这时候就需要对现有的数据坐标系进行处理&#xff0c;这里为大家介绍一下ArcGIS Pro中指定坐标系的方法&#xff0c;希望能…

关于标准那些事——第六篇 四象之“白虎”(要素的编写)

两仪生四象——东方青龙&#xff08;木&#xff09;、西方白虎&#xff08;金&#xff09;、南方朱雀&#xff08;火&#xff09;、北方玄武&#xff08;水&#xff09; 分别对应标准编写之四象——层次的编写、要素的编写、要素的表述、格式的编排。 今天来分享一下 要素的编…

系列五、搭建Naco(集群版)

一、搭建Naco&#xff08;集群版&#xff09; 1.1、前置说明 &#xff08;1&#xff09;64位Red Hat7 Linux 系统&#xff1b; &#xff08;2&#xff09;64位JDK1.8&#xff1b;备注&#xff1a;如果没有安装JDK&#xff0c;请参考【系列二、Linux中安装JDK】 &#xff08;3&…

Graceful Response 构建 Spring Boot 下优雅的响应处理

一、Graceful Response Graceful Response 是一个 Spring Boot 技术栈下的优雅响应处理器&#xff0c;提供一站式统一返回值封装、全局异常处理、自定义异常错误码等功能&#xff0c;使用Graceful Response进行web接口开发不仅可以节省大量的时间&#xff0c;还可以提高代码质…

SpringBoot 项目如何生成 swagger 文档

推荐使用 springdoc-openapi 的理由 1、springdoc-openapi 是 spring 官方出品&#xff0c;与 springboot 兼容更好&#xff08;springfox 兼容有坑&#xff09; 2、springdoc-openapi 社区更活跃&#xff0c;springfox 已经 2 年没更新了 3、springdoc-openapi 的注解更接近 …

如何在Mendix中实现全文检索

功能背景 在日常的应用使用过程中&#xff0c;存在大量希望使用全文检索技术的场景&#xff0c;对资料库中的内容进行查询。Mendix默认的结构化查询方式&#xff0c;适合对特定业务实体进行类似数据库单表的基于SQL语句的查询。那如何在Mendix实现全文检索的功能呢&#…

Flink-【时间语义、窗口、水位线】

1. 时间语义 1.1 事件时间&#xff1a;数据产生的事件&#xff08;机器时间&#xff09;&#xff1b; 1.2 处理时间&#xff1a;数据处理的时间&#xff08;系统时间&#xff09;。 &#x1f330;&#xff1a;可乐 可乐的生产日期 事件时间&#xff08;可乐产生的时间&…

vue $set 报错 Cannot use ‘in‘ operator to search for ‘imgs‘ in

这行代码会报上述错误 本意是当对象属性为空时,添加一个响应式属性. 猜测增加属性可能需要对象的原始地址,这里的 this.imageUploadData.rowData 显然不是原始地址,他是引用的 rowData 变量的地址. 于是改成 , 修改原始地址对象的属性,报错消失 this.$set(rowData, imgs, nu…

LanChatRoom局域网聊天室

CPP已经结课&#xff0c;我提交的项目是Qt的入门项目&#xff0c;局域网聊天室LanChatRoom。 这个代码重构了很多遍。第一遍是照着明哥推荐到书&#xff0c;把代码抄了一遍。 但抄下来之后&#xff0c;各种问题&#xff0c;而且是清朝老代码。抄了一遍之后&#xff0c;对代码的…

论文阅读:基于MCMC的能量模型最大似然学习剖析

On the Anatomy of MCMC-Based Maximum Likelihood Learning of Energy-Based Models 相关代码&#xff1a;点击 本文只介绍关于MCMC训练的部分&#xff0c;由此可知&#xff0c;MCMC常常被用于训练EBM。最后一张图源于Implicit Generation and Modeling with Energy-Based Mod…

Elasticsearch:带有自查询检索器的聊天机器人示例

本工作簿演示了 Elasticsearch 的自查询检索器 (self-query retriever) 将问题转换为结构化查询并将结构化查询应用于 Elasticsearch 索引的示例。 在开始之前&#xff0c;我们首先使用 langchain 将文档分割成块&#xff0c;然后使用 ElasticsearchStore.from_documents 创建…

IIS通过ARR实现负载均衡

一、实现整体方式介绍 项目中部署在windows服务器上的项目,需要部署负载均衡,本来想用nginx来配置的,奈何iis上有几个项目,把80端口和443端口占用了,nginx就用不了了(因为通过域名访问的,必须要用80和443端口),只能通过IIS的方式实现了。 这里用2个服务在一台机器上…

一个简单的接口自动化测试框架:Python+Requests+Pytest+Allure

项目结构 project&#xff1a;api_test ——api_keyword ————api_key.py&#xff1a;接口关键字驱动类 ——case ————test_cases.py&#xff1a;测试套件和测试用例 ——report_allure&#xff08;无需创建&#xff09;&#xff1a;allure报告 ——result&#xff08;…

git 如何撤销历史某次merge

git&#xff0c;如何 撤销某一次历史提交或merge&#xff0c;并保留该版本的后续提交&#xff1f; 场景1&#xff1a; 你有两个功能迭代版本的分支&#xff0c;一个是 15 号上线&#xff0c;一个是25号上线。5号的时候产品突然说&#xff0c;这两个版本一起上&#xff0c;然后…

【计算机图形学】NAP: Neural 3D Articulation Prior

文章目录 1. 这篇论文做了什么事&#xff0c;有什么贡献&#xff1f;2. Related Work铰接物体建模3D中的Diffusion model扩散模型 3. Pipeline铰接树参数化基于Diffusion的铰接树生成去噪网络 4. 实验评价铰接物体生成——以往做法与本文提出的新指标NAP捕捉到的铰接物体分布质…

gazebo卡住不动

可以看到这个sdf文件里面含有网络连接&#xff0c;有的sdf文件看上去几十个kb, 以为很小&#xff0c;但是里面含有网络连接就不知道有多大了&#xff0c;所以也可能会卡住,然后就会出现这个

无线路由器的五种工作模式:

1.Router&#xff0c;即无线路由模式&#xff0c;这也是我们最常用的一种工作方式&#xff0c;一般家里宽带连接&#xff0c;将宽带猫连接在无线路由的WAN口上&#xff0c;然后做拨号帐号设置&#xff0c;就用这个模式即可。 在Router&#xff08;无线路由&#xff09;模式下&a…

linux下docker搭建mysql8

1&#xff1a;环境信息 centos 7,mysql8 安装docker环境 2.创建mysql容器 2.1 拉取镜像 docker pull mysql:8.0.23 2.2 查询镜像拉取成功 docker images 2.3 创建挂载的目录文件 mkdir /usr/mysql8/conf mkdir /usr/mysql8/data ##给data文件赋予操作权限 chmod 777 /…

关于时间格式yyyy-M-d或yyyy-MM-d到yyyy-MM-dd的转换

工作时遇到前端传的时间格式是"2023-12-3 17:41:52"&#xff0c;和"2023-1-1 17:41:52"但是我想要的是"2023-12-03 17:41:52"和"2023-01-01 17:41:52"。下面给大家分享几个解决方法 方法一&#xff1a; 找前端&#xff01;让他改&…