Created
May 16, 2013 20:30
-
-
Save cdimartino/5594857 to your computer and use it in GitHub Desktop.
Quick and dirty rebalancing of Cassandra cluster.
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 | |
# | |
# $ ./rebalance.sh file_of_hosts | |
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