Created
April 11, 2014 20:51
-
-
Save pauloricardomg/10500609 to your computer and use it in GitHub Desktop.
Cassandra upgrade sample 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/bash | |
set -e #fail on error | |
function log { | |
echo "[`date`] $@" | |
} | |
log "Upgrading cassandra. Press <ENTER> to continue.." | |
read | |
log "Creating snapshots" | |
nodetool -h localhost -p 7199 snapshot -t upgrade | |
log "Draining node" | |
nodetool -h localhost -p 7199 drain | |
sleep 10 | |
#Disable auxiliary services such as metrics collector, monit, opscenter, etc | |
log "Stopping old cassandra.." | |
/bin/ps -ef | /bin/grep -E "javaagent.*cassandra" | /bin/grep -v grep | /usr/bin/awk '{print $2}' | /usr/bin/xargs kill -9 | |
sleep 2 | |
log "Removing saved caches" | |
rm -rf /mnt/cassandra/saved_caches/ | |
log "Waiting for information to propagate between nodes..." | |
sleep 60 | |
log "Starting new cassandra.." | |
/opt/cassandra-1.2.10/bin/cassandra | |
#Re-enable auxiliary services such as metrics collector, monit, opscenter, etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment