Multi-data center example

The following example will create the packt_ch3b keyspace, as long as it does not already exist. When a write occurs, two replicas will be written to the ClockworkAngels data center, and three will be written to the PermanentWaves and MovingPictures data centers. Writes will also be sent to the commit log for extra durability:

CREATE KEYSPACE packt_ch3_mdc WITH replication = {'class': 'NetworkTopologyStrategy',  'ClockworkAngels':'2', 'MovingPictures':'3', 'PermanentWaves':'3'} AND durable_writes = true;

Once you have created your keyspace, you can use it to avoid having to keep typing it later. Notice that this will also change your Command Prompt:

cassdba@cqlsh> use packt_ch3 ;cassdba@cqlsh:packt_ch3>

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.