简体   繁体   English

Kafka Connect MongoDB Source Connector 故障场景

[英]Kafka Connect MongoDB Source Connector failure scenario

I need to use Kafka Connect to monitor changes to a MongoDB cluster with one primary and 2 replicas.我需要使用 Kafka Connect 监控对具有一个主副本和 2 个副本的 MongoDB 集群的更改。

I see there is the official MongoDB connector , and I want to understand what would be the connector's behaviour, in case the primary replica would fail.我看到有官方的MongoDB 连接器,我想了解连接器的行为,以防主副本失败。 Will it automatically read from one of the secondary replicas which will become the new primary?它会自动从一个将成为新主副本的辅助副本中读取吗? I couldn't find information for this in the official docs.我在官方文档中找不到这方面的信息。

I've seen this post related to the tasks.max configuration, which I thought might be related to this scenario, but the answer implies that it always defaults to 1.我看过这篇tasks.max配置相关的帖子,我认为这可能与这种情况有关,但答案暗示它始终默认为 1。

I've also looked at Debezium's implementation of the connector, which seems to support this scenario automatically:我还查看了Debezium 的连接器实现,它似乎自动支持这种情况:

The MongoDB connector is also quite tolerant of changes in membership and leadership of the replica sets, of additions or removals of shards within a sharded cluster, and network problems that might cause communication failures. MongoDB 连接器还可以很好地容忍副本集的成员资格和领导层的变化、分片集群中分片的添加或删除以及可能导致通信失败的网络问题。 The connector always uses the replica set's primary node to stream changes, so when the replica set undergoes an election and a different node becomes primary, the connector will immediately stop streaming changes, connect to the new primary, and start streaming changes using the new primary node.连接器始终使用副本集的主节点来 stream 更改,因此当副本集进行选举并且不同的节点成为主节点时,连接器将立即停止流式传输更改,连接到新的主节点,并使用新的主节点开始流式传输更改节点。

Also, Debezium's version of the tasks.max configuration property states that:此外,Debezium 的tasks.max配置属性版本指出:

The maximum number of tasks that should be created for this connector.应为此连接器创建的最大任务数。 The MongoDB connector will attempt to use a separate task for each replica set, [...] so that the work for each replica set can be distributed by Kafka Connect. MongoDB 连接器将尝试为每个副本集使用单独的任务,[...] 以便每个副本集的工作可以由 Kafka Connect 分发。

The question is - can I get the same default behaviour with the default connector - as advertised for the Debezium one?问题是 - 我可以使用默认连接器获得相同的默认行为 - 正如为 Debezium 所宣传的那样? Because of external reasons, I can't use the Debezium one for now.由于外部原因,我暂时无法使用 Debezium。

In a PSS deployment:在 PSS 部署中:

  • If one node is not available, the other two nodes can elect a primary如果一个节点不可用,其他两个节点可以选举一个主节点
  • If two nodes are not available, there can be no primary如果两个节点不可用,则不能有主节点

The quote you referenced suggests the connector may be using primary read preference, which means as long as two nodes are up it will be working and if only one node is up it will not retrieve any data.您引用的报价表明连接器可能正在使用主要读取首选项,这意味着只要两个节点启动,它就会工作,如果只有一个节点启动,它将不会检索任何数据。

Therefore, bring down two of the three nodes and observe whether you are able to query.因此,将三个节点中的两个拉下来,观察是否能够查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM