I am trying to setup two node Cassandra Cluster on windows machine. I have basically two windows machine and I was following this datastax tutorial
Whenever I use the below command to get the token number from the above tutorial -
python -c "num=2; print ""\n"".join([(""token %d: %d"" %(i,(i*(2**127)/num))) for i in range(0,num)])"
I always get this error -
C:\Users\username>python -c "num=2; print ""\n"".join([(""token %d: %d"" %(i,(i*(2**127)/num))) for i
in range(0,num)])"
File "<string>", line 1
num=2; print "\n".join([("token %d: %d" %(i,(i*(2**127)/num))) for i in range(0,num)])
^
SyntaxError: invalid syntax
You might have better luck putting that command into an actual Python script. Here is a similar Python script that I use (saved as newCluster.py):
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 'node %d: %d' % (i, (i*(2**127)/num))
When I run that for two nodes, I get:
How many nodes are in your cluster? 2
node 0: 0
node 1: 85070591730234615865843651857942052864
Here is exactly how I edit and run it:
Which version of Python are you using? I have tested this script in 2.6.7 and 2.7.3.
Also to be balanced, your initial_token values for a two node cluster simply need to have a difference of 85,070,591,730,234,615,865,843,651,857,942,052,864. They don't necessarily have to be 0 and 85070591730234615865843651857942052864; although those two values should work just fine.