Nodetool

Certify and Increase Opportunity.
Be Govt. Certified

Nodetool

nodetool

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.

The nodetool utility is a command-line interface for monitoring Cassandra and performing routine database operations. Included in the Cassandra distribution, nodetool and is typically run directly from an operational Cassandra node.

The nodetool utility supports the most important JMX metrics and operations, and includes other useful commands for Cassandra administration. This utility is commonly used to output a quick summary of the ring and its current state of general health with the status command. For example:

The nodetool utility provides commands for viewing detailed metrics for tables, server metrics, and compaction statistics. Commands include decommissioning a node, running repair, and moving partitioning tokens.

Standard usage:

nodetool -h HOSTNAME [-p JMX_PORT] COMMAND

RMI usage:

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

Options

The available options are:

Flag Option Description
-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.

Command List¶

The available commands are:

Command List
cfhistograms getcompactionthreshold removetoken
cfstats getendpoints repair
cleanup getsstables ring
clearsnapshot gossipinfo scrub
compact info setcachecapacity
compactionstats invalidatekeycache setcompactionthreshold
decomission invalidaterowcache setcompactionthroughput
describering join setstreamthroughput
disablegossip move snapshot
disablethrift netstats statusthrift
drain rangekeysample stop
enablegossip rebuild tpstats
enablethrift rebuild_index upgradesstables
flush refresh version

Command Details¶

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.

cfstats

Displays statistics for every keyspace and column family.

cleanup [keyspace][cf_name]

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.

compact [keyspace][cf_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.

compactionstats

Displays compaction statistics.

decommission

Tells a live node to decommission itself (streaming its data to the next node on the ring). Use netstats to monitor the progress.

describering [keyspace]

Shows the token ranges for a given keyspace.

disablegossip

Disable Gossip. Effectively marks the node dead.

disablethrift

Disables the Thrift server.

drain

Flushes all memtables for a node and causes the node to stop accepting write operations. Read operations will continue to work. You typically use this command before upgrading a node to a new version of Cassandra or routinely before stopping a node to speed up the restart process. Because this operation writes the current memtables to disk, Cassandra does not need to read through the commit log when you restart the node. If you have durable writes set to false, which is unlikely, there is no commit log and you must drain the node before stopping it to prevent losing data.

enablegossip

Re-enables Gossip.

enablethrift

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.

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.

gossipinfo

Shows the gossip information for the cluster.

info

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.

join

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.

move new_token

Moves a node to a new token. This essentially combines decommission and bootstrap.

netstats [host]

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.

rangekeysample

Displays the sampled keys held across all keyspaces.

rebuild [source_dc_name]

Rebuilds data by streaming from other nodes (similar to bootstrap). Use this command to bring up a new data center in an existing 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.

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.

ring

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.

scrub [keyspace][cf_name]

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.

setcompactionthroughput value_in_mb

Set the maximum throughput for compaction in the system in megabytes per second. Set to 0 to disable throttling.

setstreamthroughput value_in_mb

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.

statusthrift

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.

tpstats

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.

upgradesstables [keyspace][cf_name]

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).

version

Displays the Cassandra release version for the node being queried.

-Datastax
Maintenance
Cassandra’s need and advantages

Get industry recognized certification – Contact us

keyboard_arrow_up
Open chat
Need help?
Hello 👋
Can we help you?