Manually assign token to nodes in the cluster in the Cassandra database

Source: Internet
Author: User
Tags cassandra range

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.