我一直试图在kubernetes中使用google cassandra图像设置冗余有状态集,如kubernetes 1.7 documentation中所述。cassandra stateful set in kubernetes
根据image used这是一个一致性级别为1的有状态集合。 在我的测试示例中,我使用复制因子为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>);"
我从另一个不相关的荚插入数据,使用cqlsh二进制测试,我可以看到在每个容器的数据结束了,所以复制是成功的。所有荚 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
...和所有卡桑德拉荚有表之前创建的同一个数据:
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'}
但后来我删除这些数据库的副本之一吊舱(卡桑德拉-0),一个新的吊舱再次如预期,新的卡桑德拉0跳起,我现在看到所有豆荚已经失去的那些3一行(感谢kubernetes!):
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'}
...一个
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
...不应卡桑德拉环中的所有数据复制到新创建的吊舱,并且仍然有3列有所有卡桑德拉荚:d nodetool状态现在来了?
...这个经验记录在github。
......有人试过这种体验,在这个测试环境中可能会出现什么错误?
超级提前感谢
除此之外。在Kubernetes中完成此操作的最佳方法可能是在您删除节点的位置添加PreStop钩子。更多信息在这里:https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/ –
谢谢你到目前为止的答案,但我必须澄清,我想模拟的情况是意外的失败一个特定的节点。我的想法是卡桑德拉迎合这种特殊情况。 –
@Horia,谢谢你,在那里阅读,'nodetool removenode'确实重建了令牌分配,并将数据复制到新节点上,替换了死亡节点。仍然在更清晰的测试场景中工作,但这有很大帮助。 –