Skip to content

Instantly share code, notes, and snippets.

@tzach
Created July 23, 2023 19:10
Show Gist options
  • Save tzach/09429d245d2f27080b761fd9351ff3bc to your computer and use it in GitHub Desktop.
Save tzach/09429d245d2f27080b761fd9351ff3bc to your computer and use it in GitHub Desktop.
Scylla U live 2023 script
# https://gist.github.com/tzach/7486f1a0cc904c52f4514f20f14d2a97
docker run --name some-scylla -d scylladb/scylla:5.2 --smp 1 --memory 750M --overprovisioned 1
SEED=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' some-scylla)
docker run --name some-scylla2 -d scylladb/scylla:5.2 --smp 1 --memory 750M --overprovisioned 1 --api-address 0.0.0.0 --seeds="$SEED"
docker run --name some-scylla3 -d scylladb/scylla:5.2 --smp 1 --memory 750M --overprovisioned 1 --api-address 0.0.0.0 --seeds="$SEED"
docker exec -it some-scylla nodetool status
cd ~/projects/scylla-monitoring/
## update scylla-monitoring/prometheus/scylla_servers.example.yml
./start-all.sh -s prometheus/scylla_servers.example.yml -d prometheus_data --no-loki
docker exec -it some-scylla cqlsh
# https://gist.github.com/tzach/7486f1a0cc904c52f4514f20f14d2a97
DROP KEYSPACE mykeyspace;
CREATE KEYSPACE mykeyspace WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor' : 3} AND durable_writes = true;
use mykeyspace;
CREATE TABLE heartrate_v10 (
pet_chip_id uuid,
owner uuid,
time timestamp,
heart_rate int,
PRIMARY KEY (pet_chip_id, time)
);
TRACING ON;
INSERT INTO heartrate_v10(pet_chip_id,owner,time,heart_rate) VALUES (a2a60505-3e17-4ad4-8e1a-f11139caa1cc, 642adfee-6ad9-4ca5-aa32-a72e506b8ad8, '2021-05-01 01:00+0000', 100);
CONSISTENCY;
CONSISTENCY ALL;
CONSISTENCY QUORUM ;
CONSISTENCY ONE;
docker stop some-scylla3
docker exec -it some-scylla nodetool status
# monitor
# demo...
docker start some-scylla3
docker exec -it some-scylla nodetool status
# Compaction
cassandra-stress write n=10000000 -port jmx=6868 -mode cql3 native -rate threads=1 -node 172.17.0.2
http://localhost:3000/d/detailed-5-1/detailed
-------------------
Thombstones
cqlsh> use mykeyspace ;
cqlsh:mykeyspace>
DROP KEYSPACE mykeyspace;
CREATE KEYSPACE mykeyspace WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor' : 3} AND durable_writes = true;
use mykeyspace;
CREATE TABLE heartrate_v10 (
pet_chip_id uuid,
owner uuid,
time timestamp,
heart_rate int,
PRIMARY KEY (pet_chip_id, time)
);
INSERT INTO heartrate_v10(pet_chip_id,owner,time,heart_rate) VALUES (a2a60505-3e17-4ad4-8e1a-f11139caa1cc, 642adfee-6ad9-4ca5-aa32-a72e506b8ad8, '2021-05-01 01:01+0000', 101);
INSERT INTO heartrate_v10(pet_chip_id,owner,time,heart_rate) VALUES (a2a60505-3e17-4ad4-8e1a-f11139caa1cc, 642adfee-6ad9-4ca5-aa32-a72e506b8ad8, '2021-05-01 01:02+0000', 110);
INSERT INTO heartrate_v10(pet_chip_id,owner,time,heart_rate) VALUES (a2a60505-3e17-4ad4-8e1a-f11139caa1cc, 642adfee-6ad9-4ca5-aa32-a72e506b8ad8, '2021-05-01 01:03+0000', 102);
INSERT INTO heartrate_v10(pet_chip_id,owner,time,heart_rate) VALUES (80d39c78-9dc0-11eb-a8b3-0242ac130003, 642adfee-6ad9-4ca5-aa32-a72e506b8ad8, '2021-05-01 01:00+0000', 120);
INSERT INTO heartrate_v10(pet_chip_id,owner,time,heart_rate) VALUES (80d39c78-9dc0-11eb-a8b3-0242ac130003, 642adfee-6ad9-4ca5-aa32-a72e506b8ad8, '2021-05-01 01:01+0000', 121);
INSERT INTO heartrate_v10(pet_chip_id,owner,time,heart_rate) VALUES (80d39c78-9dc0-11eb-a8b3-0242ac130003, 642adfee-6ad9-4ca5-aa32-a72e506b8ad8, '2021-05-01 01:02+0000', 120);
SELECT * FROM heartrate_v10;
DELETE FROM heartrate_v10 WHERE pet_chip_id = a2a60505-3e17-4ad4-8e1a-f11139caa1cc AND time = '2021-05-01 01:01+0000';
DELETE FROM heartrate_v10 WHERE pet_chip_id = a2a60505-3e17-4ad4-8e1a-f11139caa1cc AND time = '2021-05-01 01:02+0000';
DELETE FROM heartrate_v10 WHERE pet_chip_id = 80d39c78-9dc0-11eb-a8b3-0242ac130003;
nodetool flush
ls -l /var/lib/scylla/data/mykeyspace/heartrate_v10- ...
sstabledump /var/lib/scylla/data/mykeyspace/heartrate_v10-b11cc170292311eeb5f5ab674ba4d970/me-3-big-Data.db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment