Alter a keyspace

Either the strategy class or replication factor of a keyspace can be modified.

To change a simple replication factor, either increase or decrease the value to change the total number of copies of keyspace data stored in a cluster. Changing the replication factor of a keyspace impacts each node that the keyspace replicates to (or no longer replicates to), and data will require time to redistribute.

The most common replication strategy modification is to switch the strategy class from SimpleStrategy to NetworkTopologyStrategy (NTS). When the NetworkTopologyStrategy class is set, the replication_factor must be modified to specify one or more datacenters.

Altering the distribution of nodes within multiple datacenters when data is present should be accomplished by adding a datacenter. Then add data to the new nodes in the new datacenter and remove nodes from the old datacenter.

Follow this procedure to prepare all affected nodes for this change.

You cannot insert data into a table in a keyspace that uses NetworkTopologyStrategy unless you define the datacenter names in the snitch properties file or you use a single datacenter that is named when the keyspace was created.

See Data replication for more information.


  • A keyspace must exist.

Change simple replication_factor value

Use the ALTER KEYSPACE CQL command to change the value of a keyspace using the SimpleStrategy class:

  'class' : 'NetworkTopologyStrategy',
  'SearchAnalytics' : 1

Now, a datacenter must be named, and not just a replication factor.

Change the replication strategy and the replication_factor values

Update a keyspace in the cluster and change its replication strategy options to either increase or decrease the replication factor.

    'class' : 'NetworkTopologyStrategy', 
    'DC1' : 3, 
    'DC2' : 2

Verify the case of the datacenter name before using this command, as datacenter names are case-sensitive.

Run full repair, if required

Run a full repair of the keyspace if you add datacenters.

nodetool repair --full cycling

Related information:

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000,