Sharding Mongo惊讶地发现



我正在尝试在蒙哥运行碎片。我运行了此命令:

mongod --rest --shardsvr --port 10000 --dbpath data/localhost10000 --logpath data/localhost10000/log

mongod --rest --port 10002 --dbpath data/localhost10002 --logpath data/localhost10002/log
mongos --port 10003 --configdb localhost:10002 > run_routing_service_log

mongo localhost:10003
use admin
db.runCommand({addshard:"localhost:10000", name:"shard10000"});
db.runCommand({addshard:"localhost:10001", name:"shard10001"});

use test_sharding
sh.enableSharding("test_sharding")
db.people.ensureIndex({"zip": 1})
db.people.insert({"name": "a1", "password": "a1", .... )
sh.status()

我得到了这个错误:

惊讶地发现Localhost:10002不认为它是配置服务器

add -configsvr参数在下面的第二个mongod命令中。

mongod --rest --port 10002 --dbpath data/localhost10002 --logpath data/localhost10002/log

这应该在端口#10002上启动ConfigServer。但是,您可能会遇到与法定人数有关的另一个问题,因为MongoDB官方文档建议3个配置服务员,可以在不同端口上的上述命令开始。

另外,我看不到您已经初始化了MongoDB碎片。这也可能在识别正确的碎片配置时会产生一个问题。以下链接可能会有所帮助。

http://www.mongodbspain.com/en/2015/01/26/how-to-to-set-up-a-mongodb-sharded-cluster/

最新更新