首页 > 解决方案 > Cassandra:节点添加/删除是否需要所有集群节点都存在?

问题描述

当一个新节点增加时,由于新令牌分布均匀,环的当前节点应该将数据迁移到这个新节点。

那么,它是否需要所有节点都存在?如果没有,那么如果某些节点宕机了,那么就会错过那些部分的数据迁移,如何以及何时修复?这些节点什么时候回来?

同理,移除节点会将其数据迁移到其他节点,所以看起来其他所有节点都必须存在,否则会丢失数据?

标签: cassandra

解决方案


Cassandra 要求所有节点都存在。当另一个节点关闭并收到此错误时,我尝试添加一个节点:

Exception (java.lang.RuntimeException) encountered during startup: A node required to move the data consistently is down (/172.17.0.2). If you wish to move the data from a potentially inconsistent replica, restart the node with -Dcassandra.consistent.rangemovement=false
java.lang.RuntimeException: A node required to move the data consistently is down (/172.17.0.2). If you wish to move the data from a potentially inconsistent replica, restart the node with -Dcassandra.consistent.rangemovement=false
    at org.apache.cassandra.dht.RangeStreamer.getAllRangesWithStrictSourcesFor(RangeStreamer.java:275)
    at org.apache.cassandra.dht.RangeStreamer.addRanges(RangeStreamer.java:158)
    at org.apache.cassandra.dht.BootStrapper.bootstrap(BootStrapper.java:83)
    at org.apache.cassandra.service.StorageService.bootstrap(StorageService.java:1212)
    at org.apache.cassandra.service.StorageService.joinTokenRing(StorageService.java:891)
    at org.apache.cassandra.service.StorageService.initServer(StorageService.java:657)
    at org.apache.cassandra.service.StorageService.initServer(StorageService.java:570)
    at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:346)
    at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:569)
    at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:697)
ERROR 09:53:37 Exception encountered during startup

当我尝试在不同的 dc 中添加节点时也会发生同样的情况。

至于删除一个节点。仅当所有副本都已启动时,停用才有效。停用将从将所有数据流式传输到新副本开始,如果流式传输失败,则停用失败。

$ nodetool decommission
error: Stream failed
-- StackTrace --
org.apache.cassandra.streaming.StreamException: Stream failed
    ...

您仍然可以通过关闭节点并执行nodetool removenode. 这不会流式传输数据,但会从集群中删除节点。谨慎使用。

nodetool assasinate如果 decomission 或 removenode 都不起作用,也会出现这种情况。


推荐阅读