Changing hosts in shard

104 views
Skip to first unread message

Andrew Rollins

unread,
Mar 8, 2011, 10:11:38 PM3/8/11
to mongod...@googlegroups.com
I have a shard with nodes A1 and A2 from a replica set. I added this
shard using:

db.runCommand( { addshard : "replicaSetA/A1:27017,A2:27017" } );

Now I want to replace A2 with a different replica that has a different
host name, A3. What command do I run to take A2 out of the host list
for the shard and replace it with A3 (assuming I've already added it
to the replica set)?

If it helps, A1 is the current replica set master and I'm running 1.6.5.

Scott Hernandez

unread,
Mar 8, 2011, 10:31:54 PM3/8/11
to mongod...@googlegroups.com
If you just want to add another replica and remove the current master
I would suggest just doing that. The mongos should pickup the change
automatically in the replicaset membership (or after a restart if you
see any problems).

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

Andrew Rollins

unread,
Mar 8, 2011, 10:54:10 PM3/8/11
to mongod...@googlegroups.com, Scott Hernandez
On Tue, Mar 8, 2011 at 10:31 PM, Scott Hernandez
<scotthe...@gmail.com> wrote:
> If you just want to add another replica and remove the current master
> I would suggest just doing that. The mongos should pickup the change
> automatically in the replicaset membership (or after a restart if you
> see any problems).

This doesn't quite answer my question.

I know mongos will pick up the new replica (and all others) so long as
one replica node is listed as a seed for the shard. But what if the
hostname of the seeds change? So for example, to make my question even
more direct, what if I need to change the hostname of A1 and A2?

To be explicit, suppose my list shards says:

http://pastie.org/private/njv5rpwdpaiwa2rl6la4g

but I want to change the shard1 entry and replace the hosts with
different nodes so that it looks like this:

http://pastie.org/private/xosjjt96hk4wn0hddcauq

Can this be accomplished?

- Andrew

Andrew Armstrong

unread,
Mar 8, 2011, 11:59:39 PM3/8/11
to mongodb-user
Hi Andrew,

I don't see a command on how to change the _seed list_ for a shard on
http://www.mongodb.org/display/DOCS/Configuring+Sharding so I am at a
loss too.

I'd imagine you would want to remove the old replica set member (while
ignoring anything to do with sharding), add the new one.

I think shard config information is kept in the mongo config servers,
so you may need to edit a few documents there manually - but I'd wait
for someone official to drop by and indicate what's best to do first,
I wouldn't want to break something :)

Regards,
Andrew

On Mar 9, 2:54 pm, Andrew Rollins <and...@localytics.com> wrote:
> On Tue, Mar 8, 2011 at 10:31 PM, Scott Hernandez
>

Eliot Horowitz

unread,
Mar 9, 2011, 12:05:28 AM3/9/11
to mongod...@googlegroups.com
In 1.8 this is all handled automatically.
If you just update the replica set, then the config server will get
updated automatically with all the new nodes.

Andrew Rollins

unread,
Mar 9, 2011, 2:18:54 AM3/9/11
to mongod...@googlegroups.com, Eliot Horowitz
On Wed, Mar 9, 2011 at 12:05 AM, Eliot Horowitz <elioth...@gmail.com> wrote:
> In 1.8 this is all handled automatically.
> If you just update the replica set, then the config server will get
> updated automatically with all the new nodes.

Thanks for the heads up about 1.8.

In the mean time for 1.6.5, can I just change the relevant doc in the
shards collection in the config db? In local testing this seems to
work.

Eliot Horowitz

unread,
Mar 9, 2011, 2:22:16 AM3/9/11
to mongod...@googlegroups.com
Changing manually requires restarting mongos as well as the shard itself.
So you can/should do it if needed, but not too much.

Andrew Rollins

unread,
Mar 9, 2011, 3:36:54 AM3/9/11
to mongod...@googlegroups.com, Eliot Horowitz
Just to make sure I understand this completely, by "restarting" the
shard, you mean restart all mongod instances in the replica set that
makes up the shard?

What's the reason for restarting the shard? Isn't the shard oblivious
of the higher level cluster config?

Eliot Horowitz

unread,
Mar 9, 2011, 10:32:19 AM3/9/11
to mongod...@googlegroups.com
Correct.
No, its not actually oblivious at all, its just all automatically
configured at run time.
The way seed lists are handled in 1.6 is problematic, so in 1.8 it was
overhauled to be much smoother.
Reply all
Reply to author
Forward
0 new messages