Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stop cassandra server on mac os x

Tags:

cassandra

How do I stop cassandra server running on a single node in my mac os x? Cassandra script doesn't have -stop option. Only way other than restart the mac os x, was to do a "ps" and find the java process which had arguments for cassandra and use kill -9 to kill the process.

But trying to restart cassandra after that still throws

Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 7199; nested exception is: java.net.BindException: Address already in use.

Anybody seen it? Any quick solutions?

like image 270
bschandramohan Avatar asked Jun 04 '12 06:06

bschandramohan


People also ask

Where is Cassandra installed on Mac?

Following command is used to install Cassandra on MacOS. This installs Cassandra on location /usr/local/cellar/Cassandra . Following command is used to start Cassandra.

How do I know if Cassandra is installed on my Mac?

You can know the version from running cassandra by connecting it via CQLSH. The prompt displays the version of cassandra it connected to. Show activity on this post. Once you know the location of your Cassandra instance(s) you can simply execute the cassandra binary with the -v option.


5 Answers

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

like image 155
slycrel Avatar answered Oct 18 '22 16:10

slycrel


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
like image 37
Michael Avatar answered Oct 18 '22 16:10

Michael


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!

like image 33
Pradeep Kaushik Avatar answered Oct 18 '22 16:10

Pradeep Kaushik


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.

like image 24
Andrew Swan Avatar answered Oct 18 '22 15:10

Andrew Swan


You can use Cassandra's nodetool command, as well.

nodetool drain

The documentation doesn't say anything about it shutting down, but it works reliably for me with a single node, local server. It generally takes a few seconds to finish the shutdown, however.

like image 31
jabr Avatar answered Oct 18 '22 16:10

jabr