Kafka Connect MongoDB Source Connector 故障场景

Kafka Connect MongoDB Source Connector failure scenario

我需要使用 Kafka Connect 来监控对 MongoDB 集群的更改,该集群具有 1 个主节点和 2 个副本节点。

我看到有官方 MongoDB connector,我想了解连接器的行为,以防主副本失败。它会自动从将成为新主副本的一个辅助副本中读取吗?我在官方文档中找不到这方面的信息。

我看到tasks.max配置相关,我认为这可能与这种情况有关,但答案暗示它始终默认为 1。

我也查看了连接器的 Debezium's implementation,它似乎自动支持这种情况:

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. 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.

此外,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.

问题是 - 我能否使用默认连接器获得与 Debezium 连接器所宣传的相同的默认行为?由于外部原因,我暂时不能使用Debezium one。

在 PSS 部署中:

  • 如果一个节点不可用,其他两个节点可以选举一个primary
  • 如果两个节点都不可用,则不能有主节点

您引用的引文表明连接器可能正在使用主要读取首选项,这意味着只要有两个节点启动它就会工作,如果只有一个节点启动它不会检索任何数据。

因此,将三个节点中的两个节点下线,观察是否可以查询。