Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb reconfigure shard ports

I have restarted 2 shards on non standard ports, by chaning their .conf files. Now when I connect via mongo and issue a listshards I get:

mongos> db.runCommand( { listshards : 1 } );
Tue Oct 23 17:36:21 uncaught exception: error {
    "$err" : "error creating initial database config information :: caused by :: socket exception [CONNECT_ERROR] for vserver-dev-2:37017",
    "code" : 11002
}

(37017 is the old port). How can I update the shard ports on the router (mongos) ?

like image 398
sivann Avatar asked Oct 23 '12 14:10

sivann


People also ask

Can MongoDB be Sharded?

Sharding is the process of distributing data across multiple hosts. In MongoDB, sharding is achieved by splitting large data sets into small data sets across multiple MongoDB instances.

What is a routing service for MongoDB shard configuration?

MongoDB mongos instances route queries and write operations to shards in a sharded cluster. mongos provide the only interface to a sharded cluster from the perspective of applications.

How do I connect to Sharded cluster?

To connect to a sharded cluster, specify the mongos instance or instances in the URI connection string. In the following example, the connection string specifies the mongos instances running on localhost:50000 and localhost:50001 and the database to access ( myproject ). var MongoClient = require('mongodb').


1 Answers

Manual updating the ports on the mongo config server:

    mongo
    use config

    configsvr> db.shards.update({_id: "shard0000"} , {$set: {"host" : "vserver-dev-2:37018"}})
    configsvr> db.shards.find()
    { "_id" : "shard0000", "host" : "vserver-dev-2:37018" }
like image 163
sivann Avatar answered Sep 30 '22 14:09

sivann