Skip to content

Instantly share code, notes, and snippets.

@tzach
tzach / Demo Scylla Manager with Docker
Last active Mar 6, 2019
Running a demo of a 3 node Scylla cluster, Scylla Manager and Monitoring
View Demo Scylla Manager with Docker
# Start a Scylla cluster
########################
docker run --name some-scylla -d scylladb/scylla --smp 1 --memory 750M --overprovisioned 1 --api-address 0.0.0.0
# Do not use the above --api-address for production. Exposing API IP is not secure.
SEED=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' some-scylla)
ECHO $SEED
docker run --name some-scylla2 -d scylladb/scylla --smp 1 --memory 750M --overprovisioned 1 --api-address 0.0.0.0 --seeds="$SEED"
docker run --name some-scylla3 -d scylladb/scylla --smp 1 --memory 750M --overprovisioned 1 --api-address 0.0.0.0 --seeds="$SEED"
View CQL TTL Example
CREATE KEYSPACE mykeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
USE mykeyspace;
CREATE TABLE heartrate_ttl (
pet_chip_id uuid,
time timestamp,
heart_rate int,
PRIMARY KEY (pet_chip_id, time))
WITH default_time_to_live = 604800
ALTER TABLE heartrate_ttl WITH default_time_to_live = 3600;
View CQL Counter example
CREATE KEYSPACE mykeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
UPDATE cf SET my_counter = my_counter + 6 WHERE pk = 0;
SELECT * FROM cf;
View CQL MV Example
CREATE KEYSPACE mykeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
CREATE TABLE buildings (name text, city text, height int, PRIMARY KEY (name));
CREATE MATERIALIZED VIEW building_by_city AS
SELECT * FROM buildings
WHERE city IS NOT NULL AND name IS NOT NULL
PRIMARY KEY(city, name);
INSERT INTO buildings(name,city,height) VALUES ('Burj Khalifa','Dubai',828);
INSERT INTO buildings(name,city,height) VALUES ('Shanghai Tower','Shanghai',632);
INSERT INTO buildings(name,city,height) VALUES ('Abraj Al-Bait Clock Tower','Mecca',601);
View Large Partitions Example
### First Try
CREATE KEYSPACE IF NOT EXISTS mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
USE mykeyspace;
CREATE TABLE heartrate (
pet_chip_id uuid,
time timestamp,
heart_rate int,
PRIMARY KEY (pet_chip_id, time));
INSERT INTO heartrate(pet_chip_id, time, heart_rate) VALUES (123e4567-e89b-12d3-a456-426655440b23, '2019-03-04 07:01:00', 100);
View HiveSparkScylla_datasource.yaml
databases:
- allow_run_async: true
database_name: HiveSparkScylla
expose_in_sqllab: true
extra: "{\r\n \"metadata_params\": {},\r\n \"engine_params\": {}\r\n}\r\n"
sqlalchemy_uri: hive://172.17.0.3:10000/default
tables:
- columns:
- {avg: true, column_name: co_ppm, sum: true, type: INT}
- {column_name: sensor_id, filterable: true, groupby: true, type: STRING}
View data.cql
CREATE KEYSPACE IF NOT EXISTS mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
USE mykeyspace;
CREATE TABLE IF NOT EXISTS air_quality_data (sensor_id text,time timestamp,location text, co_ppm int,PRIMARY KEY (sensor_id, time));
INSERT INTO air_quality_data(sensor_id, time, location, co_ppm) VALUES ('my_home', '2018-06-05 07:01:00', 'ISR', 17);
INSERT INTO air_quality_data(sensor_id, time, location, co_ppm) VALUES ('my_home', '2018-06-06 07:02:01', 'ISR', 18);
INSERT INTO air_quality_data(sensor_id, time, location, co_ppm) VALUES ('my_home', '2018-06-07 07:03:02', 'ISR', 19);
INSERT INTO air_quality_data(sensor_id, time, location, co_ppm) VALUES ('my_home', '2018-06-08 07:04:03', 'ISR', 20);
INSERT INTO air_quality_data(sensor_id, time, location, co_ppm) VALUES ('my_home', '2018-06-09 07:05:04', 'ISR', 30);
INSERT INTO air_quality_data(sensor_id, time, location, co_ppm) VALUES ('my_home', '2018-06-10 07:06:04', 'ISR', 31);
INSERT INTO air_quality_data(sensor_id, time, loc
@tzach
tzach / scylla_spark_superset
Created May 30, 2018
Using Scylla with Spark, Hive and Superset
View scylla_spark_superset
### Scylla
docker run --name some-scylla -d scylladb/scylla:2.1.3
docker cp data.cql some-scylla:/data.cql
docker exec -it some-scylla cqlsh -f data.cql
### Spark
docker run -it -p 4040:4040 -p 8080:8080 -p 8081:8081 -p 10000:10000 -h spark --name=spark -d p7hb/docker-spark
docker exec -it spark /usr/local/spark-2.2.0-bin-hadoop2.7/sbin/start-thriftserver.sh \
--conf hive.server2.thrift.bind.host=0.0.0.0 \
--conf spark.cassandra.connection.host=172.17.0.2 \
View test bash
echo "even more custom!" > /home/centos/more_test.txt
View .emacs
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(erc-nick "tzach")
'(package-selected-packages
(quote
(wc-mode arduino-mode magithub magit helm cider emacsql-mysql twittering-mode ## yaml-mode starter-kit-ruby starter-kit-js starter-kit-eshell starter-kit-bindings scss-mode scala-mode markdown-preview-mode markdown-preview-eww less-css-mode langtool json-mode json js2-mode es-windows emstar clojure-project-mode)))
'(show-paren-mode t))
You can’t perform that action at this time.