db.runCommand({addshard:"localhost:10000"});
{ "ok" : 0, "errmsg" : "host already used" }
db.runCommand( { addshard : "localhost:10001" } );
{ "ok" : 0, "errmsg" : "host already used" }
我该如何解决这个问题?它是“主机已使用”错误
请给我一个解决这个问题的提示〜
答案 0 :(得分:3)
根据mongodb source code,此消息表示您已将此指定的host:port添加为分片:
// check whether this host:port is not an already a known shard
BSONObj old = conn->findOne( ShardNS::shard , BSON( "host" << host ) );
if ( ! old.isEmpty() ){
*errMsg = "host already used";
conn.done();
return false;
}
您可以使用listShards
命令查看当前的分片:
db.runCommand( { listshards : 1 } );