Kafka 之 KRaft —— 配置、存储工具、部署注意事项、缺失的特性

目录

一. 前言

二. 配置(Configuration)

2.1. 处理者角色(Process Roles)

2.2. 控制器(controller)

2.3. 存储工具(Storage Tool)

2.4. 调试(Debugging)

2.4.1. 元数据选举工具(Metadata Quorum Tool)

2.4.2. 转储日志工具(Dump Log Tool)

2.4.3. 元数据指令(Metadata Shell)

2.5. 部署注意事项(Deploying Considerations)

2.6. 缺失的特性(Missing Features)


一. 前言

    目前,Kafka 在使用的过程当中,会出现一些问题。由于重度依赖 Zookeeper 集群,当Zookeeper 集群性能发生抖动时,Kafka 的性能也会收到很大的影响。因此,在 Kafka 发展的过程当中,为了解决这个问题,提供 KRaft 模式,来取消 Kafka 对 Zookeeper 的依赖。

二. 配置(Configuration)

2.1. 处理者角色(Process Roles)

原文引用:In KRaft mode each Kafka server can be configured as a controller, a broker, or both using the process.roles property. This property can have the following values:

  • If process.roles is set to broker, the server acts as a broker.
  • If process.roles is set to controller, the server acts as a controller.
  • If process.roles is set to broker,controller, the server acts as both a broker and a controller.
  • If process.roles is not set at all, it is assumed to be in ZooKeeper mode.

    在 KRaft 模式中,每个 Kafka 服务器都可以使用 process.roles 属性配置为 controller、broker 或这两个。此属性可以具有以下值:

  • 如果 process.roles 设置为 broker,则服务器将充当 Broker。
  • 如果 process.roles 设置为 controller,则服务器将充当 Controller。
  • 如果 process.roles 设置为 broker,controller,则服务器同时充当 Broker 和 Controller。
  • 如果根本没有设置 process.roles,则假定它处于 ZooKeeper 模式。

原文引用:Kafka servers that act as both brokers and controllers are referred to as "combined" servers. Combined servers are simpler to operate for small use cases like a development environment. The key disadvantage is that the controller will be less isolated from the rest of the system. For example, it is not possible to roll or scale the controllers separately from the brokers in combined mode. Combined mode is not recommended in critical deployment environments.

    同时充当 Broker 和 Controller 的 Kafka 服务器被称为“组合”服务器。对于像开发环境这样的小用例,组合服务器更易于操作。关键的缺点是控制器与系统的其余部分的隔离度较低。例如,在组合模式下,不可能将 Controller 与 Broker 程序分开滚动或缩放。不建议在关键部署环境中使用组合模式。

2.2. 控制器(controller)

原文引用:In KRaft mode, specific Kafka servers are selected to be controllers (unlike the ZooKeeper-based mode, where any server can become the Controller). The servers selected to be controllers will participate in the metadata quorum. Each controller is either an active or a hot standby for the current active controller.

    在 KRaft 模式中,特定的 Kafka 服务器被选择为控制器(与基于 ZooKeeper 的模式不同,在该模式中,任何服务器都可以成为控制器)。被选为控制器的服务器将参与元数据选举。每个控制器都是当前活动控制器的活动控制器或热备用控制器。

原文引用:A Kafka admin will typically select 3 or 5 servers for this role, depending on factors like cost and the number of concurrent failures your system should withstand without availability impact. A majority of the controllers must be alive in order to maintain availability. With 3 controllers, the cluster can tolerate 1 controller failure; with 5 controllers, the cluster can tolerate 2 controller failures.

    Kafka 管理员通常会为这个角色选择3到5台服务器,这取决于成本和系统在不影响可用性的情况下应该承受的并发故障数量等因素。为了保持可用性,大多数控制器必须是活动的。有3个控制器,集群可以容忍1个控制器故障;使用5个控制器,集群可以容忍2个控制器故障。

原文引用:All of the servers in a Kafka cluster discover the quorum voters using the controller.quorum.voters property. This identifies the quorum controller servers that should be used. All the controllers must be enumerated. Each controller is identified with their id, host and port information. For example: 

    Kafka 集群中的所有服务器都使用 controller.quorum.voters 属性来发现 quorum 投票者。这标识了应使用的选举控制器服务器。必须列举所有控制器。每个控制器都通过其 id、host 和 port 信息进行标识。例如:

controller.quorum.voters=id1@host1:port1,id2@host2:port2,id3@host3:port3

原文引用:If a Kafka cluster has 3 controllers named controller1, controller2 and controller3, then controller1 may have the following configuration:

    如果一个 Kafka 集群有三个控制器,分别命名为 controller1、controller2 和 controller3,那么controller1 可能具有以下配置:

process.roles=controller
node.id=1
listeners=CONTROLLER://controller1.example.com:9093
controller.quorum.voters=1@controller1.example.com:9093,2@controller2.example.com:9093,3@controller3.example.com:9093

原文引用:Every broker and controller must set the controller.quorum.voters property. The node ID supplied in the controller.quorum.voters property must match the corresponding id on the controller servers. For example, on controller1, node.id must be set to 1, and so forth. Each node ID must be unique across all the servers in a particular cluster. No two servers can have the same node ID regardless of their process.roles values.

    每个 Broker 和 Controller 都必须设置 controller.quorum.voters 属性。controller.quorum.voters属性中提供的节点 ID 必须与 Controller 服务器上的相应 ID 匹配。例如,在 controller1 上,node.id 必须设置为1,依此类推。在特定集群中的所有服务器中,每个节点 ID 都必须是唯一的。无论两台服务器的 process.role 值如何,都不能具有相同的节点 ID。

2.3. 存储工具(Storage Tool)

原文引用:The kafka-storage.sh random-uuid command can be used to generate a cluster ID for your new cluster. This cluster ID must be used when formatting each server in the cluster with the kafka-storage.sh format command.

    kafka-storage.sh random uuid 命令可用于为新集群生成集群 ID。使用 kafka-storage.sh format命令格式化群集中的每个服务器时,必须使用此群集 ID。

原文引用:This is different from how Kafka has operated in the past. Previously, Kafka would format blank storage directories automatically, and also generate a new cluster ID automatically. One reason for the change is that auto-formatting can sometimes obscure an error condition. This is particularly important for the metadata log maintained by the controller and broker servers. If a majority of the controllers were able to start with an empty log directory, a leader might be able to be elected with missing committed data.

    这与 Kafka 过去的运作方式不同。以前,Kafka 会自动格式化空白存储目录,并自动生成新的集群 ID。修改的一个原因是,自动格式化有时会模糊错误条件。这对于由 Controller 和 Broker 服务器维护的元数据日志来说尤其重要。如果大多数 Controller 能够从一个空的日志目录开始,则可能能够在缺少提交数据的情况下选出 Leader。

2.4. 调试(Debugging)

2.4.1. 元数据选举工具(Metadata Quorum Tool)

原文引用:The kafka-metadata-quorum tool can be used to describe the runtime state of the cluster metadata partition. For example, the following command displays a summary of the metadata quorum:

    Kafka kafka-metadata-quorum(元数据选举工具)可用于描述集群元数据分区的运行时状态。例如,以下命令显示元数据选举的摘要:

> bin/kafka-metadata-quorum.sh --bootstrap-server  broker_host:port describe --status
ClusterId:              fMCL8kv1SWm87L_Md-I2hg
LeaderId:               3002
LeaderEpoch:            2
HighWatermark:          10
MaxFollowerLag:         0
MaxFollowerLagTimeMs:   -1
CurrentVoters:          [3000,3001,3002]
CurrentObservers:       [0,1,2]

2.4.2. 转储日志工具(Dump Log Tool)

原文引用:The kafka-dump-log tool can be used to debug the log segments and snapshots for the cluster metadata directory. The tool will scan the provided files and decode the metadata records. For example, this command decodes and prints the records in the first log segment:

    Kafka kafka-dump-log(转储日志工具)可用于调试集群元数据目录的日志段和快照。该工具将扫描提供的文件并解码元数据记录。例如,此命令解码并打印第一个日志段中的记录:

> bin/kafka-dump-log.sh --cluster-metadata-decoder --files metadata_log_dir/__cluster_metadata-0/00000000000000000000.log

原文引用:This command decodes and prints the records in the a cluster metadata snapshot:

此命令解码并打印集群元数据快照中的记录:

> bin/kafka-dump-log.sh --cluster-metadata-decoder --files metadata_log_dir/__cluster_metadata-0/00000000000000000100-0000000001.checkpoint

2.4.3. 元数据指令(Metadata Shell)

原文引用:The kafka-metadata-shell tool can be used to interactively inspect the state of the cluster metadata partition:

Kafka kafka-metadata-shell(元数据外壳工具)可用于交互式检查集群元数据分区的状态:

> bin/kafka-metadata-shell.sh  --snapshot metadata_log_dir/__cluster_metadata-0/00000000000000000000.log
>> ls /
brokers  local  metadataQuorum  topicIds  topics
>> ls /topics
foo
>> cat /topics/foo/0/data
{"partitionId" : 0,"topicId" : "5zoAlv-xEh9xRANKXt1Lbg","replicas" : [ 1 ],"isr" : [ 1 ],"removingReplicas" : null,"addingReplicas" : null,"leader" : 1,"leaderEpoch" : 0,"partitionEpoch" : 0
}
>> exit

2.5. 部署注意事项(Deploying Considerations)

原文引用:

  • Kafka server's process.role should be set to either broker or controller but not both. Combined mode can be used in development environments, but it should be avoided in critical deployment environments.
  • For redundancy, a Kafka cluster should use 3 controllers. More than 3 controllers is not recommended in critical environments. In the rare case of a partial network failure it is possible for the cluster metadata quorum to become unavailable. This limitation will be addressed in a future release of Kafka.
  • The Kafka controllers store all the metadata for the cluster in memory and on disk. We believe that for a typical Kafka cluster 5GB of main memory and 5GB of disk space on the metadata log director is sufficient.
  • Kafka 服务器的 process.role 应该设置为 broker 或 controller,但不能同时设置。组合模式可以在开发环境中使用,但在关键部署环境中应避免使用。
  • 对于冗余,一个 Kafka 集群应该使用3个 Controlloer。不建议在关键环境中使用3个以上的Controlloer。在极少数的部分网络故障情况下,群集元数据选举可能变得不可用。这一限制将在 Kafka 的未来版本中得到解决。
  • Kafka Controller 将集群的所有元数据存储在内存和磁盘上。我们认为,对于典型的 Kafka 集群,元数据日志导向器上 5GB 的主内存和 5GB 的磁盘空间就足够了。

2.6. 缺失的特性(Missing Features)

原文引用:The following features are not fully implemented in KRaft mode:

  • Supporting JBOD configurations with multiple storage directories
  • Modifying certain dynamic configurations on the standalone KRaft controller
  • Delegation tokens

以下功能未在 KRaft 模式中完全实现:

  • 支持具有多个存储目录的 JBOD 配置。
  • 修改独立 KRaft 控制器上的某些动态配置。
  • 委派令牌。

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

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

相关文章

Datawhale X 李宏毅苹果书 AI夏令营 入门笔记

文章目录 前言Task01 通过案例了解机器学习1.1机器学习的浅显介绍1.2机器学习模型的构建1.3一些感悟 第一章 前言 本文依托datawhale夏令营撰写的学习笔记,教程链接 期待大家的交流指正 Task01 通过案例了解机器学习 1.1机器学习的浅显介绍 机器学习就是让机器具…

Claude 与 ChatGPT:哪个更适合学术写作,深入对比分析

人工智能写作助手已成为学者、研究人员和学生的强大资源。Anthropic 的 Claude 和 OpenAI 的 ChatGPT 是该领域的两大主要参与者。随着这些人工智能工具的不断发展和改进,越来越多的学者面临着选择使用哪种助手来完成工作的困境。 Claude 和 ChatGPT 在应用于学术工…

第十四章 rust集合库介绍

注意 本系列文章已升级、转移至我的自建站点中,本章原文为:rust集合库介绍 目录 注意一、前言二、map三、list四、set五、deque一、前言 基本的数据结构各种语言都会有自己的实现,rust也不例外。 在rust中,这些数据结构的实现被称作“集合”,被放置在了std::colections…

【GPT】Coze使用开放平台接口-【6】Dify 也来一遍

前面讲了 coze 的相关用法,这边想着用 Dify 也来一遍,刚开始的时候接触的是 Dify,后面才是 coze。Dify 和 coze 的侧重点不同,我个人是更倾向用 Dify 构建工作流就可以了,coze 还是相对全能。 本节用 Dify 也会创建插…

Linux文件IO缓存

一、缓冲区大小对 I/O 系统调用性能的影响 总之,如果与文件发生大量的数据传输,通过采用大块空间缓冲数据,以及执行更少的 系统调用,可以极大地提高 I / O 性能 二、stdio 库的缓冲 当操作磁盘文件时,缓冲大块数据以…

集成电路学习:什么是BOM材料清单

BOM:材料清单 BOM是物料清单(Bill of Material)的缩写,也称为产品结构表或产品结构树。BOM是通过计算机辅助企业生产管理,使计算机能够识别企业所制造的产品构成和所有要涉及的物料。以下是对BOM的详细解释&#xff1a…

智能合约漏洞(一)

前言 智能合约在区块链技术中发挥着重要作用,但其复杂性和安全性问题也常常引发关注。本系列文章将深入探讨几种常见的智能合约漏洞,帮助开发者更好地理解和防范这些安全风险。本文基于 https://dasp.co/ 网站的内容和其他相关资料,分析智能…

IaaS、PaaS、SaaS是什么;算力共享商业模式;吸纳零散算力,提供高价值网络连接,促使算力流通; 以SRv6 SID为抓手,构建算网SaaS生态运营体系

目录 IaaS、PaaS、SaaS是什么 1. IaaS(基础设施即服务) 2. PaaS(平台即服务) 3. SaaS(软件即服务) 算力共享商业模式 云网融合,助力“东数西算”工程 吸纳零散算力,提供高价值网络连接,促使算力流通 以SRv6 SID为抓手,构建算网SaaS生态运营体系 IaaS、PaaS、S…

ArcGIS Pro技术应用

GIS是利用电子计算机及其外部设备,采集、存储、分析和描述整个或部分地球表面与空间信息系统。简单地讲,它是在一定的地域内,将地理空间信息和 一些与该地域地理信息相关的属性信息结合起来,达到对地理和属性信息的综合管理。GIS的…

Hreflang 和 SEO:新手完整指南

每天,数以百万计的法国用户访问像 Amazon.com 这样的全球网站。虽然 Amazon.com 的官方页面是英文的,但用户仍然可以看到法语的文本和产品描述。这是因为亚马逊的全球网站有针对法国的本地化版本,确保所有法国用户都可以自动看到法语的网站内…

五种多目标优化算法(NSGA3、MOPSO、MOGWO、NGSA2、SPEA2)性能对比,包含47个多目标测试函数,6种评价指标,MATLAB代码

一、五种多目标算法及六种评价指标简介 多目标灰狼优化算法(MOGWO): MOGWO是由Mirjalili等人在2016年提出的,基于灰狼优化算法(GWO)的多目标版本。它引入了存档机制和改进的头狼选择方式,以处理…

uniapp(微信小程序如何使用单选框、复选框)

一、先看效果 二、数据结构 说明:selected用来记录每次用户选择的值,当是单选的时候属性中的selected属性需要设置成字符串,当是复选框的时候,此时选择的是数组,selected属性应设置为数组。type用来区分当前是单选还是…

【C++ Qt day3】

2、设计一个Per类,类中包含私有成员:姓名、年龄、指针成员身高、体重,再设计一个Stu类,类中包含私有成员:成绩、Per类对象p1,设计这两个类的构造函数、析构函数和拷贝构造函数。

PTA L1-027 出租

L1-027 出租(20分) 下面是新浪微博上曾经很火的一张图: 一时间网上一片求救声,急问这个怎么破。其实这段代码很简单,index数组就是arr数组的下标,index[0]2 对应 arr[2]1,index[1]0 对应 arr[0…

权威DNS服务器

权威DNS服务器(Authoritative DNS Server)是指对特定域名(如example.com)及其下属子域名(如sub.example.com)的DNS查询提供权威答案的服务器。这意味着,当你想要知道某个特定域名的IP地址时&…

Java的IO模型详解-BIO,NIO,AIO

一、BIO相关知识 Java 的 BIO (Blocking I/O) 模型是基于传统的同步阻塞 I/O 操作。在这种模型中,每个客户端连接都需要一个独立的线程来处理请求。当线程正在执行 I/O 操作时(如读取或写入),它会被阻塞,直到操作完成…

【读点论文】Scene Text Detection and Recognition: The Deep Learning Era

Scene Text Detection and Recognition: The Deep Learning Era Abstract 随着深度学习的兴起和发展,计算机视觉发生了巨大的变革和重塑。场景文本检测与识别作为计算机视觉领域的一个重要研究领域,不可避免地受到了这波革命的影响,从而进入…

Golang | Leetcode Golang题解之第376摆动序列

题目&#xff1a; 题解&#xff1a; int wiggleMaxLength(int* nums, int numsSize) {if (numsSize < 2) {return numsSize;}int prevdiff nums[1] - nums[0];int ret prevdiff ! 0 ? 2 : 1;for (int i 2; i < numsSize; i) {int diff nums[i] - nums[i - 1];if ((…

TD学习笔记————中级教程总结(NEW)

目录 Instance功能讲解 问题&#xff1a; 报错All ops must generate the same number of instances (have the same length Replicator功能讲解 问题&#xff1a; 视频分辨率过大 Cannot find function named:onValueChange Instance功能讲解 数据通道的长度要一致 N…

安泰功率放大器应用领域:MEMS传感器的应用有哪些

功率放大器的应用领域很广泛&#xff0c;从超声测试、材料测试、水声测试再到压电驱动、电磁驱动生物医疗&#xff0c;它都能为整个系统提供强劲的激励&#xff0c;同样功率放大器在MEMS传感器系统的激励中也有着良好应用&#xff0c;今天Aigtek安泰电子就带大家走进MEMS传感器…