This shows you the differences between two versions of the page.
— | cassandra [2018/06/19 10:15] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Cassandra / ScyllaDB Basics ====== | ||
+ | **CLUSTER -> KEYSPACE -> TABLE -> DATA**\\ | ||
+ | Minimum number of running nodes are 2 (otherwise writes are not possible), so **3 or more nodes total** is absolutely minimal deployment. | ||
+ | " | ||
+ | |||
+ | ====== Data Keys ====== | ||
+ | < | ||
+ | PRIMARY KEY (a): The partition key is a. | ||
+ | PRIMARY KEY (a, b): The partition key is a, the clustering key is b. | ||
+ | PRIMARY KEY ((a, b)): The composite partition key is (a, b). | ||
+ | PRIMARY KEY (a, b, c): The partition key is a, the composite clustering key is (b, c). | ||
+ | PRIMARY KEY ((a, b), c): The composite partition key is (a, b), the clustering key is c. | ||
+ | PRIMARY KEY ((a, b), c, d): The composite partition key is (a, b), the composite clustering key is (c, d). | ||
+ | </ | ||
+ | |||
+ | In a situation of COMPOSITE primary key, the " | ||
+ | |||
+ | * The Partition Key is responsible for data distribution across your nodes. | ||
+ | * The Clustering Key is responsible for data sorting within the partition. | ||
+ | * The Primary Key is equivalent to the Partition Key in a single-field-key table (i.e. Simple). | ||
+ | * The Composite/ | ||
+ | |||
+ | ====== Aprox. recommended capacity ====== | ||
+ | 5TB on one node\\ | ||
+ | commitlog file on another disk | ||
+ | |||
+ | ====== Shell ====== | ||
+ | < | ||
+ | |||
+ | ====== Create Keyspace ====== | ||
+ | < | ||
+ | CREATE KEYSPACE Excelsior | ||
+ | WITH replication = {' | ||
+ | |||
+ | CREATE KEYSPACE Excalibur | ||
+ | WITH replication = {' | ||
+ | AND durable_writes = false; | ||
+ | </ | ||
+ | |||
+ | ====== Change number of replicas ====== | ||
+ | < | ||
+ | WITH replication = {' | ||
+ | |||
+ | ====== Describe Keyspaces ====== | ||
+ | < | ||
+ | |||
+ | ====== How to list all the tables ====== | ||
+ | < | ||
+ | describe tables;</ | ||
+ | |||
+ | ====== Info about table ====== | ||
+ | < | ||
+ | describe table {table_name};</ | ||
+ | |||
+ | ====== Create Table ====== | ||
+ | < | ||
+ | CREATE TABLE positions ( | ||
+ | bucket int, | ||
+ | idSap ascii, | ||
+ | kodSlozka ascii, | ||
+ | VolaciZnak varchar, | ||
+ | CasAktualizace int, | ||
+ | rychlost int, | ||
+ | lat double, | ||
+ | lon double, | ||
+ | PRIMARY KEY (bucket, | ||
+ | ) WITH CLUSTERING ORDER BY (CasAktualizace ASC, idSap ASC); | ||
+ | </ | ||
+ | bucket = year + week | ||
+ | ====== Create Secondary Index ====== | ||
+ | < | ||
+ | CREATE INDEX idSap ON nis.positions (idSap); | ||
+ | </ | ||
+ | experimental: | ||
+ | |||
+ | ====== WSO2 EI ====== | ||
+ | Turn off consistency check | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | <data enableBatchRequests=" | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | <result element=" | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | <result element=" | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | <param name=" | ||
+ | <param name=" | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | <param name=" | ||
+ | <param name=" | ||
+ | <param name=" | ||
+ | <param name=" | ||
+ | <param name=" | ||
+ | <param name=" | ||
+ | <param name=" | ||
+ | <param name=" | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ====== Number of Rows ====== | ||
+ | < | ||
+ | SELECT COUNT(1) FROM table; | ||
+ | </ | ||
+ | |||
+ | ====== Convert time to timestamp ====== | ||
+ | < | ||
+ | |||
+ | ====== Send data ====== | ||
+ | < | ||
+ | |||
+ | |||
+ | ====== Export CSV ====== | ||
+ | |||
+ | |||
+ | < | ||
+ | |||
+ | < |