Illustration Image

Cassandra.Link

The best knowledge base on Apache Cassandra®

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

9/16/2019

Reading time:2 min

eevans/cassandra-tools-wmf

by John Doe

Cluster management tools for Apache Cassandra.Table of contentsThe toolsc-cqlshc-any-ntc-foreach-ntc-foreach-restartc-lsstreamsuyamlBuilding a Debian packageThe toolsc-cqlshSynopsisc-cqlsh <id>DescriptionGiven an instance ID, executes cqlsh on that instance. Uses the the cqlshrc file located in the instance's configuration directory.Example$ c-cqlsh aConnected to services-test at 10.64.0.202:9042.[cqlsh 5.0.1 | Cassandra 2.2.6 | CQL spec 3.3.1 | Native protocol v4]Use HELP for help.cassandra@cqlsh>c-any-ntSynopsisc-any-nt <arg> [arg ...]DescriptionIn a WMF multi-instance environment, executes nodetool on a randomly chosen instance (any instance).Example$ c-any-nt status -r...c-foreach-ntSynopsisc-foreach-nt <arg> [arg ...]DescriptionIn a WMF multi-instance environment, iteratively execute nodetool on all local Cassandra instances.Example$ c-foreach-nt versiona: ReleaseVersion: 2.2.6b: ReleaseVersion: 2.2.6c-foreach-restartSynopsisusage: c-foreach-restart [-h] [-a ATTEMPTS] [-r RETRY] [--execute-post-shutdown CMD] [-d DELAY] [--logmsgbot LOGMSGBOT] [--tcpircbot-host HOST] [--tcpircbot-port PORT] [--phabricator-issue ISSUE]Cassandra instance restarteroptional arguments: -h, --help show this help message and exit -a ATTEMPTS, --attempts ATTEMPTS Maximum number of times to check if service is up after restarting. -r RETRY, --retry RETRY Number seconds between connection attempts, in seconds. --execute-post-shutdown CMD Command to execute after Cassandra has been shutdown, and before it is started back up. -d DELAY, --delay DELAY Delay between instance restarts (defaults to no delay). --logmsgbot LOGMSGBOT Log restarts to SAL (via logmsgbot and #wikimedia- operations). --tcpircbot-host HOST tcpircbot hostname. Only valid when --logmsgbot is used. Default: einsteinium.wikimedia.org --tcpircbot-port PORT tcpircbot port number. Only valid when --logmsgbot is used. Default: 9200 --phabricator-issue ISSUE Phabricator issue to associate these restarts with. This currently only makes sense in combination with --logmsgbot where it is included in the formatted log message.DescriptionIn a WMF multi-instance environment, iteratively restart instances.Each instance is drained prior to being restarted. After each restart, the process blocksuntil the CQL port is listening.Commands specified by --execute-post-shutdown can include the {id} template which willbe substituted with the ID of the instance being restarted.Example$ sudo c-foreach-restart --execute-post-shutdown="echo '{id} is a teapot, short and stout'"...c-lsSynopsisc-lsDescriptionList the IDs of the locally configured instance IDs.Example$ c-lsabcstreamsSynopsisstreams [-h] [-nt CMD]Cassandra streams monitoroptional arguments: -h, --help show this help message and exit -nt CMD, --nodetool CMD Nodetool command to useDescriptionRealtime console monitoring of streaming operations.Example$ streams -nt nodetool-buyamlSynopsisuyaml [-h] yaml pathYAML parserpositional arguments: yaml YAML file to parse path Path to parse from fileoptional arguments: -h, --help show this help message and exitDescriptionQuery attributes from a YAML file.Example$ uyaml /etc/cassandra-instances.d/restbase1007-a.yaml /jmx_port7189$ for i in `c-ls`; do uyaml /etc/cassandra-instances.d/restbase1007-$i.yaml /jmx_port; done718971907191Building a Debian package$ git checkout master$ make orig.tar.gz$ git checkout debian$ git merge master$ # Update debian/changelog accordingly$ dpkg-buildpackage -rfakeroot # or alternately...$ gbp buildpackage -rfakeroot -us -uc

Illustration Image

Cluster management tools for Apache Cassandra.

Table of contents

The tools

c-cqlsh

Synopsis

c-cqlsh <id>

Description

Given an instance ID, executes cqlsh on that instance. Uses the the cqlshrc file located in the instance's configuration directory.

Example

$ c-cqlsh a
Connected to services-test at 10.64.0.202:9042.
[cqlsh 5.0.1 | Cassandra 2.2.6 | CQL spec 3.3.1 | Native protocol v4]
Use HELP for help.
cassandra@cqlsh>

c-any-nt

Synopsis

c-any-nt <arg> [arg ...]

Description

In a WMF multi-instance environment, executes nodetool on a randomly chosen instance (any instance).

Example

$ c-any-nt status -r
...

c-foreach-nt

Synopsis

c-foreach-nt <arg> [arg ...]

Description

In a WMF multi-instance environment, iteratively execute nodetool on all local Cassandra instances.

Example

$ c-foreach-nt version
a: ReleaseVersion: 2.2.6
b: ReleaseVersion: 2.2.6

c-foreach-restart

Synopsis

usage: c-foreach-restart [-h] [-a ATTEMPTS] [-r RETRY]
                         [--execute-post-shutdown CMD] [-d DELAY]
                         [--logmsgbot LOGMSGBOT] [--tcpircbot-host HOST]
                         [--tcpircbot-port PORT] [--phabricator-issue ISSUE]
Cassandra instance restarter
optional arguments:
  -h, --help            show this help message and exit
  -a ATTEMPTS, --attempts ATTEMPTS
                        Maximum number of times to check if service is up
                        after restarting.
  -r RETRY, --retry RETRY
                        Number seconds between connection attempts, in
                        seconds.
  --execute-post-shutdown CMD
                        Command to execute after Cassandra has been shutdown,
                        and before it is started back up.
  -d DELAY, --delay DELAY
                        Delay between instance restarts (defaults to no
                        delay).
  --logmsgbot LOGMSGBOT
                        Log restarts to SAL (via logmsgbot and #wikimedia-
                        operations).
  --tcpircbot-host HOST
                        tcpircbot hostname. Only valid when --logmsgbot is
                        used. Default: einsteinium.wikimedia.org
  --tcpircbot-port PORT
                        tcpircbot port number. Only valid when --logmsgbot is
                        used. Default: 9200
  --phabricator-issue ISSUE
                        Phabricator issue to associate these restarts with.
                        This currently only makes sense in combination with
                        --logmsgbot where it is included in the formatted log
                        message.

Description

In a WMF multi-instance environment, iteratively restart instances.

Each instance is drained prior to being restarted. After each restart, the process blocks until the CQL port is listening.

Commands specified by --execute-post-shutdown can include the {id} template which will be substituted with the ID of the instance being restarted.

Example

$ sudo c-foreach-restart --execute-post-shutdown="echo '{id} is a teapot, short and stout'"
...

c-ls

Synopsis

c-ls

Description

List the IDs of the locally configured instance IDs.

Example

$ c-ls
a
b
c

streams

Synopsis

streams [-h] [-nt CMD]
Cassandra streams monitor
optional arguments:
  -h, --help            show this help message and exit
  -nt CMD, --nodetool CMD
                        Nodetool command to use

Description

Realtime console monitoring of streaming operations.

Example

$ streams -nt nodetool-b

uyaml

Synopsis

uyaml [-h] yaml path
YAML parser
positional arguments:
  yaml        YAML file to parse
  path        Path to parse from file
optional arguments:
  -h, --help  show this help message and exit

Description

Query attributes from a YAML file.

Example

$ uyaml /etc/cassandra-instances.d/restbase1007-a.yaml /jmx_port
7189
$ for i in `c-ls`; do uyaml /etc/cassandra-instances.d/restbase1007-$i.yaml /jmx_port; done
7189
7190
7191

Building a Debian package

$ git checkout master
$ make orig.tar.gz
$ git checkout debian
$ git merge master
$ # Update debian/changelog accordingly
$ dpkg-buildpackage -rfakeroot # or alternately...
$ gbp buildpackage -rfakeroot -us -uc

Related Articles

cassandra
tools
sstables

ic-tools for Apache Cassandra SSTables

John Doe

2/17/2023

cassandra
tools

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