Cassandra数据复制问题
我有一个 2 节点 cassandra 集群,复制因子为 2 并且 AutoBootStrap=true。启动期间一切正常,两个节点都能看到对方。我们将这些节点称为 A 和 B。
- 通过节点 A 将一组键和列(我们将其称为 K1 组)添加到 cassandra。
- 连接到节点 A 并读回组 K1。节点 B 上相同。成功 - 良好
- 杀死节点 B 上的 Cassandra 进程。
- 通过 A 添加集 K2。
- 连接到节点 A 并读取集 K2。良好
- 在节点 B 上重新启动 Cassandra 进程。
- 尝试从 B 读取所有密钥...设置 K1 存在,设置 K2 丢失。 (即使 30 分钟后)
- 将 K3 添加到 A/B 中。
- 从 A 读取所有密钥 - 返回 K1、K2、K3 集合
- 从 B 读取所有密钥 - 返回 K1、K3 集合。
B 从未同步设置 K2...(已经超过 12 小时) 为什么节点 B 看不到集合 K2...有人知道吗?
添加信息:
好的...这就是问题所在。 read_consistency_level 默认设置为 1。
因此,当我们向节点 B 请求集合 K2 时,它没有(由于复制因子 = 2 而应该有),它会立即返回“未找到”错误。
但是,如果我们使用 QUORUM 或 ALL 读取一致性,则 B 被迫询问 A,然后 A 返回正确的值,并且 B 同步该密钥(将其保存在本地)。
这导致了另一个问题 - 这意味着当节点 B 启动时,即使经过很长一段时间,它也不会同步节点 A 的所有数据。现在,如果节点 A 出现故障,我们如何访问未同步的数据? (我刚刚测试了不能)
我想一定有办法强制同步数据。我在终端输出中看到信息,当 B 出现时,发生了从 A 到 B 的 15 行的提示切换,但 B 本地没有这些行(因为我们仍然无法从一致性级别为 ONE 的 B 读取它)。这是怎么回事?
I have a 2 node cassandra cluster with a replication factor of 2 and AutoBootStrap=true. Everything is good during startup and both nodes see each other. Let us call these nodes A and B.
- Add a set of keys and columns (lets call this set K1) to cassandra through node A.
- Connect to node A and read back set K1. Same on Node B. Success - Good
- Kill Cassandra process on Node B.
- Add set K2 through A.
- Connect to node A and read set K2. Good
- Restart Cassandra process on Node B.
- Try to read all keys from B... set K1 present, set K2 MISSING. (Even after 30 minutes)
- Add K3 to A/B.
- Read all keys from A - returns set K1, K2, K3
- Read all keys from B - returns set K1, K3.
B never syncs set K2... (Its been more than 12 hours)
Why does node B not see set K2... anyone has any idea?
Added Info :
Ok... this was the problem.
The read_consistency_level was set to 1 by default.
So when we ask node B for set K2, and it doesnt have it (when it is supposed to because of the replication factor = 2), it immediately returns with a 'Not found' error.
However, if we use read consistency to be QUORUM or ALL, then B is forced to ask A, which then returns the correct value and B syncs up that key (saves it locally).
This leads to another problem - This means that when node B comes up, it is not syncing all the data from Node A, even after a long time. Now if node A goes down, how can we access that unsynced data? (I just tested that we cant)
I guess there must be a way to force syncing the data. I see the INFO in the terminal output that a hinted handoff of 15 rows from A to B occured when B came up, but B does not have those rows locally (because we still cant read it from B with consistency level ONE). Whats going on here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
cassandra 有 3 种方式同步节点关闭时发生的更新:
There are 3 ways cassandra syncs updates that happened while a node was down: