Single data center example

The following example will create the packt_ch3 keyspace. When a write occurs, one replica will be written to the cluster. Writes will also be sent to the commit log for extra durability:

CREATE KEYSPACE IF NOT EXISTS packt_ch3 WITH replication = {'class': 'NetworkTopologyStrategy', 'ClockworkAngels':'1'} AND durable_writes = true;
SimpleStrategy isn't very useful, so my advice is not to use it. It's a good idea to get into the habit of using NetworkTopologyStrategy, as that's the one that should be used in production. SimpleStrategy offers no advantages over NetworkTopologyStrategy, and using SimpleStrategy can complicate converting into a multi-data center environment later.

Get Mastering Apache Cassandra 3.x - Third Edition 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.