Create keyspace and column family
Now, let's create our keyspace and a column family using the cqlsh
client. Run the command cqlsh
, then you should be on the cqlsh
prompt. On the cqlsh
prompt, run the keyspace creation command as follows:
cqlsh> CREATE KEYSPACE cassandrademodb WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
Here, we created a keyspace named cassandrademodb
. We chose the replication factor as 3
, so each data row we'll be creating will be stored on three nodes. Since, for now we're running our cluster on only one cluster, we chose the replication strategy as SimpleStrategy
.
Now, create one column family called users
in this keyspace. Here, we'll use username column as the partition key. Using the cqlsh ...
Get Apache Cassandra Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.