|The Cassandra 1.2 documentation is transitioning to a new format! Please use the new Cassandra 1.2 documentation instead.||Back to Table of Contents All Documents List|
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 table.|
|-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 table
Displays statistics on the read/write latency for a table. These statistics, which include row size, column count, and bucket offsets, can be useful for monitoring activity in a table.
Displays statistics for every keyspace and table.
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 table 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 tables that use the SizeTieredCompactionStrategy, initiates an immediate major compaction of all tables in keyspace. For each table 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 table 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. See also:
Shows the token ranges for a given keyspace.
Disable Gossip. Effectively marks the node dead.
Disables the Thrift server.
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.
Re-enables the Thrift server.
flush [keyspace] [table]
Flushes all memtables for a keyspace to disk, allowing the commit log to be cleared. Optionally takes a list of table names.
getcompactionthreshold keyspace table
Gets the current compaction threshold settings for a table. See http://wiki.apache.org/cassandra/MemtableSSTable.
getendpoints keyspace table key
Displays the end points that owns the key. The key is only accepted in HEX format.
getsstables keyspace table 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] [tables]
Invalidates, or deletes, the key cache. Optionally takes a keyspace or list of table names. Leave a blank space between each table name.
invalidaterowcache [keyspace] [tables]
Invalidates, or deletes, the row cache. Optionally takes a keyspace or list of table names. Leave a blank space between each table 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 table_name.index_name,index_name1
Fully rebuilds of native secondary index for a given table. Example of index_names: Standard3.IdxName,Standard3.IdxName1
refresh keyspace table]
Loads newly placed SSTables on to the system without restart.
removenode force | status Host ID
Remove node by host ID, or force completion of pending removal. Show status of current node removal. To get host ID, run status.
repair keyspace [table] [-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 table 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.
If you are using virtual nodes, use nodetool status; it is much less verbose.
Rebuilds SSTables on a node for the named tables 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.
setcompactionthreshold keyspace table 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.
Probabilistic tracing is useful to determine the cause of intermittent query performance problems by identifying which queries are responsible. This option traces some or all statements sent to a cluster. Tracing a request usually requires at least 10 rows to be inserted.
A probability of 1.0 will trace everything whereas lesser amounts (for example, 0.10) only sample a certain percentage of statements. Care should be taken on large and active systems, as system-wide tracing will have a performance impact. Unless you are under very light load, tracing all requests (probability 1.0) will probably overwhelm your system. Start with a small fraction, for example, 0.001 and increase only if necessary. The trace information is stored in a systems_traces keyspace that holds two tables – sessions and events, which can be easily queried to answer questions, such as what the most time-consuming query has been since a trace was started. Query the parameters map and thread column in the system_traces.sessions and events tables for probabilistic tracing information.
snapshot -cf [tableName] [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:
Display cluster information, such as state, load, host ID, and token.
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 tables. 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.