Cassandra/Tools/cdsh

From Wikitech
Jump to navigation Jump to search

cdsh is a simple wrapper for dsh. It allows you to define a single hierarchical configuration for remote command execution, by cluster, data-center, and rack.

Project

Configuration

# Save as ~/.cdsh

# The restbase cluster (-c restbase)
restbase:
  # Data-center 'eqiad' (-d eqiad)
  eqiad:
    # Rack a (-r a)
    a:
      - restbase1007.eqiad.wmnet
      - restbase1010.eqiad.wmnet
      - restbase1011.eqiad.wmnet
    # Rack b (-r b)
    b:
      - restbase1003.eqiad.wmnet
      - restbase1004.eqiad.wmnet
      - restbase1008.eqiad.wmnet
    # Rack d (-r d)
    d:
      - restbase1005.eqiad.wmnet
      - restbase1006.eqiad.wmnet
      - restbase1009.eqiad.wmnet
  # Data-center 'codfw' (-d codfw)
  codfw:
    # Rack b (-r b)
    b:
      - restbase2001.codfw.wmnet
      - restbase2002.codfw.wmnet
      - restbase2007.codfw.wmnet
    # Rack c (-r c)
    c:
      - restbase2003.codfw.wmnet
      - restbase2004.codfw.wmnet
      - restbase2008.codfw.wmnet
    # Rack d (-r d)
    d:
      - restbase2005.codfw.wmnet
      - restbase2006.codfw.wmnet
      - restbase2009.codfw.wmnet

aqs:
  datacenter1:
    rack1:
      - aqs1001.eqiad.wmnet
      - aqs1002.eqiad.wmnet
      - aqs1003.eqiad.wmnet

Usage

$ cdsh -h
usage: cdsh [-h] [-c CLUSTER] [-d DATA_CENTER] [-r RACK] [--config CONFIG]
            [-P]
            [args [args ...]]

A dsh wrapper for Cassandra

positional arguments:
  args                  arguments to dsh

optional arguments:
  -h, --help            show this help message and exit
  -c CLUSTER, --cluster CLUSTER
                        cluster name
  -d DATA_CENTER, --data-center DATA_CENTER
                        data-center name
  -r RACK, --rack RACK  rack name
  --config CONFIG       yaml configuration file

Examples

Output kernel version for all machines in the restbase cluster, eqiad data-center, rack a:

$ cdsh -c restbase -d eqiad -r a -- uname -r
restbase1007.eqiad.wmnet: 4.4.0-1-amd64
restbase1010.eqiad.wmnet: 4.4.0-1-amd64
restbase1011.eqiad.wmnet: 4.4.0-1-amd64

To print all of the hosts in the aqs cluster:

$ cdsh -c aqs -P
aqs1001.eqiad.wmnet
aqs1002.eqiad.wmnet
aqs1003.eqiad.wmnet