Changing replication factor

Default replication factor for each keyspace in each data center is equal to the number of Cassandra nodes in that data center. You might want to change the default replication factor to increase response times.

About this task

The default replication factor provides a good trade-off between system performance and data availability. If you change the replication factor to increase response times, there is an increased risk that data might not be available. If you decrease the replication factor, data is stored on a reduced number of nodes. This can make data unavailable with a loss of a smaller number of nodes. You can modify the replication factor for each keyspace based on your requirements. The following keyspaces are defined in Global Mailbox:
  • mailbox
  • gatekeeper
  • scheduler
  • event
  • replication

To change replication factor for a keyspace:

Procedure

  1. Log in to the server where a Cassandra node is installed.
  2. Go to the <install_dir>/apache-cassandra/bin directory.
  3. Type ./cqlsh <host name/IP address>. Replace <host name/IP address> with appropriate value for the server where the Cassandra node is installed.
  4. At the cqlsh prompt, type ALTER KEYSPACE <keyspace name> WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', '<data center 1 name>' : <new replication factor>, '<data center 2 name>' : <new replication factor>}; Replace keyspace name, data center 1 name, new replication factor, and data center 2 name with appropriate values.
  5. Repeat the steps for each node, if required.
  6. Run the nodetool repair command on each node where you changed the replication factor.
    Remember: To run nodetool, JAVA_HOME must be set to the location of IBM JDK 8. This path is specified during installation of Global Mailbox.
  7. Wait for the repair to complete.
  8. Repeat the steps to change replication factor for another keyspace.