Skip to content

Instantly share code, notes, and snippets.

@rodneytamblyn
Last active March 24, 2022 10:13
Show Gist options
  • Select an option

  • Save rodneytamblyn/822d9b1b1c8f2f8d7df1c792720d4382 to your computer and use it in GitHub Desktop.

Select an option

Save rodneytamblyn/822d9b1b1c8f2f8d7df1c792720d4382 to your computer and use it in GitHub Desktop.

Revisions

  1. rodneytamblyn revised this gist Mar 24, 2022. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions docker-cassandra-safe-restart
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    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
  2. rodneytamblyn created this gist Mar 24, 2022.
    1 change: 1 addition & 0 deletions .bash_aliases
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    alias shutdown="cass-gracefulStopDatabase-and-reboot"
    10 changes: 10 additions & 0 deletions .bashrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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
    }