keyspace有两种策略,一个是 SimpleStrategy
,另一个是 NetworkTopologyStrategy
SimpleStrategy
该模式下需要指定复制策略,冗余几份数据,如:
create KEYSPACE demodb WITH replication = {‘class‘: ‘SimpleStrategy‘, ‘replication_factor‘: 2};
NetworkTopologyStrategy
该模式是基于数据中心-机架的,创建基于此模式的KEYSPACE必须在配置文件中配置成该模式,否则将会报异常:
Unable to complete request: one or more nodes were unavailable
创建代码如下:
CREATE KEYSPACE demodb WITH REPLICATION = { ‘class‘ : ‘NetworkTopologyStrategy‘, ‘dc1‘ :3 };
2、创建colum family
时间: 2024-11-04 14:31:34