分布式 - 通过JAVA代码是否能够判断MongoDB集群的某个表设置了分片?
巴扎黑
巴扎黑 2017-04-18 10:52:04
0
1
596

通过JAVA代码是否能够判断MongoDB集群的某个表设置了分片?

巴扎黑
巴扎黑

reply all(1)
大家讲道理

You can retrieve the config collections. The collections in each document in the collections are sharded; you can also learn the specific situation of the sharding of the collection. 说着有点拗口

The following example is one of the collections given in the official documentation:

{
   "_id" : "records.pets",                             --Database name.Collection name
   "lastmod" : ISODate("1970-01-16T15:00:58.107Z"),
   "dropped" : false,
   "key" : {
         "a" : 1                                       --Shard key
   },
   "unique" : false,
   "lastmodEpoch" : ObjectId("5078407bd58b175c5c225fdc")
}

Use Java code to retrieve the above collection to get the required sharding information.

For reference.

Love MongoDB! Have Fun!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!