Modifying the replication factor

Modifying the replication factor either increases or decreases the total number of copies of keyspace data stored in a cluster.

Modifying the replication factor either increases or decreases the total number of copies of keyspace data stored in a cluster. See Data replication.

Changing the replication factor of a keyspace impacts each node that the keyspace replicates to (or no longer replicates to). Follow this procedure to prepare all affected nodes for this change.

Note: 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 named datacenter1.

Procedure

  1. Update a keyspace in the cluster and change its replication strategy options to either increase or decrease the replication factor.
    ALTER KEYSPACE keyspace_name 
    WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'dc_name_1' : 3, 'dc_name_2' : 2};

    Or if using SimpleStrategy:

    ALTER KEYSPACE keyspace_name 
    WITH REPLICATION =  { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
    Note: Datacenter names are case sensitive. Verify the case of the using utility, such as dsetool status.
    See Changing keyspace replication strategy.
  2. Run a full repair of the keyspace when adding datacenters. .
    nodetool repair --full keyspace_name