Created
May 16, 2013 20:30
-
-
Save cdimartino/5594847 to your computer and use it in GitHub Desktop.
This file contains 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 characters
#!/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) | |
HOSTS=$(cat $1 | sed 'N;s/\n/ /') | |
HOST_NUM=$(echo $HOSTS | wc -w) | |
INDEX=0 | |
for host in $HOSTS | |
do | |
token=$(echo "$INDEX*$RING_SIZE/$HOST_NUM" | bc) | |
echo "Moving $host to $token" | |
ssh $host "sudo nodetool -v -h localhost move $token" | |
INDEX=$((INDEX+1)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment