-
-
Save dev0x10/44aae54ad96cd63b6754 to your computer and use it in GitHub Desktop.
Revisions
-
gjcourt created this gist
Apr 27, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ #!/bin/sh # This will allow you to rebalance the Cassandra ring # Accepts hosts from stdin and automatically rebalances # tokens in your ring. # # $ echo "one two three" | ./rebalance.sh RING_SIZE=$(echo "2^127" | bc) while read host do if [ -z $hosts ] then hosts=$host else hosts="$hosts $host" fi done HOST_NUM=$(echo $hosts | wc -w) INDEX=0 for host in $hosts do token=$(echo "$INDEX*$RING_SIZE/$HOST_NUM" | bc) ssh $host "/usr/bin/nodetool move $token" INDEX=$((INDEX+1)) done