Skip to content

Cassandra Basics

Create keyspace

Bash
CREATE KEYSPACE IF NOT EXISTS somename WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1}  AND durable_writes = true;

or

Bash
CREATE KEYSPACE test1 WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1' : 2};

Increase | Decrease replica set

Bash
ALTER KEYSPACE somename WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };

Drop keyspace

Bash
DROP KEYSPACE some_name;

Check how much replicas keyspaces have

Bash
SELECT * FROM system_schema.keyspaces;

Tips:

In case you change cluster name the following is needed

Bash
cqlsh> UPDATE system.local SET cluster_name = 'test' where key='local';

flush the sstables to persist the update.

Bash
./nodetool flush