Skip to content

Cassandra Basics

Create keyspace

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

or

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

Increase | Decrease replica set

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

Drop keyspace

DROP KEYSPACE some_name;

Check how much replicas keyspaces have

SELECT * FROM system_schema.keyspaces;

Tips:

In case you change cluster name the following is needed

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

flush the sstables to persist the update.

./nodetool flush