Token is a very important concept in the Cassandra cluster because it affects the range of data that each node governs: We use the program to generate the token and then allocate it to each node:
We use the following code to generate the token:
#! /usr/bin/python
Import sys
if (len (SYS.ARGV) > 1):
num=int (sys.argv[1])
else:
num=int (raw_ Input ("How many nodes are in your cluster?"))
For I in range (0, num):
print ' token%d:%d '% (I, (i* (2**127)/num))
Then we save it to the Tokengentool and let it have enforceable rights (chmod +x Tokengentool):
We run this program, and we produce:
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/database/extra/
3 token are generated here, and we manually assign them to 3 nodes by editing the Cassandra.yaml file for each node:
We set the Initial_token of the 192.168.129.34 node to the value of token 0, and the initial_token of the 192.168.129.35 node is set to the value of token 1, The Initial_token of the 192.168.129.39 node is set to the value of token 2
We'll reboot the 3 nodes.
This article from the "Cohesion of parallel Lines" blog, please be sure to retain this source http://supercharles888.blog.51cto.com/609344/869118