Apache Cassandra

Cassandra Get Cluster Status

As a database administrator, you will constantly monitor and check the health status of your Cassandra nodes. Cassandra provides a native command-line tool that allows us to do just that.

In this tutorial, you will learn how to use the Apache Cassandra nodetool command to monitor the health of your cluster.

What Is Nodetool?

The nodetool is a command-line utility that allows you to easily manage your Apache Cassandra cluster. Using the nodetool command, you can create backups, manage logs and flush the cluster, manage the cluster daemon, and more.

Checking Your Cluster Health with Nodetool

The nodetool command allows us to gather information about the cluster such as its state, resource usage, IDs, etc.

The command syntax is as shown:

nodetool <options> status ( -r | --resolve-ip ) -- <keyspace>

 
If you installed Apache Cassandra via the archive, you can find the nodetool command in the bin directory:

installation_directory/cassandra/bin

 
The command accepts the options such as:

    1. -h – Specifies the hostname or IP address of the target node.
    2. -p – Defines the port number on which the cluster is running.
    3. -pwf – Sets the path to the password file.
    4. -pw – Specifies the password to login into the cluster.
    5. -r – Shows the node names instead of IP addresses.
    6. Keyspace – Defines the keyspace name.

Example:

The following example shows how to check the cluster health of the local node:

$ nodetool status

 
The command returns the cluster information as shown in the following output:

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load        Tokens  Owns  Host ID                               Rack
UN  127.0.0.1  217.76 KiB  16      ?     98e7247d-735a-4552-9c8f-beeb964e50b6  rack1

 
The status command returns the information such as:

    1. Status – This shows whether the node is running or not.
    2. State – This indicates the stat of the node to the cluster.
    3. Address – This represents the address of the node.
    4. Load – Shows the size under the Cassandra data directory (excluding snapshots).
    5. Tokens – Represents the number of tokens for that specific node.
    6. Owns – Indicates the percentage of data held by the node within the data center.
    7. Host ID – Represents the network ID of the node.
    8. Rack – Shows the rack to which the node belongs.

Checking Node Health with the Info Command

You can also use the nodetool info command to show the detailed information about the node. An example is as shown:

$ nodetool info

 
The command should return the information as:

ID                     : 98e7247d-735a-4552-9c8f-beeb964e50b6
Gossip active          : true
Native Transport active: true
Load                   : 217.76 KiB
Generation No          : 1661396337
Uptime (seconds)       : 7381
Heap Memory (MB)       : 301.87 / 1914.94
Off Heap Memory (MB)   : 0.00
Data Center            : datacenter1
Rack                   : rack1
Exceptions             : 0
Key Cache              : entries 40, size 3.44 KiB, capacity 95 MiB, 169 hits, 212 requests, 0.797 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 47 MiB, 0 hits, 0 requests, NaN recent hit rate, 7200 save period in seconds
Percent Repaired       : 100.0%
Token                  : (invoke with -T/--tokens to see all 16 tokens)

 

 

Conclusion

This article discussed how to use the nodetool command to gather the health information about your Apache Cassandra cluster.

Thanks for reading!

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list