Reputation: 2006
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?
Upvotes: 20
Views: 33351
Reputation: 221
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!
Upvotes: 22
Reputation: 4285
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
Upvotes: 27
Reputation: 21642
I'm using the new Datastax Enterprise 5.0 version, and it, at least, offers a simple enough command for stopping Cassandra:
dse cassandra-stop
It takes a few moments to shut down, but it works for me.
Upvotes: 0
Reputation: 41
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.
Upvotes: 4
Reputation: 13627
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.
Upvotes: 4
Reputation: 1251
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
Upvotes: 23