0

我正在寻找一种将新成员添加到现有 Aeron 集群而不重新配置现有成员的方法。

集群成员似乎是在启动期间静态定义 的,如集群教程中所述:

final ConsensusModule.Context consensusModuleContext = new ConsensusModule.Context()
    .errorHandler(errorHandler("Consensus Module"))
    .clusterMemberId(nodeId)                                                                    
    .clusterMembers(clusterMembers(Arrays.asList(hostnames))) // <------ HERE                   
    .clusterDir(new File(baseDir, "consensus-module"))                                          
    .ingressChannel("aeron:udp?term-length=64k")                                                
    .logChannel(logControlChannel(nodeId, hostname, LOG_CONTROL_PORT_OFFSET))                    
    .replicationChannel(logReplicationChannel(hostname))                                         
    .archiveContext(aeronArchiveContext.clone());

如果我理解正确,如果我想添加更多节点,我需要重新配置每个现有节点以包含新成员。

此外,我在Aeron Cookbook中找到了这个(重点是我的)

Raft 的关键方面:

  • 有一个强领导者,这意味着所有日志条目都从领导者流向追随者
  • Raft 利用随机定时器来选举领导者。这为故障转移增加了几毫秒,但减少了同意选出的领导者的时间(在 Aeron 集群中,这是选举超时 * 2 的最大值)。
  • Raft 协议允许运行时配置更改(即在运行时添加新节点或删除节点)。在撰写本文时,此功能仍在 Aeron Cluster 中待定。

但是,我确实看到了类似的类io.aeron.cluster.DynamicJoin及其用法,io.aeron.cluster.ConsensusModuleAgent这让我认为动态添加节点是可能的,也许食谱已经过时了。

你知道在不触及现有节点的情况下加入更多节点的方法吗?

4

1 回答 1

1

是的,有可能!上下文应该是这样构建的:

ConsensusModule.Context()
    .errorHandler(errorHandler("Consensus Module"))
    .clusterMemberId(Aeron.NULL_VALUE) // <1>
    .clusterMembers("") // <2>
    .memberEndpoints(memberEndpoints(hostnames[nodeId], nodeId)) // <3>
    .clusterConsensusEndpoints(consensusEndpoints(hostnames)) // <4>
    .clusterDir(File(baseDir, "consensus-module"))
    .ingressChannel("aeron:udp?term-length=64k")
    .logChannel("aeron:udp?term-length=64k")
    .replicationChannel(logReplicationChannel(hostname))
    .archiveContext(aeronArchiveContext.clone())
  1. clusterMemberId必须设置为Aeron.NULL_VALUE。会员ID会自动生成
  2. clusterMembers应该是空的。动态节点不需要静态成员
  3. memberEndpoints是该节点的通道配置。格式为ingress:port,consensus:port,log:port,catchup:port,archive:port. 非常类似于单个节点的静态clusterMembers配置,但前面没有成员 ID。
  4. clusterConsensusEndpoints是逗号分隔的列表共识:已知集群成员的端口通道。我认为它类似于要加入的主机的“引导”列表。
于 2021-05-20T19:31:27.023 回答