kubernetes 中的 cassandra 有状态集

cassandra stateful set in kubernetes

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

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

我创建了一个键空间和一个 table:

"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>);"

我正在使用 cqlsh 二进制文件从另一个不相关的 pod 插入数据进行测试,我可以看到数据最终进入每个容器,因此复制成功。 所有 pods 的节点工具状态显示:

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 pods 在之前创建的 table 中具有相同的数据:

 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'}

但随后我删除了其中一个数据库副本 pods(cassandra-0),一个新的 pod 按预期再次出现,一个新的 cassandra-0(感谢 kubernetes!),我现在看到了所有 pods 都丢失了其中的一行 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 环不应该将所有数据复制到新创建的 pod 中,并且在所有 cassandra pods 中仍然有 3 行吗?

...此经验记录在 github

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

提前超级感谢

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

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