I'd like to know whether a Cassandra node is running or not (I know how to do that part, I can just check whether a java
process is running, that's the only one that uses java
on that server) and when not running, whether the node was properly drained before it was stopped.
So the question is: How can I determine whether nodetool drain
was run against a node which is currently stopped?
It's probably something to do with the commitlogs that should be empty, but I'm not too sure how to check that. I'm looking for a way to do so in the console.
Update:
As per Pandey's answer, here is how my commitlog files look like:
First the location of commitlogs in the /etc/cassandra/cassandra.yaml
file:
commitlog_directory: /var/lib/cassandra/commitlog
And the contents of that folder:
alexis@cass1:~$ ls -l /var/lib/cassandra/commitlog
total 65536
-rw-r--r-- 1 cassandra cassandra 33554432 Feb 22 17:15 CommitLog-6-1550882527529.log
-rw-r--r-- 1 cassandra cassandra 33554432 Feb 22 17:15 CommitLog-6-1550882527530.log
(1024 × 1024 × 32 = 33554432 — so exactly 32Mb)
"nodetool drain" just flushes all memtables from the node to SSTables on disk. Cassandra stops listening for connections from the client and other nodes. Once you fired drain command node will shown DN status from other nodes if you check from "nodetool status" also gossip will not happen. You need to restart Cassandra after running nodetool drain.
For Commitlog, you need to check first commit log path in cassandra.yaml then you can check.