-
-
Save arnobroekhof/3ce994fec5684e928cad94770536f5c4 to your computer and use it in GitHub Desktop.
Cassandra node rebalancing script
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 characters
#!/bin/sh | |
#this looks up the nodes from the ring and rebalances them automatically | |
hosts = `/usr/bin/nodetool ring |grep Normal |awk '{print $1}' |xargs echo` | |
RING_SIZE=$(echo "2^127" | bc) | |
HOST_NUM=$(echo $hosts | wc -w) | |
INDEX=0 | |
for host in $hosts | |
do | |
token=$(echo "$INDEX*$RING_SIZE/$HOST_NUM" | bc) | |
if [[ $token -ne 0 ]]; then | |
/usr/bin/nodetool -h $host move $token | |
fi | |
INDEX=$((INDEX+1)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment