replication factor:副本因子

查看各个 KeySpace 的 rf:

  1. SELECT * FROM system_schema.keyspaces;

修改:https://docs.datastax.com/en/cql-oss/3.3/cql/cql_using/useUpdateKeyspaceRF.html

  1. -- 使用 NetworkTopologyStrategy
  2. ALTER KEYSPACE system_auth WITH REPLICATION =
  3. {'class' : 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2' : 2};
  4. -- 使用 SimpleStrategy,并指定 rf
  5. ALTER KEYSPACE "Excalibur" WITH REPLICATION =
  6. { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };

Procedure

  1. Update a keyspace in the cluster and change its replication strategy options.

cqlsh> ALTER KEYSPACE system_auth WITH REPLICATION =
{‘class’ : ‘NetworkTopologyStrategy’, ‘dc1’ : 3, ‘dc2’ : 2};

  1. Or if using SimpleStrategy:

cqlsh> ALTER KEYSPACE “Excalibur” WITH REPLICATION =
{ ‘class’ : ‘SimpleStrategy’, ‘replication_factor’ : 3 };

  1. Note: Datacenter names are case sensitive. Verify the case of the using utility, such as nodetool status.
  2. On each affected node, run nodetool repair with the -full option.
  3. Wait until repair completes on a node, then move to the next node.For more about replication strategy options, see Changing keyspace replication strategy

Repairing nodes:

https://docs.datastax.com/en/archived/cassandra/3.0/cassandra/operations/opsRepairNodesTOC.html
修复数据不一致

Read Repair:

https://docs.datastax.com/en/archived/cassandra/3.0/cassandra/operations/opsRepairNodesReadRepair.html

  1. nodetoll repair -full

image.png