(二)Kafka 地理复制之配置地理复制

目录

一. 前言

二. 配置地理复制(Configuring Geo-Replication)

2.4. 创建和启用复制流(Creating and Enabling Replication Flows)

2.5. 配置复制流(Configuring Replication Flows)

2.6. 保护复制流(Securing Replication Flows)

2.7. 目标集群中复制 Topic 的自定义命名(Custom Naming of Replicated Topics in Target Clusters)

2.8. 防止配置冲突(Preventing Configuration Conflicts)

2.9. 最佳实践(Best Practice: Consume from Remote, Produce to Local)

2.10. 示例:主动/被动高可用性部署

2.11. 示例:主动/主动高可用性部署

2.12. 示例:多群集地理复制


一. 前言

    接一篇《(一)Kafka 地理复制之配置地理复制》,第二节从 2.4 小节开始。

二. 配置地理复制(Configuring Geo-Replication)

2.4. 创建和启用复制流(Creating and Enabling Replication Flows)

原文引用:To define a replication flow, you must first define the respective source and target Kafka clusters in the MirrorMaker configuration file.

  • clusters (required): comma-separated list of Kafka cluster "aliases"
  • {clusterAlias}.bootstrap.servers (required): connection information for the specific cluster; comma-separated list of "bootstrap" Kafka brokers

Example: Define two cluster aliases primary and secondary, including their connection information.

要定义复制流,必须首先在 MirrorMaker 配置文件中定义相应的源和目标 Kafka 集群。

  • clusters(必需):Kafka 集群“别名”的逗号分隔列表。
  • {clusterAlias}.bootstrap.servers(必需):特定集群的连接信息;逗号分隔的“bootstrap”Kafka Broker 列表。

示例:定义两个别名为 primary 和 secondary 的集群,包括它们的连接信息。

clusters = primary, secondary
primary.bootstrap.servers = broker10-primary:9092,broker-11-primary:9092
secondary.bootstrap.servers = broker5-secondary:9092,broker6-secondary:9092

原文引用:Secondly, you must explicitly enable individual replication flows with {source}->{target}.enabled = true as needed. Remember that flows are directional: if you need two-way (bidirectional) replication, you must enable flows in both directions.

    其次,根据需要您必须显式地启用单个复制流 {source}->{target}.enabled=true。请记住,流是定向的:如果需要相互(双向)复制,则必须启用双向流。

# Enable replication from primary to secondary
primary->secondary.enabled = true

原文引用:By default, a replication flow will replicate all but a few special topics and consumer groups from the source cluster to the target cluster, and automatically detect any newly created topics and groups. The names of replicated topics in the target cluster will be prefixed with the name of the source cluster (see section further below). For example, the topic foo in the source cluster us-west would be replicated to a topic named us-west.foo in the target cluster us-east.

The subsequent sections explain how to customize this basic setup according to your needs.

    默认情况下,复制流会将除少数特殊 Topic 和消费者组外的所有 Topic 和消费者组从源集群复制到目标集群,并自动检测任何新创建的 Topic 和组。目标集群中已复制 Topic 的名称将以源集群的名称为前缀(请参阅下面的一节)。例如,源集群 us-west 中的 Topic foo 将复制到目标集群 us- east 中名为 us-west.foo 的 Topic。

    接下来的部分将解释如何根据您的需要自定义此基本设置。

2.5. 配置复制流(Configuring Replication Flows)

原文引用:The configuration of a replication flow is a combination of top-level default settings (e.g., topics), on top of which flow-specific settings, if any, are applied (e.g., us-west->us-east.topics). To change the top-level defaults, add the respective top-level setting to the MirrorMaker configuration file. To override the defaults for a specific replication flow only, use the syntax format {source}->{target}.{config.name}.

    复制流的配置是顶级默认设置(例如,Topic)的组合,如果有 flow-specific 配置,则在这些设置之上应用(例如,us-west->us-east.topics)。要更改顶级默认值,请将相应的顶级设置添加到MirrorMaker 配置文件中。要仅覆盖特定复制流的默认值,请使用语法格式 {source}->{target}.{config.name}。

原文引用:The most important settings are:

  • topics: list of topics or a regular expression that defines which topics in the source cluster to replicate (default: topics = .*)
  • topics.exclude: list of topics or a regular expression to subsequently exclude topics that were matched by the topics setting (default: topics.exclude = .*[\-\.]internal, .*\.replica, __.*)
  • groups: list of topics or regular expression that defines which consumer groups in the source cluster to replicate (default: groups = .*)
  • groups.exclude: list of topics or a regular expression to subsequently exclude consumer groups that were matched by the groups setting (default: groups.exclude = console-consumer-.*, connect-.*, __.*)
  • {source}->{target}.enable: set to true to enable the replication flow (default: false)


Example: 

最重要的设置是:

  • topics:Topic 列表或正则表达式,用于定义源集群中要复制的 Topic(默认值:topics=.*)
  • topics.exclude:Topic 列表或正则表达式,用于随后排除与 Topic 设置匹配的 Topic(默认值:topics.exclude=.*[\-\.]internal,.*\.recopy,__.*)
  • groups:定义源集群中要复制的消费者组的 Topic 或正则表达式列表(默认值:groups=.*)
  • groups.exclude:Topic 列表或正则表达式,用于随后排除由组设置匹配的消费者组(默认值:groups.excelle=console-consumer-.*,connect-.*,__.*)
  • {source}->{target}.enable:设置为 true 以启用复制流(默认值:false)。

实例

# Custom top-level defaults that apply to all replication flows
topics = .*
groups = consumer-group1, consumer-group2

# Don't forget to enable a flow!
us-west->us-east.enabled = true

# Custom settings for specific replication flows
us-west->us-east.topics = foo.*
us-west->us-east.groups = bar.*
us-west->us-east.emit.heartbeats = false

原文引用:Additional configuration settings are supported which can be left with their default values in most cases. See MirrorMaker Configs.

支持其他配置设置,在大多数情况下可以保留其默认值。请参阅 MirrorMaker 配置。

2.6. 保护复制流(Securing Replication Flows)

原文引用:MirrorMaker supports the same security settings as Kafka Connect, so please refer to the linked section for further information.

Example: Encrypt communication between MirrorMaker and the us-east cluster.

MirrorMaker 支持与 Kafka Connect 相同的安全设置,因此请参阅链接部分了解更多信息。

示例:加密 MirrorMaker 和 us-east 集群之间的通信。

us-east.security.protocol=SSL
us-east.ssl.truststore.location=/path/to/truststore.jks
us-east.ssl.truststore.password=my-secret-password
us-east.ssl.keystore.location=/path/to/keystore.jks
us-east.ssl.keystore.password=my-secret-password
us-east.ssl.key.password=my-secret-password

2.7. 目标集群中复制 Topic 的自定义命名(Custom Naming of Replicated Topics in Target Clusters)

原文引用:Replicated topics in a target cluster—sometimes called remote topics—are renamed according to a replication policy. MirrorMaker uses this policy to ensure that events (aka records, messages) from different clusters are not written to the same topic-partition. By default as per DefaultReplicationPolicy, the names of replicated topics in the target clusters have the format {source}.{source_topic_name}:

    目标群集中复制的 Topic(有时称为远程 Topic)将根据复制策略进行重命名。MirrorMaker 使用此策略来确保来自不同集群的事件(也称为记录、消息)不会写入同一 Topic 分区。默认情况下,根据 DefaultReplicationPolicy,目标集群中已复制 Topic 的名称的格式为 {source}.{source_topic_name}:

us-west         us-east
=========       =================
                bar-topic
foo-topic  -->  us-west.foo-topic

原文引用:You can customize the separator (default: .) with the replication.policy.separator setting:

您可以使用 replication.policy.separator 设置自定义分隔符(默认值:.):

# Defining a custom separator
us-west->us-east.replication.policy.separator = _

原文引用:If you need further control over how replicated topics are named, you can implement a custom ReplicationPolicy and override replication.policy.class (default is DefaultReplicationPolicy) in the MirrorMaker configuration.

    如果需要进一步控制复制 Topic 的命名方式,可以在 MirrorMaker 配置中实现自定义ReplicationPolicy 并覆盖 replication.policy.class(默认为 DefaultReplicationPolicy)。

2.8. 防止配置冲突(Preventing Configuration Conflicts)

原文引用:MirrorMaker processes share configuration via their target Kafka clusters. This behavior may cause conflicts when configurations differ among MirrorMaker processes that operate against the same target cluster.

For example, the following two MirrorMaker processes would be racy:

    MirrorMaker 进程通过其目标 Kafka 集群共享配置。当针对同一目标群集运行的 MirrorMaker 进程之间的配置不同时,此行为可能会导致冲突。

    例如,以下两个 MirrorMaker 进程将是 racy 进程:

# Configuration of process 1
A->B.enabled = true
A->B.topics = foo

# Configuration of process 2
A->B.enabled = true
A->B.topics = bar

原文引用:In this case, the two processes will share configuration via cluster B, which causes a conflict. Depending on which of the two processes is the elected "leader", the result will be that either the topic foo or the topic bar is replicated, but not both.

    在这种情况下,两个进程将通过集群 B 共享配置,这会导致冲突。根据这两个进程中哪一个是当选的“Leader”,结果将是复制 Topic foo 或 Topic 栏,但不是两者都复制。

原文引用:It is therefore important to keep the MirrorMaker configuration consistent across replication flows to the same target cluster. This can be achieved, for example, through automation tooling or by using a single, shared MirrorMaker configuration file for your entire organization. 

    因此,重要的是要在到同一目标群集的复制流之间保持 MirrorMaker 配置的一致性。例如,这可以通过自动化工具或为整个组织使用单个共享的 MirrorMaker 配置文件来实现。

2.9. 最佳实践(Best Practice: Consume from Remote, Produce to Local)

原文引用:To minimize latency ("producer lag"), it is recommended to locate MirrorMaker processes as close as possible to their target clusters, i.e., the clusters that it produces data to. That's because Kafka producers typically struggle more with unreliable or high-latency network connections than Kafka consumers.

    为了最大限度地减少延迟(“生产者滞后”),建议将 MirrorMaker 进程定位在尽可能靠近其目标集群的位置,即它生成数据的集群。这是因为 Kafka 生产者通常比 Kafka 消费者更难处理不可靠或高延迟的网络连接。

First DC          Second DC
==========        =========================
primary --------- MirrorMaker --> secondary
(remote)                           (local)

原文引用:To run such a "consume from remote, produce to local" setup, run the MirrorMaker processes close to and preferably in the same location as the target clusters, and explicitly set these "local" clusters in the --clusters command line parameter (blank-separated list of cluster aliases):

    要运行这样的“从远程消费,从生产到本地”设置,请在目标集群附近运行 MirrorMaker 进程,最好在与目标集群相同的位置运行,并在 --clusters 命令行参数中显式设置这些“local”集群(集群别名的空白分隔列表):

# Run in secondary's data center, reading from the remote `primary` cluster
$ ./bin/connect-mirror-maker.sh connect-mirror-maker.properties --clusters secondary

原文引用:The --clusters secondary tells the MirrorMaker process that the given cluster(s) are nearby, and prevents it from replicating data or sending configuration to clusters at other, remote locations.

    --clusters 辅助“通知” MirrorMaker 进程给定的集群就在附近,并阻止它复制数据或将配置发送到其他远程位置的集群。

2.10. 示例:主动/被动高可用性部署

原文引用:The following example shows the basic settings to replicate topics from a primary to a secondary Kafka environment, but not from the secondary back to the primary. Please be aware that most production setups will need further configuration, such as security settings.

    以下示例显示了将 Topic 从主环境复制到辅助 Kafka 环境的基本设置,而不是从辅助环境复制回主环境。请注意,大多数生产设置都需要进一步配置,例如安全设置。

# Unidirectional flow (one-way) from primary to secondary cluster
primary.bootstrap.servers = broker1-primary:9092
secondary.bootstrap.servers = broker2-secondary:9092

primary->secondary.enabled = true
secondary->primary.enabled = false

primary->secondary.topics = foo.*  # only replicate some topics

2.11. 示例:主动/主动高可用性部署

原文引用:The following example shows the basic settings to replicate topics between two clusters in both ways. Please be aware that most production setups will need further configuration, such as security settings.

    以下示例显示了在两个集群之间以两种方式复制 Topic 的基本设置。请注意,大多数生产设置都需要进一步配置,例如安全设置。

# Bidirectional flow (two-way) between us-west and us-east clusters
clusters = us-west, us-east
us-west.bootstrap.servers = broker1-west:9092,broker2-west:9092
Us-east.bootstrap.servers = broker3-east:9092,broker4-east:9092

us-west->us-east.enabled = true
us-east->us-west.enabled = true

原文引用:Note on preventing replication "loops" (where topics will be originally replicated from A to B, then the replicated topics will be replicated yet again from B to A, and so forth): As long as you define the above flows in the same MirrorMaker configuration file, you do not need to explicitly add topics.exclude settings to prevent replication loops between the two clusters.

    关于防止复制“循环”的注意事项(其中 Topic 最初将从 A 复制到 B,然后复制的 Topic 将再次从B 复制到 A,依此类推):只要在同一 MirrorMaker 配置文件中定义了以上流,就不需要显式添加topic.exclude 设置来防止两个集群之间的复制循环。

2.12. 示例:多群集地理复制

原文引用:Let's put all the information from the previous sections together in a larger example. Imagine there are three data centers (west, east, north), with two Kafka clusters in each data center (e.g., west-1, west-2). The example in this section shows how to configure MirrorMaker (1) for Active/Active replication within each data center, as well as (2) for Cross Data Center Replication (XDCR).

First, define the source and target clusters along with their replication flows in the configuration:

    让我们把前面部分的所有信息放在一个更大的例子中。假设有三个数据中心(west, east, north),每个数据中心有两个 Kafka 集群(例如,west-1、west-2)。本节中的示例显示如何配置 MirrorMaker(1)用于每个数据中心内的活动/活动复制,以及(2)用于跨数据中心复制(XDCR)。

    首先,在配置中定义源集群和目标集群及其复制流:

# Basic settings
clusters: west-1, west-2, east-1, east-2, north-1, north-2
west-1.bootstrap.servers = ...
west-2.bootstrap.servers = ...
east-1.bootstrap.servers = ...
east-2.bootstrap.servers = ...
north-1.bootstrap.servers = ...
north-2.bootstrap.servers = ...

# Replication flows for Active/Active in West DC
west-1->west-2.enabled = true
west-2->west-1.enabled = true

# Replication flows for Active/Active in East DC
east-1->east-2.enabled = true
east-2->east-1.enabled = true

# Replication flows for Active/Active in North DC
north-1->north-2.enabled = true
north-2->north-1.enabled = true

# Replication flows for XDCR via west-1, east-1, north-1
west-1->east-1.enabled  = true
west-1->north-1.enabled = true
east-1->west-1.enabled  = true
east-1->north-1.enabled = true
north-1->west-1.enabled = true
north-1->east-1.enabled = true

原文引用:Then, in each data center, launch one or more MirrorMaker as follows:

然后,在每个数据中心中,启动一个或多个 MirrorMaker,如下所示:

# In West DC:
$ ./bin/connect-mirror-maker.sh connect-mirror-maker.properties --clusters west-1 west-2

# In East DC:
$ ./bin/connect-mirror-maker.sh connect-mirror-maker.properties --clusters east-1 east-2

# In North DC:
$ ./bin/connect-mirror-maker.sh connect-mirror-maker.properties --clusters north-1 north-2

原文引用:With this configuration, records produced to any cluster will be replicated within the data center, as well as across to other data centers. By providing the --clusters parameter, we ensure that each MirrorMaker process produces data to nearby clusters only.

    使用此配置,生成到任何集群的记录都将在数据中心内复制,也可以跨数据中心复制到其他数据中心。通过提供 --clusters 参数,我们确保每个 MirrorMaker 进程只向附近的集群生成数据。

原文引用:Note: The --clusters parameter is, technically, not required here. MirrorMaker will work fine without it. However, throughput may suffer from "producer lag" between data centers, and you may incur unnecessary data transfer costs.

    注意:从技术上讲,这里不需要 --clusters 参数。MirrorMaker 在没有它的情况下可以正常工作。但是,吞吐量可能会受到数据中心之间“生产者滞后”的影响,并且您可能会产生不必要的数据传输成本。

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

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

相关文章

模板匹配——基于模板与基于特征的两种模板匹配对比

概述 在人工智能(AI)的研究领域中,模板匹配不仅是一个重要的研究课题,也是解决图像处理中核心问题——定位兴趣区域的关键方法之一。通过模板匹配,可以准确地识别和定位给定图像中的特定对象。这项技术在对象检测、跟…

【Week-Y4】修改yolov5s中C3模块的结构,common.py文件解读

修改C3模块的结构 一、commom.py文件解析二、修改代码,运行train.py训练 🍨 本文为🔗365天深度学习训练营 中的学习记录博客🍖 原作者:K同学啊 | 接辅导、项目定制 📕本次任务:将yolov5s网络模型…

Dynamo之雪花分形(衍生式设计)

你好,这里是BIM的乐趣,我是九哥~ 今天简单分享一些我收集的Dynamo的雪花分形案例吧,不过多讲解了,有兴趣的小伙伴,可以私信“雪花分形”获取案例文件,下面基本以分享为主: ******多图预警****…

第四百四十二回

文章目录 1. 概念介绍2. 使用方法2.1 获取思路2.2 获取方法 3. 示例代码4. 内容总结 我们在上一章回中介绍了"如何获取屏幕相关参数"相关的内容,本章回中将介绍如何获取AppBar的高度.闲话休提,让我们一起Talk Flutter吧。 1. 概念介绍 我们在…

文章解读与仿真程序复现思路——电网技术EI\CSCD\北大核心《含储能接入的三相配电网分布式可再生能源可调度域建模与计算》

本专栏栏目提供文章与程序复现思路,具体已有的论文与论文源程序可翻阅本博主免费的专栏栏目《论文与完整程序》 论文与完整源程序_电网论文源程序的博客-CSDN博客https://blog.csdn.net/liang674027206/category_12531414.html 电网论文源程序-CSDN博客电网论文源…

糟糕,Oracle归档满RMAN进不去,CPU98%了!

📢📢📢📣📣📣 哈喽!大家好,我是【IT邦德】,江湖人称jeames007,10余年DBA及大数据工作经验 一位上进心十足的【大数据领域博主】!😜&am…

程序员延寿指南:科学延寿 20 年 | 开源日报 No.214

geekan/HowToLiveLonger Stars: 28.7k License: Unlicense HowToLiveLonger 是一个程序员延寿指南项目。 该项目旨在提供关于如何延长寿命的指南,特别是针对程序员群体。该项目包括术语、目标、关键结果、分析、行动和证据等内容,涵盖了各种与健康相关的…

C语言要点细细梳理——番外:运算符优先级

C语言中的运算符优先级决定了在没有括号的情况下,表达式中的各个部分应如何求值。这个优先级是固定的,并且遵循一定的规则。当运算符的优先级相同时,运算的方向(从左到右或从右到左)则称为运算符的结合性。 下面是一个…

JAVA基础03-scanner,输出,循环,if的使用以及eclipse的安装

目录 scanner的使用 if语句的使用 eclipse的使用 switch语句的使用 输出方法的使用 循环语句 scanner的使用 实现用户数据的交互,用户通过终端输入数据 注意:使用Scanner需要导包 在程序开头加上:import java.util.Scanner; //由于S…

2024免费Mac苹果解压压缩包软件BetterZip5

在2024年,对于Mac电脑用户来说,如果你想要无需解压就能快速查看压缩文档的内容,BetterZip是一个极佳的选择。这款软件不仅支持多种格式的压缩和解压,如zip、rar、7z、tar等,还具备丰富的功能和设置,包括预览…

异地组网怎么管理?

在当今信息化时代,随着企业的业务扩张和员工的分布,异地组网已经成为越来越多企业的需求。异地组网管理相对来说是一项复杂而繁琐的任务。本文将介绍一种名为【天联】的管理解决方案,帮助企业更好地管理异地组网。 【天联】组网的优势 【天联…

《pytorch深度学习实战》学习笔记第2章

第2章 预训练网络 讨论3种常用的预训练模型: 1、根据内容对图像进行标记(识别) 2、从真实图像中生成新图像(GAN) 3、使用正确的英语句子来描述图像内容(自然语言) 2.1 获取一个预训练好的网络…

c++宏有什么离谱操作?

Boost.Preprocessor确实是一个非常强大而复杂的C宏库,专门用于元编程,即在编译时进行代码生成和变换。我这里有一套编程入门教程,不仅包含了详细的视频讲解,项目实战。如果你渴望学习编程不妨点个关注,给个评论222&…

WordPress建站教程:10步快速搭建个人网站

WordPress是一个广泛使用的内容管理系统(CMS),凭借其用户友好的界面和大量可定制的主题和插件,为WordPress 提供了多功能性和灵活性,可用于创建各种类型的网站,包括个人博客、B2B企业网站、B2C外贸网站等&a…

骨架屏:提升用户体验的巧妙技巧

🤍 前端开发工程师、技术日更博主、已过CET6 🍨 阿珊和她的猫_CSDN博客专家、23年度博客之星前端领域TOP1 🕠 牛客高级专题作者、打造专栏《前端面试必备》 、《2024面试高频手撕题》 🍚 蓝桥云课签约作者、上架课程《Vue.js 和 E…

CleanMyMac2024拥有优化Mac电脑所需的所有工具,深层清理、恶意软件移除、用CleanMyMac X就够了!

CleanMyMac X 拥有优化 Mac 电脑所需的所有工具:深层清理、恶意软件移除、性能提升…… 优化 Mac 电脑,用 CleanMyMac X 就够了! CleanMyMac作为一款专为Mac用户设计的系统清理和优化软件,通过其独特的功能和特性,帮助…

Linux集群(二)集群搭建与keeplived配置

目录 一、集群搭建 1.复制3份Tomcat 2.测试Tomcat 3. 配置nginx.conf配置文件 二、keeplived 1.什么是keeplived 2.keeplived特点 3.下载和安装 3.1下载 3.2安装 3.3配置keeplived.conf配置文件 3.4测试 一、集群搭建 集群的主要目的是解决并发的问题。 1.复制3…

【QT+QGIS跨平台编译】056:【pdal_lazperf+Qt跨平台编译】(一套代码、一套框架,跨平台编译)

点击查看专栏目录 文章目录 一、pdal_lazperf介绍二、pdal下载三、文件分析四、pro文件五、编译实践一、pdal_lazperf介绍 pdal_lazperf 是 PDAL(Point Data Abstraction Library)的一个插件,用于处理点云数据。PDAL 是一个开源的库,用于处理和分析地理空间数据,特别是点云…

详解TCP/IP五层模型

目录 一、什么是TCP五层模型? 二、TCP五层模型的详细内容 1. 应用层 2. 传输层 3. 网络层 4. 数据链路层 5. 物理层 三、网络设备所在分层 封装和分⽤ 三、Java示例 引言: 在网络通信中,TCP/IP协议是至关重要的。为了更好地理解TCP协议的工…

SD-WAN组网,协助企业业务需求灵活调整带宽和网络资源

随着企业网络需求的不断增长和变化,传统的网络架构已经不能满足企业灵活调整带宽和网络资源的需求。而SD-WAN(软件定义广域网)作为一种新型的网络架构,可以帮助企业实现灵活调整带宽和网络资源,满足不同业务需求。本文…
最新文章