I need to do sharding without shutdown or restart the existing mongo instance in the port 27017 .
I tried the following, (while the default port is running and mongo instance)
mongod --shardsvr --dbpath /var/lib/mongodb/dba --port 10001 > /var/log/mongodb/shardlog/sharda.log &
mongod --shardsvr --dbpath /var/lib/mongodb/dbb --port 10002 > /var/log/mongodb/shardlog/shardb.log &
mongod --configsvr --dbpath /var/lib/mongodb/config --port 20000 > /var/log/mongodb/shardlog/configdb.log &
mongos --configdb localhost:20000 > /var/log/mongodb/shardlog/mongos.log &
Then mongos log giving an error,
Thu Aug 23 14:44:36 [mongosMain] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017 Thu Aug 23 14:44:36 [mongosMain] ERROR: addr already in use
mongos is running on port 20000 but why It’s trying to connect the default 27017 port?
Can I start mongos with several shards without disturbing the existing mongo instance on port 27017 ?
From the the list of commands you have given, it looks like you have not told the
mongosto start on a different port than default.You would need to supply the
--portargument formongosto start on a different port.Try:
mongos --configdb localhost:20000 --port 10003Note:
mongosis not running on port 20000 as you have said above. You have the config server running on that port