Created
December 1, 2015 16:04
-
-
Save RobinUS2/43618165a1204c5389d5 to your computer and use it in GitHub Desktop.
Cleanup cassandra tables one by one, starting with the smallest
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/bash | |
# This will work in case you have very limited disk space, it will also show more digestable progress compared to nodetool compactionstats | |
DATA_FOLDER="/var/lib/cassandra/data" | |
CMD="cleanup" | |
cd $DATA_FOLDER | |
# list keyspaces from small to large | |
KEYSPACES=`du -s * | sort -n | awk '{print $2}'` | |
# iterate keyspaes | |
for KS in $KEYSPACES; do | |
echo "Starting with $KS" | |
cd $KS | |
# list tables | |
TABLES=`du -s * | sort -n | awk '{print $2}'` | |
# iterate tables | |
for TABLE in $TABLES; do | |
echo " Processing $TABLE" | |
nodetool $CMD $KS $TABLE | |
done | |
# back | |
cd .. | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment