Debug Cassandra

  • Table status: nodetool tablestats (size, compression ratio, ...)

Cassandra stress

specname: bookings
keyspace: flights
table: bookings
columnspec:
  - name: booking_id
    size: uniform(1..100)
  - name: flight_id
    size: uniform(1..100)
  - name: user_id
    size: normal(10..100,50)
  - name: seat
    size: uniform(1..200)
  - name: time
    cluster: uniform(20..200)
insert:
  # How many partition to insert per batch
  partitions: fixed(1)
  # How many rows to update per partition
  select: fixed(1)/200
  # UNLOGGED or LOGGED batch for insert
  batchtype: UNLOGGED

queries:
   events:
      cql: select *  from staff_activities where name = ?
      fields: samerow
   latest_event:
      cql: select * from staff_activities where name = ?  LIMIT 1
      fields: samerow

## cassandra-stress user profile=./stress-example.yaml "ops(insert=1,latest_event=1,events=1)" -graph file=graph.html title="Awesome graph"
## cassandra-stress user profile=./example.yaml duration=1m "ops(insert=1,latest_event=1,events=1)" truncate=once
## cassandra-stress user profile=./stress-bookings.yaml duration=10m "ops(insert=10,latest_event=1,events=1)" truncate=once -graph file=graph.html -node 192.168.0.91

Commands

docker run --rm -e SSL_VALIDATE=false -it cassandra:5 cqlsh 1.2.3.4 9042

Export data

https://docs.datastax.com/en/cql-oss/3.3/cql/cql_reference/cqlshCopy.html

COPY keyspace_name.users (id, name, email) FROM 'path/to/users.csv' WITH HEADER = TRUE;

Import data

COPY keyspace_name.users TO 'path/to/exported_users.csv' WITH HEADER = TRUE;