๐ Apache Cassandra#
Overview
Cassandra is a free and open-source,
distributed, wide-column store, NoSQL database
management system designed to handle large
amounts of data across many commodity servers,
providing high availability with no single point
of failure.
NOSQL vs SQL = CAP vs ACID
- CAP Theorem (Brewerโs theorem)
consistency
availabilty
partition tolerance
- ACID
atomicity
consistency
isolation
durability
apache fondation, opensourced in 2008 by facebook
- competitors
Google Bigtable
Amazon DynamoDB
- Advantages
fault tolerance
highly scalable
high performance with large volume
opensource (Datastax)
distributed system (no spof)
databases models simplification
langage CQL , close to SQL
- Disadvantages
no ACID : consistency vs performance
no conplexes models : no foreign key, no indexes
๐
ACID vs CAP#
ACID = RDBMS (Relational DataBase Management System)
atomic |
transaction is complete or not at all |
consistent |
in case of error the status reverts to the one before |
isolated |
no interference between transactions |
durable |
data are available after reboot |
CAP Theorem
consistency |
same state on all nodes |
availability |
systematic response to requests |
partition |
autonomy if network failure |
- no transaction but PAXOS protocol
- consensus protocols for fallible distributed system
roles :
client : issues a request to the distributed system
acceptor : act as the fault-tolerant โmemoryโ of the protocol
proposer : advocates a client request
learner : act as the replication factor for the protocol
leader : Paxos requires a distinguished Proposer
Single Installation#
Debian packages.
> apt install openjdk-11-jdk gnupg2
> echo "deb https://debian.cassandra.apache.org 41x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list>
> curl https://downloads.apache.org/cassandra/KEYS | sudo apt-key add -
> apt update && apt install cassandra
> netstat -tupane | grep java
tcp 0 0 127.0.0.1:7199 0.0.0.0:* LISTEN 108 13566 568/java
tcp 0 0 127.0.0.1:40015 0.0.0.0:* LISTEN 108 13567 568/java
tcp 0 0 127.0.0.1:9042 0.0.0.0:* LISTEN 108 13725 568/java
tcp 0 0 127.0.0.1:7000 0.0.0.0:* LISTEN 108 13102 568/java
> nodetool status
> cqlsh
Docker images with docker-compose.yml
version: '3.9'
services:
cassandra:
image: cassandra:latest
container_name: cassandra
ports:
- 9042:9042 # cqlsh
- 7199:7199 # jmx
- 7000:7000 # internode communication
- 7001:7001 # tls internode
- 9160:9160 # client api
networks:
- cassnet
volumes:
- ./data:/var/lib/cassandra:Z
environment:
- CASSANDRA_CLUSTER_NAME=test
networks:
cassnet:
driver: bridge
ipam:
config:
- subnet: 172.20.1.0/24
Principles and Definitions#
Component |
Defintion |
cluster |
set of servers linked by their network configuration spread over one or more sites |
datacenter |
replication group, physical cutting (dc, rack,โฆ) or logical |
node/peer |
serveur member of a cluster |
keyspaces |
like database/schema, group of one or more tables |
tables |
lines/columns |
users |
accounts with login/password access |
commitlog |
write requests to disk (like WAL PG), recovery |
memtables |
write data to memory |
SSTables |
datafiles where the data are stored on disk |
Principle |
Defintion |
coordinator |
received the request first, determines who can process the request |
replica |
distributed data copying, keyspace replication strategy, replicas = latency |
consistency |
how many replicas need to be written to consider the resquest as completed |
protocol gossip |
nodes discovery by cluster and node status |
partitionner function |
allows to know who stores replica cases, token principle |
ring token |
write row data >> hash value (token) >> 1 node owner by hash |
snitch |
find the answer to resquests via topology and data distribution method |
compaction |
table data are versioned, marked as deleted (tombstone) |
bloom filter |
algorhythm to find the data of a line |
node repair |
fix consistency |
Directories and Files#
> systemctl cat cassandra.service | grep ^Exec
ExecStart=/etc/init.d/cassandra start
ExecStop=/etc/init.d/cassandra stop
/etc/init.d/cassandra#
> grep "^[A-Z]" /etc/init.d/cassandra
DESC="Cassandra"
NAME=cassandra
PIDFILE=/var/run/$NAME/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
CONFDIR=/etc/cassandra
WAIT_FOR_START=10
CASSANDRA_HOME=/usr/share/cassandra
CASSANDRA_CONF=$CONFDIR
FD_LIMIT=100000
CMD_PATT="Dcassandra-pidfile=.*cassandra\.pid"
/etc/cassandra/cassandra.yaml#
cluster_name |
name of the cluster, important for nodes linking |
listen_address |
listen ip (default localhost) |
listen_interfaces |
replacement of the listen_address by the interface |
/etc/cassandra/jvm-*options#
/etc/cassandra/jvm-server.options
/etc/cassandra/jvm-clients.options
/etc/cassandra/jvm8-server.options
/etc/cassandra/jvm8-clients.options
/etc/cassandra/jvm11-server.options
/etc/cassandra/jvm11-clients.options
Xm[xs]
Garbage Collector
default ports
/var/lib/cassandra#
data |
datafiles >> SSTables |
commitlogs |
transactions files (recovery) |
saved_caches |
keys and rows cache backups |
binaries#
cassandra |
main binary |
cqlsh |
CQL client |
nodetool |
administration and maintenace tasks |
cassandra-stress |
benchmark tool |
sstableXXX |
sstable tools |
> line="" && ls -tr1 /usr/bin/sstable*| while read binary;do line+="${binary##*/}",;done && echo ${line%,}
sstableverify,sstableutil,sstableupgrade,sstablescrub,sstableloader
Others files#
|
conf snitch GossipingPropertyFileSnitch |
|
topology rack/dc |
|
JAVA/JVM environment variables |
|
commitlogs configuration |
|
logs format and conf |
cqlsh#
Get cluster state and infos.
> nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 192.18 KiB 16 100.0% a19242bf-639f-4d6a-8c3d-4bd1b4fc9695 rack1
> nodetool info
ID : a19242bf-639f-4d6a-8c3d-4bd1b4fc9695
Gossip active : true
Native Transport active: true
Load : 192.18 KiB
Generation No : 1675174898
Uptime (seconds) : 21598
Heap Memory (MB) : 222.64 / 972.00
Off Heap Memory (MB) : 0.00
Data Center : datacenter1
Rack : rack1
Exceptions : 0
Key Cache : entries 16, size 1.47 KiB, capacity 48 MiB, 94 hits, 113 requests, 0.832 recent hit rate, 14400 save period in seconds
Row Cache : entries 0, size 0 bytes, capacity 0 bytes, 0 hits, 0 requests, NaN recent hit rate, 0 save period in seconds
Counter Cache : entries 0, size 0 bytes, capacity 24 MiB, 0 hits, 0 requests, NaN recent hit rate, 7200 save period in seconds
Percent Repaired : 100.0%
Token : (invoke with -T/--tokens to see all 16 tokens)
Version.
> cassandra -v
> cqlsh -e 'show version;'
> nodetool version
> cqlsh --cqlshrc cqlshrc
Base.
cqlsh <ip> <port>
> cqlsh -h | awk '/^[[:space:]]*-[hCupkfe]/'
-h, --help show this help message and exit
-C, --color Always use color output
-u USERNAME, --username=USERNAME
-p PASSWORD, --password=PASSWORD
-k KEYSPACE, --keyspace=KEYSPACE
-f FILE, --file=FILE Execute commands from FILE, then exit
-e EXECUTE, --execute=EXECUTE
CQL#
- CQL keywords
SHOW : list objects
DESCRIBE : detail object
USE : use object
CREATE/DELETE/INSERT/SELECT
- Keyspaces (databases/schemas)objects/tables container
replication factor
replcation strategy / SimpleStrategy (NetworkTopologyStrategy)
Tables : formatting of row/column data - create/drop/alter/insert
Colums (fileds) : characteristics of a line with a type (int, text,โฆ)
Connection.
> cqlsh 127.0.0.1 9042
Connected to Test Cluster at 127.0.0.1:9042
[cqlsh 6.1.0 | Cassandra 4.1.0 | CQL spec 3.4.6 | Native protocol v5]
Use HELP for help.
Keyspace creation.
cqlsh> describe keyspaces;
system system_distributed system_traces system_virtual_schema
system_auth system_schema system_views
cqlsh> create keyspace myksp with replication = {'class': '
NetworkTopologyStrategy SimpleStrategy
cqlsh> create keyspace myksp with replication = {'class': 'SimpleStrategy', 'replication_factor': 2};
Warnings :
Your replication factor 2 for keyspace myksp is higher than the number of nodes 1
cqlsh> describe keyspace myksp;
CREATE KEYSPACE myksp WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '2'} AND durable_writes = true;
Use keyspace.
cqlsh> use myksp;
cqlsh:myksp> create table mytbl (id int primary key, name text);
cqlsh:myksp> insert into mytbl (id, name) values (1, 'guisam');
cqlsh:myksp> insert into mytbl (id, name) values (2, 'bill');
cqlsh:myksp> insert into mytbl (id, name) values (3, 'georges');
cqlsh:myksp> select * from mytbl;
id | name
----+---------
1 | guisam
2 | bill
3 | georges
(3 rows)
Data Modeling#
Important difference between sql and cql : different modeling/design.
Duplication and Denormalization
Normalization |
Denormalization |
|---|---|
objects classification |
request approach |
business logic (user, invoice,โฆ) |
application logic |
strong links between objects |
no link between objects |
Unicity |
Duplication |
|---|---|
reference tables |
several tables can contain the same information |
foreign/external key |
no link |
- Advantages
design simplification
maintenace simplification
fewer relations = more performances
microservices => the relational is handle at the application level
- Evolution
SQL => less writing / no duplication
Cassandra => distribution optimization, wide partitioning for easy reading
anticipation of requests (filter = where, sort = group/sort)
Design Difference#
See Data Modeling on ๐ Ditaa.
Cluster Installation#
Connect the cluster nodes#
Update the configuration filesโฆ
> ansible debian -a 'grep "^\(listen_address\|[[:space:]]*- seeds\):" /etc/cassandra/cassandra.yaml'
debian02 | CHANGED | rc=0 >>
- seeds: "192.168.122.157:7000,192.168.122.120:7000,192.168.122.161:7000"
listen_address: 192.168.122.120
debian03 | CHANGED | rc=0 >>
- seeds: "192.168.122.157:7000,192.168.122.120:7000,192.168.122.161:7000"
listen_address: 192.168.122.161
debian01 | CHANGED | rc=0 >>
- seeds: "192.168.122.157:7000,192.168.122.120:7000,192.168.122.161:7000"
listen_address: 192.168.122.157
and restart services.
Change the cluster name#
> cqlsh -e "update system.local set cluster_name = '<cassandra_cluster_name>' where key='local';"
> nodetool flush
Then update the cluster_name in /etc/cassandra/cassandra.yaml.
Check the cluster status.
> nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 192.168.122.120 212.9 KiB 16 100.0% 7ebe91a9-7e19-4ac4-afad-0dbbc7b375dd rack1
UN 192.168.122.161 250.61 KiB 16 100.0% 819799ca-876f-46dd-a68b-4f4a27641f42 rack1
UN 192.168.122.157 207.29 KiB 16 100.0% a19242bf-639f-4d6a-8c3d-4bd1b4fc9695 rack1
Change the cqlsh listening ip#
> ansible debian -m shell -a 'ss -tln | grep 9042'
debian03 | CHANGED | rc=0 >>
LISTEN 0 4096 127.0.0.1:9042 0.0.0.0:*
debian02 | CHANGED | rc=0 >>
LISTEN 0 4096 127.0.0.1:9042 0.0.0.0:*
debian01 | CHANGED | rc=0 >>
LISTEN 0 4096 127.0.0.1:9042 0.0.0.0:*
Update the configuration filesโฆ
> ansible debian -m shell -a 'grep "^rpc_address: " /etc/cassandra/cassandra.yaml'
debian03 | CHANGED | rc=0 >>
rpc_address: 192.168.122.161
debian02 | CHANGED | rc=0 >>
rpc_address: 192.168.122.120
debian01 | CHANGED | rc=0 >>
rpc_address: 192.168.122.157
and restart services.
> ansible debian -m shell -a 'ss -tln | grep 9042'
debian02 | CHANGED | rc=0 >>
LISTEN 0 4096 192.168.122.120:9042 0.0.0.0:*
debian03 | CHANGED | rc=0 >>
LISTEN 0 4096 192.168.122.161:9042 0.0.0.0:*
debian01 | CHANGED | rc=0 >>
LISTEN 0 4096 192.168.122.157:9042 0.0.0.0:*
> cqlsh 192.168.122.120
Connected to Guisam Cluster at 192.168.122.120:9042
[cqlsh 6.1.0 | Cassandra 4.1.0 | CQL spec 3.4.6 | Native protocol v5]
Use HELP for help.
cqlsh>
Tuning#
Kernel params.
/etc/sysctl.d/991-cass-tuning.conf
net.core.optmem_max = 40960
net.core.rmem_default = 16777216
net.core.rmem_max = 16777216
net.core.wmem_default = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
vm.max_map_count = 1048575
> sysctl -p /etc/sysctl.d/991-cass-tuning.conf
Disable swap.
> swapoff -a
> sed -i 's/^\([^#].*swap\)/#\1/' /etc/fstab
Change the Garbage Collector (CMS to G1).
> diff -u /etc/cassandra/jvm8-server.options{.back,}
--- /etc/cassandra/jvm8-server.options.back 2022-12-07 21:53:33.000000000 +0100
+++ /etc/cassandra/jvm8-server.options 2023-02-03 19:24:01.154164432 +0100
@@ -18,33 +18,33 @@
#################
### CMS Settings
--XX:+UseParNewGC
--XX:+UseConcMarkSweepGC
--XX:+CMSParallelRemarkEnabled
--XX:SurvivorRatio=8
--XX:MaxTenuringThreshold=1
--XX:CMSInitiatingOccupancyFraction=75
--XX:+UseCMSInitiatingOccupancyOnly
--XX:CMSWaitDuration=10000
--XX:+CMSParallelInitialMarkEnabled
--XX:+CMSEdenChunksRecordAlways
+#-XX:+UseParNewGC
+#-XX:+UseConcMarkSweepGC
+#-XX:+CMSParallelRemarkEnabled
+#-XX:SurvivorRatio=8
+#-XX:MaxTenuringThreshold=1
+#-XX:CMSInitiatingOccupancyFraction=75
+#-XX:+UseCMSInitiatingOccupancyOnly
+#-XX:CMSWaitDuration=10000
+#-XX:+CMSParallelInitialMarkEnabled
+#-XX:+CMSEdenChunksRecordAlways
## some JVMs will fill up their heap when accessed via JMX, see CASSANDRA-6541
--XX:+CMSClassUnloadingEnabled
+#-XX:+CMSClassUnloadingEnabled
### G1 Settings
## Use the Hotspot garbage-first collector.
-#-XX:+UseG1GC
-#-XX:+ParallelRefProcEnabled
+-XX:+UseG1GC
+-XX:+ParallelRefProcEnabled
#
## Have the JVM do less remembered set work during STW, instead
## preferring concurrent GC. Reduces p99.9 latency.
-#-XX:G1RSetUpdatingPauseTimePercent=5
+-XX:G1RSetUpdatingPauseTimePercent=5
#
## Main G1GC tunable: lowering the pause target will lower throughput and vise versa.
## 200ms is the JVM default and lowest viable setting
## 1000ms increases throughput. Keep it smaller than the timeouts in cassandra.yaml.
-#-XX:MaxGCPauseMillis=500
+-XX:MaxGCPauseMillis=500
## Optional G1 Settings
# Save CPU time on large (>= 16GB) heaps by delaying region scanning
> systemctl restart cassandra
Token Ring#
cassandra.apache.org - dynamo.html#consistent-hashing-using-a-token-ring
Cluster with docker-compose#
> mkdir cassandra0{1,2,3}
> sudo chown 999:999 cassandra0*
version: '3.9'
services:
cassandra01:
image: cassandra:latest
container_name: cassandra01
ports:
- 9042:9042
expose:
- 9042 # cqlsh
- 7199 # jmx
- 7000 # internode communication
- 7001 # tls internode
- 9160 # client api
networks:
- cassnet
volumes:
- ./cassandra01:/var/lib/cassandra:Z
environment:
- CASSANDRA_CLUSTER_NAME="Guisam Cluster"
- CASSANDRA_SEEDS=cassandra01,cassandra02,cassandra03
- CASSANDRA_PASSWORD_SEEDER=yes
- CASSANDRA_PASSWORD=test123
- MAX_HEAP_SIZE=2G
- HEAP_NEWSIZE=200M
cassandra02:
image: cassandra:latest
container_name: cassandra02
ports:
- 9043:9042
expose:
- 9042 # cqlsh
- 7199 # jmx
- 7000 # internode communication
- 7001 # tls internode
- 9160 # client api
networks:
- cassnet
volumes:
- ./cassandra02:/var/lib/cassandra:Z
environment:
- CASSANDRA_CLUSTER_NAME="Guisam Cluster"
- CASSANDRA_SEEDS=cassandra01,cassandra02,cassandra03
- CASSANDRA_PASSWORD_SEEDER=yes
- CASSANDRA_PASSWORD=test123
- MAX_HEAP_SIZE=2G
- HEAP_NEWSIZE=200M
cassandra03:
image: cassandra:latest
container_name: cassandra03
ports:
- 9044:9042
expose:
- 9042 # cqlsh
- 7199 # jmx
- 7000 # internode communication
- 7001 # tls internode
- 9160 # client api
networks:
- cassnet
volumes:
- ./cassandra03:/var/lib/cassandra:Z
environment:
- CASSANDRA_CLUSTER_NAME="Guisam Cluster"
- CASSANDRA_SEEDS=cassandra01,cassandra02,cassandra03
- CASSANDRA_PASSWORD_SEEDER=yes
- CASSANDRA_PASSWORD=test123
- MAX_HEAP_SIZE=2G
- HEAP_NEWSIZE=200M
networks:
cassnet:
driver: bridge
ipam:
config:
- subnet: 172.20.1.0/24
> docker-compose up -d --build
> docker exec -it cassandra01 cqlsh
> docker exec -it cassandra01 nodetool status
Reaper API#
Authenticate and store session cookie.
แ
curl -c /tmp/cookies -b /tmp/cookies -v -XPOST https://reaper.internal.softwareheritage.org/login -d "username=$USER&password=$PASS"
Get current running repairs.
แ
curl -s -c /tmp/cookies -b /tmp/cookies https://reaper.internal.softwareheritage.org/repair_run | jq '.[].state' | sort | uniq -c
แ
curl -XPUT -c /tmp/cookies -b /tmp/cookies -v \
https://reaper.internal.softwareheritage.org/repair_run/dfd93a70-3779-11ee-a734-ade03ad0235f/state/ABORTED
# pause all running tasks
แ
curl -s -c /tmp/cookies -b /tmp/cookies https://reaper.internal.softwareheritage.org/repair_run | \
jq -r '.[] | .id + " " + .state' | awk '/RUNNING/{print $1}' | \
xargs -t -n1 -i{} curl -s -c /tmp/cookies -b /tmp/cookies -XPUT https://reaper.internal.softwareheritage.org/repair_run/{}/state/PAUSED
# DELETE all paused tasks
แ
curl -s -c /tmp/cookies -b /tmp/cookies https://reaper.internal.softwareheritage.org/repair_run | \
jq -r '.[] | .id + " " + .state' | grep PAUSED | awk '{print $1}' | \
xargs -t -n1 -i{} curl -s -c /tmp/cookies -b /tmp/cookies -XDELETE https://reaper.internal.softwareheritage.org/repair_run/{}?owner=reaper
Scheduled Repairs#
แ
curl -s -c /tmp/cookies -b /tmp/cookies https://reaper.internal.softwareheritage.org/repair_schedule
แ
curl -s -c /tmp/cookies -b /tmp/cookies https://reaper.internal.softwareheritage.org/repair_run | \
jq '.[] | select(.column_families==["directory_entry"]) | "\(.state) \(.id) \(.incremental_repair) \(.start_time) \(.duration)"'
แ
curl -s -c /tmp/cookies -b /tmp/cookies https://reaper.internal.softwareheritage.org/repair_run | \
jq '.[] | select(.column_families==["raw_extrinsic_metadata"] and .state=="RUNNING") | "\(.keyspace_name) \(.column_families[0]) \(.state) \(.id) \(.incremental_repair) \(.start_time) \(.duration)"
Launch a repair manually#
แ
seq -w 01 16 | xargs -t -n1 -i{} /opt/cassandra/bin/nodetool -h cassandra{} -u cassandra \
--password $PASS repair -pr --skip-paxos -os -j4 swh directory_entry
แ
seq -w 01 16 | xargs -t -n1 -i{} /opt/cassandra/bin/nodetool -h cassandra{} -u cassandra \
--password $PASS repair -pr --skip-paxos -os -j4 swh object_references_2025w27
แ
seq -w 02 10 | xargs -t -n1 -i{} /opt/cassandra/bin/nodetool -h cassandra{} -u cassandra \
--password "$PASSWORD" repair -os -j1 swh directory_entry
แ
/opt/cassandra/bin/nodetool -h cassandra01 -u cassandra --password "$PASSWORD" repair -os -j1 swh directory_entry
แ
seq -w 01 16 | parallel --keep-order -j5 '/opt/cassandra/bin/nodetool -h cassandra{} -u cassandra \
--password siesta-subway-composer-reproduce compactionstats -H | grep -E "^([a-f0-9]+-)|^id" | sed "s/id/\nid/"'
แ
seq -w 01 16 | /usr/bin/parallel -v -j10 --ungroup ssh -t cassandra{} \
"tail -n 10000 -F /var/log/cassandra/instance1/system.log | awk '{print \"cassandra{}\",\$0}' | grep -v anticompacted"
Cassandra Reaper API endpoints#
Method |
Endpoint |
Resource |
|---|---|---|
GET |
/cluster |
(io.cassandrareaper.resources.ClusterResource) |
POST |
/cluster |
(io.cassandrareaper.resources.ClusterResource) |
POST |
/cluster/auth |
(io.cassandrareaper.resources.ClusterResource) |
PUT |
/cluster/auth/{cluster_name} |
(io.cassandrareaper.resources.ClusterResource) |
DELETE |
/cluster/{cluster_name} |
(io.cassandrareaper.resources.ClusterResource) |
GET |
/cluster/{cluster_name} |
(io.cassandrareaper.resources.ClusterResource) |
PUT |
/cluster/{cluster_name} |
(io.cassandrareaper.resources.ClusterResource) |
GET |
/cluster/{cluster_name}/tables |
(io.cassandrareaper.resources.ClusterResource) |
GET |
/crypto/encrypt/{text} |
(io.cassandrareaper.resources.CryptoResource) |
GET |
/diag_event/sse_listen/{id} |
(io.cassandrareaper.resources.DiagEventSseResource) |
GET |
/diag_event/subscription |
(io.cassandrareaper.resources.DiagEventSubscriptionResource) |
POST |
/diag_event/subscription |
(io.cassandrareaper.resources.DiagEventSubscriptionResource) |
GET |
/diag_event/subscription/adhoc |
(io.cassandrareaper.resources.DiagEventSubscriptionResource) |
GET |
/diag_event/subscription/pollers |
(io.cassandrareaper.resources.DiagEventSubscriptionResource) |
DELETE |
/diag_event/subscription/{id} |
(io.cassandrareaper.resources.DiagEventSubscriptionResource) |
GET |
/diag_event/subscription/{id} |
(io.cassandrareaper.resources.DiagEventSubscriptionResource) |
GET |
/jwt |
(io.cassandrareaper.resources.auth.ShiroJwtProvider) |
POST |
/login |
(io.cassandrareaper.resources.auth.LoginResource) |
POST |
/logout |
(io.cassandrareaper.resources.auth.LoginResource) |
GET |
/node/clientRequestLatencies/{clusterName}/{host} |
(io.cassandrareaper.resources.NodeStatsResource) |
GET |
/node/compactions/{clusterName}/{host} |
(io.cassandrareaper.resources.NodeStatsResource) |
GET |
/node/dropped/{clusterName}/{host} |
(io.cassandrareaper.resources.NodeStatsResource) |
GET |
/node/streams/{clusterName}/{host} |
(io.cassandrareaper.resources.NodeStatsResource) |
GET |
/node/tokens/{clusterName}/{host} |
(io.cassandrareaper.resources.NodeStatsResource) |
GET |
/node/tpstats/{clusterName}/{host} |
(io.cassandrareaper.resources.NodeStatsResource) |
GET |
/ping |
(io.cassandrareaper.resources.PingResource) |
HEAD |
/ping |
(io.cassandrareaper.resources.PingResource) |
GET |
/reaper/datacenterAvailability |
(io.cassandrareaper.resources.ReaperResource) |
GET |
/repair_run |
(io.cassandrareaper.resources.RepairRunResource) |
POST |
/repair_run |
(io.cassandrareaper.resources.RepairRunResource) |
GET |
/repair_run/cluster/{clusterName} |
(io.cassandrareaper.resources.RepairRunResource) |
POST |
/repair_run/purge |
(io.cassandrareaper.resources.RepairRunResource) |
DELETE |
/repair_run/{id} |
(io.cassandrareaper.resources.RepairRunResource) |
GET |
/repair_run/{id} |
(io.cassandrareaper.resources.RepairRunResource) |
PUT |
/repair_run/{id}/intensity/{intensity} |
(io.cassandrareaper.resources.RepairRunResource) |
GET |
/repair_run/{id}/segments |
(io.cassandrareaper.resources.RepairRunResource) |
POST |
/repair_run/{id}/segments/abort/{segment_id} |
(io.cassandrareaper.resources.RepairRunResource) |
PUT |
/repair_run/{id}/state/{state} |
(io.cassandrareaper.resources.RepairRunResource) |
GET |
/repair_schedule |
(io.cassandrareaper.resources.RepairScheduleResource) |
POST |
/repair_schedule |
(io.cassandrareaper.resources.RepairScheduleResource) |
GET |
/repair_schedule/cluster/{cluster_name} |
(io.cassandrareaper.resources.RepairScheduleResource) |
POST |
/repair_schedule/start/{id} |
(io.cassandrareaper.resources.RepairScheduleResource) |
GET |
/repair_schedule/{clusterName}/{id}/percent_repaired |
(io.cassandrareaper.resources.RepairScheduleResource) |
DELETE |
/repair_schedule/{id} |
(io.cassandrareaper.resources.RepairScheduleResource) |
GET |
/repair_schedule/{id} |
(io.cassandrareaper.resources.RepairScheduleResource) |
PATCH |
/repair_schedule/{id} |
(io.cassandrareaper.resources.RepairScheduleResource) |
PUT |
/repair_schedule/{id} |
(io.cassandrareaper.resources.RepairScheduleResource) |
GET |
/snapshot/cluster/{clusterName} |
(io.cassandrareaper.resources.SnapshotResource) |
POST |
/snapshot/cluster/{clusterName} |
(io.cassandrareaper.resources.SnapshotResource) |
GET |
/snapshot/cluster/{clusterName}/{host} |
(io.cassandrareaper.resources.SnapshotResource) |
POST |
/snapshot/cluster/{clusterName}/{host} |
(io.cassandrareaper.resources.SnapshotResource) |
DELETE |
/snapshot/cluster/{clusterName}/{host}/{snapshotName} |
(io.cassandrareaper.resources.SnapshotResource) |
DELETE |
/snapshot/cluster/{clusterName}/{snapshotName} |
(io.cassandrareaper.resources.SnapshotResource) |
Cassandra Scripts#
# bold
BLUEB="\e[1;34m"
GREEN="\e[32m"
NORM="\e[0m"
# bold blinking
REDBB="\e[1;5;31m"
PASSWD=$(awk '{print $2}' /etc/cassandra/jmxremote.password)
USERNAME=$(awk '{print $1}' /etc/cassandra/jmxremote.password)
alias nd='/opt/cassandra/bin/nodetool -u $USERNAME -pw $PASSWD'
ndst () {
nd status -r
}
nd_compactionstats () {
for host in $(ndst|awk '$1=="UN"{print $2}');do
echo -e "${BLUEB}${host%%.*}${NORM}"
nd -h "$host" compactionstats
done
}
nd_health () {
for host in $(ndst|awk '$1~/[DU][NLM]/{print $2}');do
echo -e "${BLUEB}${host%%.*}${NORM}"
status=$(ndst|awk -v host="$host" '$2~host{print $1}')
[[ "$status" == "UN" ]] && \
echo -e "Service status: ${GREEN}${status}${NORM} (Up and Normal)"
[[ "$status" == "DN" ]] && \
echo -e "Service status: ${REDBB}${status}${NORM} (Down and Normal)"
[[ "$status" == "UN" ]] && nd -h "$host" version
done
}
nd_unrepaired () {
[[ "$#" != 1 ]] && { echo Please give a valid cassandra table. ; exit 1 ;}
local table=$1
for host in $(ndst|awk '$1=="UN"{print $2}');do
echo -e "${BLUEB}${host%%.*}${NORM}"
nd -h "$host" tablestats -H "$table" | \
grep repaired
done
}
