【问题标题】:cassandra stateful set in kubernetesKubernetes 中的 cassandra 有状态集
【发布时间】:2017-11-06 16:48:22
【问题描述】:

我一直在尝试使用 google cassandra 映像在 kubernetes 中设置冗余状态集,如 kubernetes 1.7 documentation 中所述。

根据image used,这是一个有状态的集合,一致性级别为ONE。 在我的测试示例中,我使用了复制因子为 3 的 SimpleStrategy 复制,因为我仅在一个数据中心的有状态集中设置了 3 个副本。 我已经将 cassandra-0,cassandra-1,cassandra-2 定义为种子,所以它们都是种子。

我已经创建了一个键空间和一个表:

"create keyspace if not exists testing with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 }"

"create table testing.test (id uuid primary key, name text, age int, properties map<text,text>, nickames set<text>, goals_year map<int,int>, current_wages float, clubs_season tuple<text,int>);"

我正在测试从另一个不相关的 pod 插入数据,使用 cqlsh 二进制文件,我可以看到数据最终在每个容器中,所以复制是成功的。 所有 pod 上的 nodetool 状态都显示为:

Datacenter: DC1-K8Demo
======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address      Load       Tokens       Owns (effective)  Host ID                               Rack
UN  10.16.0.161  71.04 KiB  32           100.0%            4ad4e1d3-f984-4f0c-a349-2008a40b7f0a  Rack1-K8Demo
UN  10.16.0.162  71.05 KiB  32           100.0%            fffca143-7ee8-4749-925d-7619f5ca0e79  Rack1-K8Demo
UN  10.16.2.24   71.03 KiB  32           100.0%            975a5394-45e4-4234-9a97-89c3b39baf3d  Rack1-K8Demo

...并且所有 cassandra pod 在之前创建的表中都有相同的数据:

 id                                   | age | clubs_season | current_wages | goals_year | name     | nickames | properties
--------------------------------------+-----+--------------+---------------+------------+----------+----------+--------------------------------------------------
 b6d6f230-c0f5-11e7-98e0-e9450c2870ca |  26 |         null |          null |       null | jonathan |     null | {'goodlooking': 'yes', 'thinkshesthebest': 'no'}
 5fd02b70-c0f8-11e7-8e29-3f611e0d5e94 |  26 |         null |          null |       null | jonathan |     null | {'goodlooking': 'yes', 'thinkshesthebest': 'no'}
 5da86970-c0f8-11e7-8e29-3f611e0d5e94 |  26 |         null |          null |       null | jonathan |     null | {'goodlooking': 'yes', 'thinkshesthebest': 'no'}

但是随后我删除了其中一个 db 副本 pod(cassandra-0),一个新的 pod 按预期再次出现,一个新的 cassandra-0(感谢 kubernetes!),我现在看到所有的 pod 都丢失了一个这 3 行:

 id                                   | age | clubs_season | current_wages | goals_year | name     | nickames | properties
--------------------------------------+-----+--------------+---------------+------------+----------+----------+--------------------------------------------------
 5fd02b70-c0f8-11e7-8e29-3f611e0d5e94 |  26 |         null |          null |       null | jonathan |     null | {'goodlooking': 'yes', 'thinkshesthebest': 'no'}
 5da86970-c0f8-11e7-8e29-3f611e0d5e94 |  26 |         null |          null |       null | jonathan |     null | {'goodlooking': 'yes', 'thinkshesthebest': 'no'}

...nodetool 状态现在出现:

 Datacenter: DC1-K8Demo
======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address      Load       Tokens       Owns (effective)  Host ID                               Rack
UN  10.16.0.161  71.04 KiB  32           81.7%             4ad4e1d3-f984-4f0c-a349-2008a40b7f0a  Rack1-K8Demo
UN  10.16.0.162  71.05 KiB  32           78.4%             fffca143-7ee8-4749-925d-7619f5ca0e79  Rack1-K8Demo
DN  10.16.2.24   71.03 KiB  32           70.0%             975a5394-45e4-4234-9a97-89c3b39baf3d  Rack1-K8Demo
UN  10.16.2.28   85.49 KiB  32           69.9%             3fbed771-b539-4a44-99ec-d27c3d590f18  Rack1-K8Demo

... cassandra ring 不应该将所有数据复制到新创建的 pod 中,并且所有 cassandra pod 中仍然有 3 行吗?

...这种体验记录在github

...有没有人尝试过这种体验,在这种测试环境中可能有什么问题?

在此先感谢

【问题讨论】:

    标签: cassandra kubernetes statefulset


    【解决方案1】:

    我认为在关闭节点后,您需要通知集群中的其他对等节点该节点已死亡并需要更换。

    我会推荐一些reading 以获得正确的测试用例。

    【讨论】:

    • 除此之外。在 Kubernetes 中执行此操作的最佳方法可能是在删除节点的位置添加 PreStop 挂钩。更多信息在这里:kubernetes.io/docs/concepts/containers/…
    • 感谢您到目前为止的回答,但我必须澄清一下,我想模拟的情况是特定节点的意外故障。我知道 cassandra 适合这种特定情况。
    • @Horia,谢谢,在那里进行了阅读,nodetool removenode 确实重新建立了令牌分配并将数据复制到替换死节点的新节点上。仍在更清晰的测试场景中工作,但这有很大帮助。
    • ...现在我想知道,有没有像 nodetool removenode 那样自动删除节点的方法?这一步是手动的吗?
    猜你喜欢
    • 2023-04-06
    • 1970-01-01
    • 2019-12-01
    • 2022-01-25
    • 2020-07-09
    • 2017-05-19
    • 2018-02-08
    • 2019-06-24
    • 2021-01-30
    相关资源
    最近更新 更多