nodetool stopdaemon
Stops the Cassandra daemon process.
Synopsis
Section titled “Synopsis”nodetool [connection_options] stopdaemonSee connection options for connection options.
Description
Section titled “Description”nodetool stopdaemon sends a shutdown signal to the Cassandra process, terminating the daemon. This is a hard stop that does not perform graceful draining—use drain first for a clean shutdown.
Not Graceful
stopdaemon does not flush memtables or complete pending operations. For graceful shutdown, always run drain before stopdaemon.
Behavior
Section titled “Behavior”When stopdaemon is executed:
- JMX shutdown signal is sent to Cassandra
- Cassandra process begins termination
- In-flight requests may be interrupted
- Unflushed memtable data remains in commit log
- Process exits
What does NOT happen:
- Memtables are not flushed to SSTables
- Pending operations are not completed
- Gossip shutdown notification is not sent
- Other nodes are not informed gracefully
Examples
Section titled “Examples”Basic Usage
Section titled “Basic Usage”nodetool stopdaemonGraceful Shutdown (Recommended)
Section titled “Graceful Shutdown (Recommended)”# First drain (graceful)nodetool drain
# Then stopnodetool stopdaemonEmergency Stop
Section titled “Emergency Stop”When immediate shutdown is required:
nodetool stopdaemonWhen to Use
Section titled “When to Use”After Drain
Section titled “After Drain”The recommended shutdown sequence:
# 1. Drain first (flushes data, stops accepting requests)nodetool drain
# 2. Stop the daemonnodetool stopdaemonEmergency Situations
Section titled “Emergency Situations”When immediate shutdown is critical:
# Stop immediately (not graceful)nodetool stopdaemonUse emergency stop when:
- Node is causing cluster-wide issues
- Runaway process consuming resources
- Security incident requiring immediate isolation
drainis hanging or not responding
After drain Completes
Section titled “After drain Completes”Once drain finishes, stopdaemon simply terminates the process:
# Drain completesnodetool drain# INFO: DRAINED
# Safe to stop nownodetool stopdaemonComparison: drain vs stopdaemon
Section titled “Comparison: drain vs stopdaemon”| Action | drain | stopdaemon |
|---|---|---|
| Flush memtables | Yes | No |
| Complete pending requests | Yes | No |
| Stop gossip | Yes | Immediate |
| Stop native transport | Yes | Immediate |
| Notify other nodes | Yes | No |
| Process exits | No | Yes |
| Data safety | Safe | Requires commit log replay |
Graceful Shutdown Sequence
Section titled “Graceful Shutdown Sequence”| Step | Command | What Happens |
|---|---|---|
| 1 | drain | Flush memtables, stop accepting requests, stop gossip |
| 2 | stopdaemon | Exit process (data is safe) |
Emergency Shutdown Sequence
Section titled “Emergency Shutdown Sequence”| Step | Command | What Happens |
|---|---|---|
| 1 | stopdaemon | Immediate exit (commit log replay needed on restart) |
Post-Stop Verification
Section titled “Post-Stop Verification”Verify Process Stopped
Section titled “Verify Process Stopped”# Check for Cassandra processpgrep -f CassandraDaemon# Should return nothing (no output)
# Alternativeps aux | grep CassandraDaemon | grep -v grep# Should return nothingVerify Ports Released
Section titled “Verify Ports Released”# CQL portnetstat -tlnp | grep 9042# Should return nothing
# JMX portnetstat -tlnp | grep 7199# Should return nothing
# Inter-node portnetstat -tlnp | grep 7000# Should return nothingAll-in-One Verification
Section titled “All-in-One Verification”#!/bin/bashecho "=== Cassandra Stop Verification ==="echo ""
# Process checkpid=$(pgrep -f CassandraDaemon)if [ -z "$pid" ]; then echo "Process: STOPPED"else echo "Process: STILL RUNNING (PID: $pid)"fi
# Port checksfor port in 9042 7199 7000 7001; do if netstat -tlnp 2>/dev/null | grep -q ":$port "; then echo "Port $port: IN USE" else echo "Port $port: FREE" fidoneAlternatives to stopdaemon
Section titled “Alternatives to stopdaemon”systemd (Recommended for Production)
Section titled “systemd (Recommended for Production)”# Stop via systemd (usually runs drain internally)systemctl stop cassandraMost distribution packages configure systemd to call drain before stopping.
init.d
Section titled “init.d”service cassandra stopkill Command (Last Resort)
Section titled “kill Command (Last Resort)”# Find PIDpid=$(pgrep -f CassandraDaemon)
# Normal kill (SIGTERM)kill $pid
# Force kill if unresponsive (SIGKILL)kill -9 $pidForce Kill
kill -9 should only be used when the process is completely unresponsive. It prevents any cleanup and may require longer commit log replay.
Comparison of Stop Methods
Section titled “Comparison of Stop Methods”| Method | Graceful | Runs Drain | Recommended |
|---|---|---|---|
nodetool drain && stopdaemon | Yes | Yes | Yes |
systemctl stop cassandra | Usually | Depends on unit file | Yes |
nodetool stopdaemon alone | No | No | Emergency only |
kill <pid> | Partial | No | Last resort |
kill -9 <pid> | No | No | Extreme emergency |
Workflow: Planned Maintenance Stop
Section titled “Workflow: Planned Maintenance Stop”#!/bin/bashecho "=== Graceful Cassandra Shutdown ==="echo ""
# 1. Check current stateecho "1. Pre-stop status:"echo " Binary: $(nodetool statusbinary)"echo " Gossip: $(nodetool statusgossip)"
# 2. Drainecho ""echo "2. Draining node..."nodetool drainecho " Drain complete"
# 3. Stop daemonecho ""echo "3. Stopping daemon..."nodetool stopdaemon
# 4. Wait for process exitecho ""echo "4. Waiting for process to exit..."for i in {1..30}; do if ! pgrep -f CassandraDaemon > /dev/null; then echo " Process stopped" break fi sleep 1done
# 5. Verifyecho ""echo "5. Verification:"if pgrep -f CassandraDaemon > /dev/null; then echo " WARNING: Process still running!"else echo " Cassandra stopped successfully"fiWorkflow: Emergency Stop
Section titled “Workflow: Emergency Stop”#!/bin/bashecho "=== EMERGENCY STOP ==="echo "WARNING: This is not a graceful shutdown!"echo ""
# Immediate stopnodetool stopdaemon
# Wait brieflysleep 5
# Check if stoppedif pgrep -f CassandraDaemon > /dev/null; then echo "Process still running, forcing kill..." pkill -9 -f CassandraDaemon sleep 2fi
# Final checkif pgrep -f CassandraDaemon > /dev/null; then echo "ERROR: Cannot stop Cassandra!" exit 1else echo "Cassandra stopped" echo "NOTE: Commit log replay will occur on restart"fiAfter Stop: Restart Considerations
Section titled “After Stop: Restart Considerations”If Stopped Without Drain
Section titled “If Stopped Without Drain”When Cassandra restarts after stopdaemon without drain:
- Commit log is replayed
- Unflushed memtable data is recovered
- Startup may take longer
- Data integrity is maintained (commit log is durable)
# Start after emergency stopsystemctl start cassandra
# Monitor startup (may be slower due to replay)tail -f /var/log/cassandra/system.log | grep -i "replay\|starting\|listening"If Stopped After Drain
Section titled “If Stopped After Drain”Clean restart:
# Normal startsystemctl start cassandra
# Quick startup expectedtail -f /var/log/cassandra/system.log | grep -i "starting\|listening"Troubleshooting
Section titled “Troubleshooting”stopdaemon Doesn't Work
Section titled “stopdaemon Doesn't Work”If JMX command fails:
# Check JMX connectivitynodetool info# If this fails, JMX is unreachable
# Use kill insteadpid=$(pgrep -f CassandraDaemon)kill $pidProcess Hangs After stopdaemon
Section titled “Process Hangs After stopdaemon”If process doesn't exit:
# Check process stateps aux | grep CassandraDaemon
# Check what it's doingstrace -p $(pgrep -f CassandraDaemon) 2>&1 | head -20
# Force kill if necessarykill -9 $(pgrep -f CassandraDaemon)Cannot Connect to JMX
Section titled “Cannot Connect to JMX”# If nodetool can't connectnodetool stopdaemon# Error: Failed to connect to '127.0.0.1:7199'
# Use systemctl or kill insteadsystemctl stop cassandra# orkill $(pgrep -f CassandraDaemon)Best Practices
Section titled “Best Practices”Shutdown Guidelines
- Always drain first - Run
nodetool drainbeforestopdaemon - Use systemd in production - Prefer
systemctl stopfor managed shutdown - Verify stopped - Confirm process exited and ports released
- Document emergency stops - Log when and why emergency stop was used
- Allow startup time - Expect longer restart after non-graceful stop
- Reserve for emergencies - Only use
stopdaemonalone when drain is not viable
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| drain | Graceful prepare for shutdown |
| status | Check cluster status before stop |
| info | Node information |
| disablebinary | Stop client connections |
| disablegossip | Stop cluster communication |