You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Techy Teck <co...@gmail.com> on 2013/11/01 07:59:24 UTC

How to generate tokens for my two node Cassandra cluster?

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 (
http://www.datastax.com/2012/01/how-to-setup-and-monitor-a-multi-node-cassandra-cluster-on-windows
)

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

Re: How to generate tokens for my two node Cassandra cluster?

Posted by Aaron Morton <aa...@thelastpickle.com>.
For a while now the binary distribution as included a tool to calculate tokens:

aarons-MBP-2011:apache-cassandra-1.2.11 aaron$ tools/bin/token-generator 
Token Generator Interactive Mode
--------------------------------

 How many datacenters will participate in this Cassandra cluster? 1
 How many nodes are in datacenter #1? 3

DC #1:
  Node #1:                                        0
  Node #2:   56713727820156410577229101238628035242
  Node #3:  113427455640312821154458202477256070484

Cheers



-----------------
Aaron Morton
New Zealand
@aaronmorton

Co-Founder & Principal Consultant
Apache Cassandra Consulting
http://www.thelastpickle.com

On 2/11/2013, at 3:43 am, Ray Sutton <ra...@gmail.com> wrote:

> Your quotes need to be escaped:
> python -c "num=2; print \"\n\".join([(\"token %d: %d\" %(i,(i*(2**127)/num))) for i in range(0,num)])"
> 
> 
> --
> Ray  //o-o\\
> 
> 
> 
> On Fri, Nov 1, 2013 at 10:36 AM, Peter Sanford <ps...@nearbuysystems.com> wrote:
> I can't tell you why that one-liner isn't working, but you can try http://www.cassandraring.com for generating balanced tokens.
> 
> 
> On Thu, Oct 31, 2013 at 11:59 PM, Techy Teck <co...@gmail.com> wrote:
> 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 (http://www.datastax.com/2012/01/how-to-setup-and-monitor-a-multi-node-cassandra-cluster-on-windows)
> 
> 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
>     
> 
> 
> 


Re: How to generate tokens for my two node Cassandra cluster?

Posted by Ray Sutton <ra...@gmail.com>.
Your quotes need to be escaped:
python -c "num=2; print \"\n\".join([(\"token %d: %d\"
%(i,(i*(2**127)/num))) for i in range(0,num)])"


--
Ray  //o-o\\



On Fri, Nov 1, 2013 at 10:36 AM, Peter Sanford
<ps...@nearbuysystems.com>wrote:

> I can't tell you why that one-liner isn't working, but you can try
> http://www.cassandraring.com for generating balanced tokens.
>
>
> On Thu, Oct 31, 2013 at 11:59 PM, Techy Teck <co...@gmail.com>wrote:
>
>> 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 (
>> http://www.datastax.com/2012/01/how-to-setup-and-monitor-a-multi-node-cassandra-cluster-on-windows
>> )
>>
>> 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
>>
>>
>>
>

Re: How to generate tokens for my two node Cassandra cluster?

Posted by Peter Sanford <ps...@nearbuysystems.com>.
I can't tell you why that one-liner isn't working, but you can try
http://www.cassandraring.com for generating balanced tokens.


On Thu, Oct 31, 2013 at 11:59 PM, Techy Teck <co...@gmail.com>wrote:

> 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 (
> http://www.datastax.com/2012/01/how-to-setup-and-monitor-a-multi-node-cassandra-cluster-on-windows
> )
>
> 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
>
>
>