stop cassandra server on mac os x

Found this solution elsewhere which seems to work!

pkill -f 'java.*cassandra'

Worth a try! This works on the Ubuntu I have. Not on MacOS!

On Mac one more is ps -af | grep cassandra and then using kill. But, it does not work sometimes!


If you've installed cassandra via homebrew, use brew info cassandra and it will tell you how to load/unload cassandra using launchctl. This worked better for me than the other answers here.

Commands

brew info cassandra To see status of cassandra

brew services start cassandra To start cassandra

brew services stop cassandra To stop cassandra


Another approach is to see which OS process has the Cassandra port open, like this:

lsof -i :9160

Sample output:

COMMAND   PID  USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
java    30253 aswan  214u  IPv4 0xffffff80190dcc20      0t0  TCP *:netlock1 (LISTEN)

Then you can use "kill -9 [pid]" on that process.


EDIT: I actually find this much more useful.

Open terminal and type:

$ ps -ax | grep cassandra

gives you a list of pids running with the name cassandra.

Use the PID number to kill the process for example here is a returned value: 708 ttys000 0:03.10 /usr/bin/java -ea -javaagent:Downloads/Web/Cassandra/dsc-cassandra-1.1.0/bin/

$ kill 708


Old post:

After posting my comment I found a stop-server script in the BIN.

You have to open up the script and comment out the code if you want to use that script. But here is what it says inside the script.

 echo "please read the stop-server script before use"

    # if you are using the cassandra start script with -p, this
    # is the best way to stop:

     kill `cat <pidfile>` 


    # otherwise, you can run something like this, but
    # this is a shotgun approach and will kill other processes
    # with cassandra in their name or arguments too:

    # user=`whoami`
    # pgrep -u $user -f cassandra | xargs kill -9

Tags:

Cassandra