Last active
March 24, 2022 10:13
-
-
Save rodneytamblyn/822d9b1b1c8f2f8d7df1c792720d4382 to your computer and use it in GitHub Desktop.
docker cassandra graceful shutdown and safe restart
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
alias shutdown="cass-gracefulStopDatabase-and-reboot" |
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
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 | |
} |
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
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