DS201 Study Notes: Cassandra nodetool Commands

DS201 course study notes on Cassandra's nodetool: key commands like status, info, drain, and running stress tests with cassandra-stress.

Study notes from DS201: Foundations of Apache Cassandra™ and DataStax Enterprise.

nodetool is part of the Apache Cassandra management tools and supports runtime operations and monitoring of a Cassandra cluster.

Key Commands

help Command

$ nodetool help
usage: nodetool [(-pp | --print-port)] [(-p <port> | --port <port>)]
        [(-pwf <passwordFilePath> | --password-file <passwordFilePath>)]
        [(-pw <password> | --password <password>)] [(-h <host> | --host <host>)]
        [(-u <username> | --username <username>)] <command> [<args>]

The most commonly used nodetool commands are:
    assassinate                         Forcefully remove a dead node without re-replicating any data.  Use as a last resort if you cannot removenode
    bootstrap                           Monitor/manage node's bootstrap process
    cleanup                             Triggers the immediate cleanup of keys no longer belonging to a node. By default, clean all keyspaces
    ...

status Command

The status command displays information about the entire cluster, particularly the state of each node and node-specific details.

$ nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load        Tokens  Owns (effective)  Host ID                               Rack
UN  127.0.0.1  283.23 KiB  16      100.0%            349d6a93-038a-45a9-bd86-cc22ed3d8e0d  rack1
  • Status: Indicates the node’s status. Up means the node is running; Down means the node is stopped.
  • State: Indicates the node’s state. Normal is the regular state, Leaving means the node is departing the cluster, Joining means it is joining, and Moving means data is being moved.
  • Address: The node’s IP address.
  • Load: The amount of data the node is handling.
  • Tokens: The number of tokens the node holds.
  • Owns (effective): The percentage of data the node owns (effective ownership).
  • Host ID: The node’s unique identifier.
  • Rack: The rack the node belongs to.

info Command

The info command displays information about the connected node.

$ nodetool info
ID                     : 349d6a93-038a-45a9-bd86-cc22ed3d8e0d
Gossip active          : true
Native Transport active: true
Load                   : 283.23 KiB
Generation No          : 1686104812
Uptime (seconds)       : 20868
Heap Memory (MB)       : 302.16 / 1996.81
Off Heap Memory (MB)   : 0.00
Data Center            : datacenter1
Rack                   : rack1
Exceptions             : 0
Key Cache              : entries 21, size 1.95 KiB, capacity 99 MiB, 98 hits, 121 requests, 0.810 recent hit rate, 14400 save period in seconds
Row Cache              : entries 0, size 0 bytes, capacity 0 bytes, 0 hits, 0 requests, NaN recent hit rate, 0 save period in seconds
Counter Cache          : entries 0, size 0 bytes, capacity 49 MiB, 0 hits, 0 requests, NaN recent hit rate, 7200 save period in seconds
Network Cache          : size 8 MiB, overflow size: 0 bytes, capacity 124 MiB
Percent Repaired       : 100.0%
Token                  : (invoke with -T/--tokens to see all 16 tokens)
  • ID: The node’s unique identifier.
  • Gossip active: Whether the Gossip protocol is active.
  • Native Transport active: Whether the native transport protocol is active.
  • Load: The amount of data the node is handling.
  • Generation No: Cassandra’s generation number.
  • Uptime (seconds): How long the node has been running (in seconds).
  • Heap Memory (MB): Heap memory usage and capacity (in megabytes).
  • Off Heap Memory (MB): Off-heap memory usage (in megabytes).
  • Data Center: Data center information.
  • Rack: Rack information.
  • Exceptions: Number of errors reported by the node.
  • Key Cache: Cache information (entries, size, capacity, hits, requests, recent hit rate, save period).
  • Row Cache: Row cache information (entries, size, capacity, hits, requests, recent hit rate, save period).
  • Counter Cache: Counter cache information (entries, size, capacity, hits, requests, recent hit rate, save period).
  • Network Cache: Network cache information (size, overflow size, capacity).
  • Percent Repaired: Percentage of SSTables that have been repaired.
  • Token: Token information for the node.

describecluster Command

The describecluster command displays common settings across all nodes in the cluster and the current schema version used by each node.

$ nodetool describecluster
Cluster Information:
	Name: Test Cluster
	Snitch: org.apache.cassandra.locator.SimpleSnitch
	DynamicEndPointSnitch: enabled
	Partitioner: org.apache.cassandra.dht.Murmur3Partitioner
	Schema versions:
		d99b9ce7-d0ce-32e5-85b5-8daef23def7c: [127.0.0.1]

Stats for all nodes:
	Live: 1
	Joining: 0
	Moving: 0
	Leaving: 0
	Unreachable: 0

Data Centers:
	datacenter1 #Nodes: 1 #Down: 0

Database versions:
	4.1.2: [127.0.0.1:7000]

Keyspaces:
	system_schema -> Replication class: LocalStrategy {}
	system -> Replication class: LocalStrategy {}
	killrvideo -> Replication class: SimpleStrategy {replication_factor=1}
	system_auth -> Replication class: SimpleStrategy {replication_factor=1}
	system_distributed -> Replication class: SimpleStrategy {replication_factor=3}
	system_traces -> Replication class: SimpleStrategy {replication_factor=2}
  • Cluster Information: Displays cluster details (cluster name, snitch configuration, dynamic endpoint snitch enabled status, partitioner information).
  • Schema versions: Displays the schema version used by each node.
  • Stats for all nodes: Displays state statistics for all nodes (Live, Joining, Moving, Leaving, Unreachable).
  • Data Centers: Displays data center information (data center name, node count, down nodes).
  • Database versions: Displays database version information.
  • Keyspaces: Displays keyspace information (keyspace name and replication strategy).

getlogginglevels Command

$ nodetool getlogginglevels

Logger Name                                        Log Level
ROOT                                                    INFO
org.apache.cassandra                                   DEBUG

The following log levels are available:

  • TRACE: Displays the most detailed log messages.
  • DEBUG: Displays debug information.
  • INFO: Displays general information messages.
  • WARN: Displays warning messages.
  • ERROR: Displays error messages.

Log levels can be changed as follows:

$ nodetool setlogginglevel org.apache.cassandra TRACE

settraceprobability Command

The value set by the settraceprobability command is a decimal representing the proportion of queries that are saved. This value ranges from 0 (0%) to 1 (100%). Saved traces can be viewed in the system_traces keyspace.

$ nodetool settraceprobability 0.1

drain Command

The drain command stops writes on the node and flushes all data to disk. Typically, this command is run before stopping an Apache Cassandra node. Running it before shutdown ensures that writes are completed and data is persisted to disk.

$ nodetool drain

stopdaemon Command

A command that stops the node’s execution.

$ nodetool stopdaemon

Running a Stress Test and Verifying Data

Use the cassandra-stress write n=50000 no-warmup -rate threads=1 command to perform a write stress test against the Cassandra cluster. This test executes 50,000 write operations with a single thread against the “keyspace1” keyspace. The nodetool flush command forces in-memory data to be written to disk. The nodetool status command checks the current state of the cluster. Finally, the cqlsh tool is used to verify keyspace and table information.

$ cassandra-stress write n=50000 no-warmup -rate threads=1
******************** Stress Settings ********************
Command:
  Type: write
  Count: 50,000
  No Warmup: true
  Consistency Level: LOCAL_ONE
  ...

Results:
Op rate                   :    4,801 op/s  [WRITE: 4,801 op/s]
Partition rate            :    4,801 pk/s  [WRITE: 4,801 pk/s]
Row rate                  :    4,801 row/s [WRITE: 4,801 row/s]
Latency mean              :    0.2 ms [WRITE: 0.2 ms]
Latency median            :    0.1 ms [WRITE: 0.1 ms]
Latency 95th percentile   :    0.3 ms [WRITE: 0.3 ms]
Latency 99th percentile   :    1.0 ms [WRITE: 1.0 ms]
Latency 99.9th percentile :    3.5 ms [WRITE: 3.5 ms]
Latency max               :   48.1 ms [WRITE: 48.1 ms]
Total partitions          :     50,000 [WRITE: 50,000]
Total errors              :          0 [WRITE: 0]
Total GC count            : 1
Total GC memory           : 383.747 MiB
Total GC time             :    0.0 seconds
Avg GC time               :   45.0 ms
StdDev GC time            :    0.0 ms
Total operation time      : 00:00:10

END
$ nodetool flush
$ nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens  Owns (effective)  Host ID                               Rack
UN  127.0.0.1  12.04 MiB  16      100.0%            349d6a93-038a-45a9-bd86-cc22ed3d8e0d  rack1