Herberth Amaral
Herberth Amaral

Reputation: 3539

MongoDB - Adding new config servers in production

I've been doing some tests with mongodb and sharding and at some point I tried to add new config servers to my mongos router (at that time, I was playing with just one config server). But I couldn't find any information on how to do this.

Have anybody tried to do such a thing?

Upvotes: 2

Views: 6886

Answers (3)

Tilo
Tilo

Reputation: 33732

Use DNS CNAMES

make sure to use DNS entries or at least /etc/hosts entries for all mongod and mongo config servers when you set-up multiple config servers in /etc/mongos.conf , when you set-up replica sets and/or sharding.

e.g. a common pitfall on AWS is to use just the private DNS name of EC2 instances, but these can change over time... and when that happens you'll need to shut down your entire mongodb system, which can be extremely painful to do if it's in production.

Upvotes: 2

lemon
lemon

Reputation: 66

Unfortunately you will need to shutdown the entire system.

Shutdown all processes (mongod, mongos, config server).

Copy the data subdirectories (dbpath tree) from the config server to the new config servers.

Start the config servers.

Restart mongos processes with the new --configdb parameter.

Restart mongod processes.

From: http://www.mongodb.org/display/DOCS/Changing+Config+Servers

Upvotes: 5

gWaldo
gWaldo

Reputation: 442

The Configure Sharding and Sample Configuration Session pages appear to have what you're looking for.

You must have either 1 or 3 config servers; anything else will not work as expected.

You need to dump and restore content from your original config server to 2 new config servers before adding them to mongos's --configdb.

The relevant section is:

Now you need a configuration server and mongos:

`$ mkdir /data/db/config

$ ./mongod --configsvr --dbpath /data/db/config --port 20000 > /tmp/configdb.log &

$ cat /tmp/configdb.log

$ ./mongos --configdb localhost:20000 > /tmp/mongos.log &

$ cat /tmp/mongos.log `

mongos does not require a data directory, it gets its information from the config server.

Upvotes: 1

Related Questions