Database Reference
In-Depth Information
For, Murmur3Partitioner (default type of partitioner, since Cassandra Ver-
sion 1.2), you can use this Python script:
python -c 'print [str(((2**64 / nodes_count) * i) -
2**63) for i in range(nodes_count)]'
For example, if you have six nodes, run the following command:
python -c 'print [str(((2**64 / 6) * i) - 2**63) for
i in range(6)]'
['-9223372036854775808', '-6148914691236517206',
'-3074457345618258604', '-2', '3074457345618258600',
'6148914691236517202']
If you have nodes distributed across two data centers, you may want to assign al-
ternate tokens to each data center:
DC #1:
-9223372036854775808 -3074457345618258604
3074457345618258600
DC #2:
-6148914691236517206 -2 6148914691236517202
2. Now that we have tokens, we need to call the following command:
bin/nodetool -h <node_to_move> move <token_number>
The trick here is to assign a new token to a node that is closest to it. This will allow faster
balancing as there will be less data to move. A live example of how load balancing is
done is covered in the Adding nodes to a cluster section, where we add a node to the
cluster, which makes the cluster lopsided. We finally balance it by moving tokens around.
It is actually very easy to write a shell or Python script that takes the ring and then bal-
ances it automatically. For someone using RandomPartitioner , there is a GitHub
project, Cassandra-Balancer ( https://github.com/tivv/cassandra-balancer ), which calcu-
lates the tokens for a node and moves the data. So, instead of writing one of your own you
can just use this Groovy script. Execute it on each node, one by one, and you are done.
Search WWH ::




Custom Search