How do you fix node token collision issues when starting up Cassandra nodes in a cluster on VMWare?

前端 未结 2 1383
挽巷
挽巷 2021-01-14 11:40

Are there any known issues with initial_token collision when adding nodes to a cluster in a VM environment?

I\'m working on a 4 node cluster set up on a VM. We\'re r

相关标签:
2条回答
  • 2021-01-14 12:17

    Clearly your nodes are holding onto some past cluster information that is being used at startup. Make sure to delete the LocationInfo directories, which contain the data about the cluster. You have a very strange token layout (where's the 0 token, for example?), so you're certainly going to need to reassign them if you want the proper ownership.

    It may help to explain how token assignment works, so let me also address this. In a brand new cluster, the first node will get assigned token 0 by default and will have 100% ownership. If you do not specify a token for your next node, Cassandra will calculate a token such that the original node owns the lower 50% and the new node the higher 50%.

    When you add node 3, it will insert the token between the first and second, so you'll actually end up with ownership that looks like 25%, 25%, 50%. This is really important, because the lesson to learn here is that Cassandra will NEVER reassign a token by itself to balance the ring. If you want your ownership balanced properly, you must assign your own tokens. This is not hard to do, and there's actually a utility provided to do this.

    So Cassandra's initial bootstrap process, while dynamic, may not yield the desired ring balance. You can't simply allow new nodes to join willy nilly without some intervention to make sure you get the desired result. Otherwise you will end up with the scenario you have laid out in your question.

    0 讨论(0)
  • 2021-01-14 12:20

    This is what I did to fix this problem:

    1. Stop the Cassandra service
    2. Set auto_bootstrap: false on the seed node.
    3. Empty data and commitlog directories: sudo rm -rf /var/lib/cassandra/data/* sudo rm -rf /var/lib/cassandra/commitlog/*
    4. And then restart the service

    I tested this with Cassandra 3.7.

    0 讨论(0)
提交回复
热议问题