Illustration Image

Cassandra.Link

The best knowledge base on Apache Cassandra®

Helping platform leaders, architects, engineers, and operators build scalable real time data platforms.

12/5/2020

Reading time:N/A min

What is the best way to get a list of nodes that belong to a Cassandra cluster?

by John Doe

I'm creating some scripts for some Cassandra clusters I operate. Some of these scripts need a list of nodes that are part of the cluster. nodetool status will print a list of the nodes and their current state, but it prints out more information than I need. For example:$ nodetool status mykeyspaceDatacenter: datacenter1=======================Status=Up/Down|/ State=Normal/Leaving/Joining/Moving-- Address Load Tokens Owns Host ID RackUN 10.11.12.13 47.66 KB 1 33.3% aaa1b7c1-6049-4a08-ad3e-3697a0e30e10 rack1UN 10.11.12.14 47.67 KB 1 33.3% 1848c369-4306-4874-afdf-5c1e95b8732e rack1UN 10.11.12.15 47.67 KB 1 33.3% 49578bf1-728f-438d-b1c1-d8dd644b6f7f rack1The list of the nodes should be IPs only ( hostnames aren't necessary) and I'd like clean output like the following:10.11.12.1310.11.12.1410.11.12.15What is the best/simplest way to do this? I'll provide my current method below for doing this, but if there's a better way I'd love to see it. Even if it doesn't use the nodetool command.

Illustration Image

I'm creating some scripts for some Cassandra clusters I operate. Some of these scripts need a list of nodes that are part of the cluster.

nodetool status will print a list of the nodes and their current state, but it prints out more information than I need. For example:

$ nodetool status mykeyspace
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address      Load       Tokens  Owns    Host ID                               Rack
UN  10.11.12.13  47.66 KB   1       33.3%   aaa1b7c1-6049-4a08-ad3e-3697a0e30e10  rack1
UN  10.11.12.14  47.67 KB   1       33.3%   1848c369-4306-4874-afdf-5c1e95b8732e  rack1
UN  10.11.12.15  47.67 KB   1       33.3%   49578bf1-728f-438d-b1c1-d8dd644b6f7f  rack1

The list of the nodes should be IPs only ( hostnames aren't necessary) and I'd like clean output like the following:

10.11.12.13
10.11.12.14
10.11.12.15

What is the best/simplest way to do this?

I'll provide my current method below for doing this, but if there's a better way I'd love to see it. Even if it doesn't use the nodetool command.

Related Articles

data.processing
cassandra
nvidia

GitHub - fversaci/cassandra-dali-plugin: Cassandra plugin for NVIDIA DALI

fversaci

8/17/2023

cassandra
prisma

Checkout Planet Cassandra

Claim Your Free Planet Cassandra Contributor T-shirt!

Make your contribution and score a FREE Planet Cassandra Contributor T-Shirt! 
We value our incredible Cassandra community, and we want to express our gratitude by sending an exclusive Planet Cassandra Contributor T-Shirt you can wear with pride.

Join Our Newsletter!

Sign up below to receive email updates and see what's going on with our company

Explore Related Topics

AllKafkaSparkScyllaSStableKubernetesApiGithubGraphQl

Explore Further

cassandra