![](/img/trans.png)
[英]Does mongoDB supports sharding and replicaset on hybrid env (IBM8 and Intel server )
[英]Sharding in a replicaset MongoDB
我有mongoDb副本集,一个主要的中学和一名仲裁员进行投票。 我计划实现分片,因为预计数据将呈指数增长。我很难遵循mongoDb文档进行分片。 有人可以清楚地说明它进行设置。 提前致谢。
如果可以完成副本集,则分片非常简单。 在这里快速重复了mongo文档:
下面是一个示例设置:3 configDB和3个分片对于下面的示例,您可以在一台机器上运行所有configDB以查看其是否正常运行。
#start mongos with three configs: mongos --port 27023 --configdb localhost:27017,localhost:27018,localhost:27019 mongos> sh.addShard("127.0.0.1:27000"); { "shardAdded" : "shard0000", "ok" : 1 } mongos> sh.addShard("127.0.0.1:37000"); { "shardAdded" : "shard0001", "ok" : 1 } mongos> sh.addShard("127.0.0.1:47000"); { "shardAdded" : "shard0002", "ok" : 1 } mongos> sh.enableSharding("db_to_shard"); { "ok" : 1 } mongos> use db_to_shard; switched to db db_to_shard mongos> mongos> sh.shardCollection("db_to_shard.coll_to_shard", {collId: 1, createdDate: 1} ); { "collectionsharded" : "db_to_shard.coll_to_shard", "ok" : 1 } mongos> show databases; admin (empty) config 0.063GB db_to_shard 0.078GB mongos> sh.status(); --- Sharding Status --- sharding version: { "_id" : 1, "minCompatibleVersion" : 5, "currentVersion" : 6, "clusterId" : ObjectId("557003eb4a4e61bb2ea0555b") } shards: { "_id" : "shard0000", "host" : "127.0.0.1:27000" } { "_id" : "shard0001", "host" : "127.0.0.1:37000" } { "_id" : "shard0002", "host" : "127.0.0.1:47000" } balancer: Currently enabled: yes Currently running: no Failed balancer rounds in last 5 attempts: 0 Migration Results for the last 24 hours: No recent migrations databases: { "_id" : "admin", "partitioned" : false, "primary" : "config" } { "_id" : "test", "partitioned" : false, "primary" : "shard0000" } { "_id" : "db_to_shard", "partitioned" : true, "primary" : "shard0000" } db_to_shard.coll_to_shard shard key: { "collId" : 1, "createdDate" : 1 } chunks: shard0000 1 { "collId" : { "$minKey" : 1 }, "createdDate" : { "$minKey" : 1 } } -->> { "collId" : { "$maxKey" : 1 }, "createdDate" : { "$maxKey" : 1 } } on : shard0000 Timestamp(1, 0)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.