Cassandra/Tools

From Wikitech

cassandra-tools-wmf

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-cqlsh is deprecated, see cqlsh-instance below or Cassandra#Getting_a_CQL_shell

cqlsh-instance

Description

A convenience wrapper for cqlsh. This is not meant to be invoked directly; Create a symlink (preferably somewhere on PATH) in the form cqlsh-{id} .

$ ln -s /usr/bin/cqlsh-instance /usr/local/bin/cqlsh-a
$ cqlsh-a
Connected to cassandra-dev at 10.192.16.14:9042
[cqlsh 6.1.0 | Cassandra 4.1.1 | CQL spec 3.4.6 | Native protocol v5]
Use HELP for help.
cassandra@cqlsh>
In the Wikimedia environment, links are created automatically via Puppet (see also: Cassandra#Getting_a_CQL_shell)

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
                         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

cassandra-ca-manager

cassandra-ca-manager: manage Java keystores with a self-signed certificate authority

cdsh

cdsh: a Cassandra cluster wrapper for dsh