james
james

Reputation: 275

when i started mongodb db.runCommand...host already used error invoked~

db.runCommand({addshard:"localhost:10000"});
{ "ok" : 0, "errmsg" : "host already used" }
db.runCommand( { addshard : "localhost:10001" } );
{ "ok" : 0, "errmsg" : "host already used" }

how can i solve that problem? it is "host already used" error

please give me a tips to solve this~

Upvotes: 0

Views: 540

Answers (1)

Andrew Orsich
Andrew Orsich

Reputation: 53685

According to mongodb source code this message say that you've already added this specified host:port as a shard:

// 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;
}

You can use listShards command to see your current shards:

db.runCommand( { listshards : 1 } );

Upvotes: 3

Related Questions