Mongodb – Mongos – Query error

mongodb

After we configured six replica set servers and three config servers with mongos. we are not able to see records from mongos server. Kindly have a look my below errors and please suggest to us.

mongos>use test
switched to db test 
mongos> show collections;
2014-12-03T15:11:09.312+0300 error: {
  "$err" : "could not initialize sharding on connection firstset/localhost1:10001,localhost2:10002,localhost3:10003 :: caused by :: mongos specified a different config database string : stored : X.X.X.1:20001 vs given : X.X.X.1:20001,X.X.X.2:20002,X.X.X.3:20003",
  "code" : 15907,
  "shard" : "firstset" 
} at src/mongo/shell/query.js:131 mongos>

Best Answer

You cannot mix and match resolvable and non-resolvable host addresses in your cluster.

When you started your config servers and another mongos, you had told them their hostnames are X.X.X.X (the IP you masked in your error message). You are now trying to start a mongos using localhost for the host name/IP - that is not allowed.

You must use identical configdb string to every mongos every time in a sharded cluster.