【问题标题】:How Cassandra Cluster - Seed Provider Works?Cassandra 集群 - 种子提供者如何工作?
【发布时间】:2020-08-05 13:46:04
【问题描述】:

我对 cassandra seed_provider 分配有疑问。在我的环境中,设置为集群需要 3 个 cassandra 节点。我应该如何在 cassandra.yaml 中定义它?我很困惑,因为大多数教程给出了不同的答案。

示例: 主机 A - 192.168.1.1 主机 B - 192.168.1.2 主机 C - 192.168.1.3

以下是我当前对主机 A 的设置,是否正确?

Host B 和 Host C 的配置如何?

# any class that implements the SeedProvider interface and has a
# constructor that takes a Map<String, String> of parameters will do.
seed_provider:
    # Addresses of hosts that are deemed contact points. 
    # Cassandra nodes use this list of hosts to find each other and learn
    # the topology of the ring.  You must change this if you are running
    # multiple nodes!
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider
      parameters:
          # seeds is actually a comma-delimited list of addresses.
          # Ex: "<ip1>,<ip2>,<ip3>"
          - seeds: "192.168.1.1,192.168.1.2,192.168.1.3"

【问题讨论】:

    标签: database cassandra rhel cassandra-2.0


    【解决方案1】:

    对于初学者,您不需要更改 class_name 的 seed_provider。 AFAIK,只有一个随 Cassandra 一起提供。它被定义为“可插入的”,以允许编写自定义种子提供程序。

    对于seeds,我不建议指定种子列表中的每个节点。如果只有 3 个节点,则只提供 1 个或 2 个。种子节点不引导数据,需要repair 才能在替换时保持一致。这会使添加节点变得困难。

    但据我所知,您当前的配置将起作用。我只会构建最多包含 2 个节点的种子列表。

    请记住,seed_list 有两个主要要求:

    • 如果您要启动集群中的第一个节点,其 IP 必须在 seed_list 中。
    • 至少有一个节点必须在运行。

    您介意进一步解释如果我继续在种子列表中添加所有 3 个节点会产生什么影响吗?你会选择在种子列表中添加 1 或 2 个节点的原因是什么?

    当然,这一切都可以追溯到这个:

    种子节点不引导数据

    因此,在所有 3 个节点上指定 seed_list 中的所有 3 个节点会导致以下问题:

    • 如果节点 A 已启动并且在节点 B 或 C 加入集群之前写入数据,则该数据将不会流向节点 B 或 C .
    • 如果将来节点 A 发生故障并被替换,数据将不会流式传输到替换节点。

    在这些情况下,需要运行nodetool repair 以将初始数据传送到新添加的节点。

    【讨论】:

    • 表示最佳做法是将主机B和主机C设置为种子?所以我只需要在所有 3 个 A、B 和 C 节点上应用 - 种子的配置:“192.168.1.2,192.168.1.3”?
    • @BlackHat 应该没问题,只要 B 或 C 是​​第一个启动的节点。
    • 您介意进一步解释如果我继续在种子列表中添加所有 3 个节点会产生什么影响吗?你会选择在种子列表中添加 1 或 2 个节点的原因是什么?
    猜你喜欢
    • 1970-01-01
    • 2022-01-02
    • 2021-01-11
    • 2016-10-31
    • 1970-01-01
    • 2021-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多