Skip to content

Instantly share code, notes, and snippets.

@rodneytamblyn
Last active March 24, 2022 10:13
Show Gist options
  • Save rodneytamblyn/822d9b1b1c8f2f8d7df1c792720d4382 to your computer and use it in GitHub Desktop.
Save rodneytamblyn/822d9b1b1c8f2f8d7df1c792720d4382 to your computer and use it in GitHub Desktop.
docker cassandra graceful shutdown and safe restart
alias shutdown="cass-gracefulStopDatabase-and-reboot"
cass-gracefulStopDatabase-and-reboot() {
logger -s "ob3 - Cassandra database docker container is gracefully stopping....."
docker exec -it MYCASSANDRACONTAINERNAME nodetool flush
docker exec -it MYCASSANDRACONTAINERNAME nodetool stopdaemon
#dont stop docker database or it wont automatically restart on reboot
logger -s "ob3 - C* stopped but container still running. Restart with docker stop database and docker start database"
#don't just use shutdown as we have aliased that and it will loop...
#continue shutdown/restart
/usr/sbin/shutdown $1 $2
}
Read-me
A method to safely stop Cassandra running in a Docker container before proceeding with reboot.
There may be better ways using init.d but we do want to ensure that C* stops before we get on with anything else, and
This method achieves that purpose
After editing your bashrc and aliases file source to load new config:
source ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment