Asked:2020-09-20 04:53:31 +0000 UTC2020-09-20 04:53:31 +0000 UTC2020-09-20 04:53:31 +0000 UTC
运行 mongos 会抛出错误
772
启动mongos时,
mongos --configdb localhost:47040抛出错误:BadValue: configdb support only replica set connection string try 'mongos --help' for more information
mkdir sh1, sh2, conf1, conf2
mongod.exe --shardsvr --dbpath C:\data\sh1 --bind_ip localhost --port 27000
mongod.exe --shardsvr --dbpath C:\data\sh2 --bind_ip localhost --port 27001
3.让我们提出2个配置服务器:
mongod.exe --configsvr --replSet configrs --dbpath C:\data\conf1 --bind_ip localhost --port 27002
mongod.exe --configsvr --replSet configrs --dbpath C:\data\conf2 --bind_ip localhost --port 27003
让我们连接到一台配置服务器:
mongo.exe localhost:27002
设置副本
rs.initiate( { _id: "configrs", members: [ { _id : 0, host : "localhost:27002" }, { _id : 1, host : "localhost:27003" } ] } )
让我们提升 mongos 切换服务器:
mongos.exe --configdb configrs/localhost:27002 --bind_ip localhost --port 27004
连接到交换机服务器:
mongo.exe localhost:27004
我们注册分片:
sh.addShard("localhost:27000")
sh.addShard("localhost:27001")
要检查,请输入命令:
db.printShardingStatus()