Open FS1360472174 opened 7 years ago
1.mongo 支持查询不提供shard key的值,这点与cassandra不同
2.compound shard key 可以只指定一个shard key
sh.shardCollection("school.courses",{"classId":1,"userId":1})
这个会创建一个compound index.
多datacenter的配置, write concern such as writing to at least two replica set members in one data center and at least one replica in a second data center.
read concern 可以使用near-geo选择低延迟的数据去读取节点,而不是始终去读主节点,或者使用 tag路由到特定的节点 The nearest read option allows the client to read from the lowest-latency members of a replica set, rather than always reading from the primary. This is typically used to route queries to a local data center, reducing the effects of geographic latency. Tags can also be used to ensure that reads are always routed to a specific node or subset of nodes
问题有个compound shard key a+b a:a1-a10 b:b1-b100000
a1,b1, a1,b2 a1,b3.. 这些都是一个range?,都到一个shard去了
hash 方式分片只能是一个field
1.在database这层 sh.enableSharding("school") 2.shardkey sh.shardCollection("school.courses",{userId:"hashed"})
Pattern must either be a single hashed field, or a list of ascending fields." sh.shardCollection("school.courses",{userId:"hashed",school:1})