Creating a keyspace
Add a keyspace and set the replication factor.
A keyspace is analogous to an SQL database. The keyspace is the top level container
for database objects. The keyspace replication strategy and replication factor
control data availability for a set of tables in each datacenter of the cluster.
- SimpleStrategy: Applies the same replication setting across the cluster. Only use this setting on single node test or development environments.
- NetworkTopography: Applies the replication setting per datacenter. Use in production environments.
- EverywhereStrategy: The default replication strategy for the
dse_system
andsolr_admin
keyspaces. Do not use or alter any instances of EverywhereStrategy.
Procedure
-
Verify the datacenter name using
nodetool status
.nodetool status
The output is:
Datacenter: datacenter1 ================ Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns Host ID Rack UN 10.200.181.134 4.97 MiB 1 ? c9027497-011c-4390-ae59-e4ed1ac794cc rack1 UN 10.200.181.135 5.16 MiB 1 ? af2af8ec-5fa2-4a04-ac9c-c75669d8d3a0 rack1
- Verify the datacenter names, which are case-sensitive. Ensure that the datacenter name case matches exactly in the next step.
-
Start cqlsh and create a keyspace.
CREATE KEYSPACE IF NOT EXISTS cycling WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 3};
-
Switch to the keyspace.
USE cycling;