replication factor:副本因子
查看各个 KeySpace 的 rf:
SELECT * FROM system_schema.keyspaces;
修改:https://docs.datastax.com/en/cql-oss/3.3/cql/cql_using/useUpdateKeyspaceRF.html
-- 使用 NetworkTopologyStrategy
ALTER KEYSPACE system_auth WITH REPLICATION =
{'class' : 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2' : 2};
-- 使用 SimpleStrategy,并指定 rf
ALTER KEYSPACE "Excalibur" WITH REPLICATION =
{ 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
Procedure
- 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};
- Or if using SimpleStrategy:
cqlsh> ALTER KEYSPACE “Excalibur” WITH REPLICATION =
{ ‘class’ : ‘SimpleStrategy’, ‘replication_factor’ : 3 };
- Note: Datacenter names are case sensitive. Verify the case of the using utility, such as
nodetool status
. - On each affected node, run
nodetool repair
with the-full
option. - 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:
nodetoll repair -full