Showing posts with label compact. Show all posts
Showing posts with label compact. Show all posts

Sunday, 3 May 2020

Using the nodetool Utility

The nodetool utility is a command-line interface for managing a cluster.
  • A command-line interface for monitoring Cassandra
  • Also used for performing routine database operations
  • Run directly from an operating Cassandra node
Note: If the node from which you issue the command is the intended target, you do not need the -h option to identify the target; otherwise, for remote invocation, identify the target node, or nodes, using -h.

How does it work?:
  • JMX(Java Management Extention) command line wrapper.
  • Communicates with JMX to perform Operation and Monitoring tasks exposed by MBeans
  • JMX is a Java technology that supplies tools for managing and monitoring Java applications and services.

Where does it work on? :
The nodetool commands can be categorized into these groups: 1) Cluster 2) Server 3) Backup 4) Storage 5) Compaction 6) Network


nodetool status:










Type of commands: Cluster
  • This has to do with working with the cluster-wide information
  • As the point-of-view of that node as it sees the state of the cluster.
1) nodetool status

  • Provides information about the cluster, such as the state, load, and IDs.
  • Who's up and who's down.
  • This is probably the most used nodetool command.

$ nodetool <options> status <keyspace>


2) nodetool repair

  • Starts a repair process from the point of the view of that node.
  • Repairs one or more keyspaces, tables.

$ nodetool <options> repair


Type of commands: Node
  • Scope of the commands are at the node level.

1) nodetool info
  • Provides node information such as load and uptime
  • Status of the JVM
  • Use the "T" flag to display all tokens

$ nodetool <options> info ( -T | --tokens )

2) nodetool tpstats
  • Provides usage statistics of thread pools
  • How many completed, how many pending, which ones are blocked.
  • A high number of pending tasks for any pool can indicate performance problems
  • Shows mutation drops( critical for troubleshooting a node)
  • A heavily used command during troubleshooting

$ nodetool <options> tpstats
Statuses: Active, Pending, Completed, Blocked, All time blocked, Pool Names : ReadStage RequestReleaseStage MutationStage ReadRepairStage GossipStage Anti-EntropyStage MigrationStage MemoryMeter MemtablePostFlusher FlushWriter Commitlog_Archiver InternalResponseStage HintedHandoff Message Type: Type of operations get dropped Range_Slice Read_Repair Paged_Range Binary Read Mutation _Trace Request_Response Counter_Mutation
3) nodetool tablehistograms
  • The nodetool tablehistograms command provides statistics about a table
  • Includes read/write latency, partition size, column count, and number of SSTABLES
  • The report is incremental, not cumulative.
  • It covers all the operation since the last time nodetool tablehistograms was run in the current session.
  • The use of the metrics-core library makes the output more informative and easier to understand
  • These statistics could be used to plot a frequency function.
$ nodetool <options> tablehistograms -- <keyspace>.<table>

Type of commands: Backup

1) nodetool snapshot
  • We can take a snapshot of one or more keyspaces, or of a table, to backup data.
  • Cassandra flushes the node before taking the snapshot.
  • Takes the snapshot and store the data in the snapshot directory of each keyspace in the data directory.
  • If you do not specify the name of the snapshot directory using the -T option, Cassandra names the directory using the timestamp of the snapshot like 398276394348934.
$ nodetool <options> snapshot Example: Snapshot all keyspaces $ nodetool snapshot Example: Snapshot single keypsace $ nodetool snapshot -t 2016.05.17 killrvideo Example: Multiple keyspace snapshot $ nodetool snapshot mykeyspace killrvideo Example: Single table snapshot $ nodetool snapshot --table users killrvideo Example: Snapshot different tables from different keyspaces $ nodetool snapshot -kt Cycling.Cyclist_Name, KillrVideo.Users
2) nodetool clearsnapshot:
  • Removes one or more snapshots.
$ nodetool <options> clearsnapshot --t snapshot --keyspace Keyspace_Name

3) nodetool listsnapshots:
  • Lists snapshot names, size on disk, and true size.
  $ nodetool <options> listsnapshots

Type of commands: Storage
1) nodetool cleanup:
  • Used to get rid of old data on nodes after bootstrap operations.
$ nodetool <options> cleanup -- <keyspace> (<table> ...)
2) nodetool flush:
  • The command flushes everything in the memtables out to SSTables and deletes all commitlog segments.
  • You can specify a keyspace followed by one or more tables that you want to flush from the memtable to SSTables on disk.

$ nodetool <options> flush -- <keyspace> ( <table> ... )
Type of commands: Compaction 1) nodetool compact:
  • Forces a major compaction on one or more tables for size tired compaction.
  • Acts differently for different compaction strategies.

$ nodetool <options> compact <keyspace> (<table> ...)
2) nodetool compactionstats:
  • Provides statistics about a compaction
  • Not something you would just run all the time.
  • This is a JMX statistic you could also pull in using OpsCenter
  • See what is currently compacting

$ nodetool <options> compactionstats -H
* H converts bytes to human-readable form: KB, MB, GB, or TB
Type of commands: Network

1) nodetool proxyhistograms:
  • Provides a histogram of network statistics
  • The output of this command shows the full request latency recorded by the coordinator.
  • Includes the percentile rank of the read and write latency values for inter-node communication
  • Typically, you use the command to see if requests encounter a slow node.

       $ nodetool <options> proxyhistograms


2) nodetool netstats:
  • Provides network information about host
  • The default host is the connect host if the user does not include a hostname or ip-address in the command.

$ nodetool <options> netstats -H