The nodetool utility is a command line interface for Cassandra. You can use it to help manage a cluster.
In binary installations, nodetool is located in the <install_location>/bin directory. Square brackets indicate optional parameters.
nodetool -h HOSTNAME [-p JMX_PORT] COMMAND
If a username and password for RMI authentication are set explicitly in the cassandra-env.sh file for the host, then you must specify credentials:
nodetool -h HOSTNAME [-p JMX_PORT -u JMX_USERNAME -pw JMX_PASSWORD] COMMAND
The available options are:
|-h||--host arg||Hostname of node or IP address.|
|-p||--port arg||Remote JMX agent port number.|
|-pr||--partitioner-range||Repair only the first range returned by the partitioner for the node.|
|-pw||--password arg||Remote JMX agent password.|
|-u||--username arg||Remote JMX agent username.|
|Snapshot Options Only|
|-cf||--column-family arg||Only take a snapshot of the specified column family.|
|-snapshot||--with-snapshot||Repair one node at a time using snapshots.|
|-t||--tag arg||Optional name to give a snapshot.|
The available commands are:
Details for each command are listed below:
cfhistograms keyspace cf_name
Displays statistics on the read/write latency for a column family. These statistics, which include row size, column count, and bucket offsets, can be useful for monitoring activity in a column family.
Displays statistics for every keyspace and column family.
Triggers the immediate cleanup of keys no longer belonging to this node. This has roughly the same effect on a node that a major compaction does in terms of a temporary increase in disk space usage and an increase in disk I/O. Optionally takes a list of column family names.
clearsnapshot [keyspaces] -t [snapshotName]
Deletes snapshots for the specified keyspaces. You can remove all snapshots or remove the snapshots with the given name.
For column families that use the SizeTieredCompactionStrategy, initiates an immediate major compaction of all column families in keyspace. For each column family in keyspace, this compacts all existing SSTables into a single SSTable. This can cause considerable disk I/O and can temporarily cause up to twice as much disk space to be used. Optionally takes a list of column family names.
Displays compaction statistics.
Tells a live node to decommission itself (streaming its data to the next node on the ring). Use netstats to monitor the progress.
Shows the token ranges for a given keyspace.
Disable Gossip. Effectively marks the node dead.
Disables the Thrift server.
Flushes all memtables from the node to SSTables on disk. Cassandra stops listening for connections from the client and other nodes. You need to restart Cassandra after running nodetool drain. You typically use this command before upgrading a node to a new version of Cassandra. To simply flush memtables to disk, use nodetool flush.
Re-enables the Thrift server.
flush [keyspace] [cf_name]
Flushes all memtables for a keyspace to disk, allowing the commit log to be cleared. Optionally takes a list of column family names.
getcompactionthreshold keyspace cf_name
Gets the current compaction threshold settings for a column family. See:
getendpoints keyspace cf key
Displays the end points that owns the key. The key is only accepted in HEX format.
getsstables keyspace cf key
Displays the sstable filenames that own the key.
Shows the gossip information for the cluster.
Outputs node information including the token, load info (on disk storage), generation number (times started), uptime in seconds, and heap memory usage.
invalidatekeycache [keyspace] [cfnames]
Invalidates, or deletes, the key cache. Optionally takes a keyspace or list of column family names. Leave a blank space between each column family name.
invalidaterowcache [keyspace] [cfnames]
Invalidates, or deletes, the row cache. Optionally takes a keyspace or list of column family names. Leave a blank space between each column family name.
Causes the node to join the ring. This assumes that the node was initially not started in the ring, that is, started with -Djoin_ring=false. Note that the joining node should be properly configured with the desired options for seed list, initial token, and auto-bootstrapping.
Moves a node to a new token. This essentially combines decommission and bootstrap. See:
Displays network information such as the status of data streaming operations (bootstrap, repair, move, and decommission) as well as the number of active, pending, and completed commands and responses.
Displays the sampled keys held across all keyspaces.
Rebuilds data by streaming from other nodes (similar to bootstrap). Use this command to bring up a new data center in an existing cluster. See Adding a Data Center to a Cluster.
rebuild_index keyspace cf-name index_name,index_name1
Fully rebuilds of native secondary index for a given column family. Example of index_names: Standard3.IdxName,Standard3.IdxName1
refresh keyspace cf_name
Loads newly placed SSTables on to the system without restart.
removetoken status | force | token
Shows status of a current token removal, forces the the completion of a pending removal, or removes a specified token. This token’s range is assumed by another node and the data is streamed there from the remaining live replicas. See:
repair keyspace [cf_name] [-pr]
Begins an anti-entropy node repair operation. If the -pr option is specified, only the first range returned by the partitioner for a node is repaired. This allows you to repair each node in the cluster in succession without duplicating work.
Without -pr, all replica ranges that the node is responsible for are repaired.
Optionally takes a list of column family names.
Displays node status and information about the ring as determined by the node being queried. This can give you an idea of the load balance and if any nodes are down. If your cluster is not properly configured, different nodes may show a different ring; this is a good way to check that every node views the ring the same way.
Rebuilds SSTables on a node for the named column families and snapshots data files before rebuilding as a safety measure. If possible use upgradesstables. While scrub rebuilds SSTables, it also discards data that it deems broken and creates a snapshot, which you have to remove manually.
setcachecapacity key_cache_capacity row_cache_capacity
Set global key and row cache capacities in megabytes.
setcompactionthreshold keyspace cf_name min_threshold max_threshold
The min_threshold parameter controls how many SSTables of a similar size must be present before a minor compaction is scheduled. The max_threshold sets an upper bound on the number of SSTables that may be compacted in a single minor compaction. See also:
Set the maximum throughput for compaction in the system in megabytes per second. Set to 0 to disable throttling.
Set the maximum streaming throughput in the system in megabytes per second. Set to 0 to disable throttling.
snapshot -cf [columnfamilyName] [keyspace] -t [snapshot-name]
Takes an online snapshot of Cassandra’s data. Before taking the snapshot, the node is flushed. The results are stored in Cassandra’s data directory under the snapshots directory of each keyspace. See Install Locations. See:
Status of the thrift server.
stop [operation type]
Stops an operation from continuing to run. Options are COMPACTION, VALIDATION, CLEANUP, SCRUB, INDEX_BUILD. For example, this allows you to stop a compaction that has a negative impact on the performance of a node. After the compaction stops, Cassandra continues with the rest in the queue. Eventually, Cassandra restarts the compaction.
Displays the number of active, pending, and completed tasks for each of the thread pools that Cassandra uses for stages of operations. A high number of pending tasks for any pool can indicate performance problems. See:
Rebuilds SSTables on a node for the named column families. Use when upgrading your server or changing compression options (available from Cassandra 1.0.4 onwards).
Displays the Cassandra release version for the node being queried.