Upgrade shard to replica set

119 views
Skip to first unread message

raylu

unread,
Jun 24, 2011, 5:37:53 AM6/24/11
to mongodb-user
How does one upgrade a shard node to a replica set (without draining
the node)? I didn't see anything on http://www.mongodb.org/display/DOCS/Upgrading+to+Replica+Sets
about reconfiguring the configdb.

Related threads:
http://groups.google.com/group/mongodb-user/browse_thread/thread/b69cc7417cce25e3/bb8850cb263f7f86
http://groups.google.com/group/mongodb-user/browse_thread/thread/d0dde3ac8ea5aea4/

Also, a separate but related issue: on a 1.8.2 test cluster, I set up
one stand-alone shard node and one replica set.

The replica set is configured as so:
{
"_id" : "testr",
"version" : 2,
"members" : [
{
"_id" : 0,
"host" : "10.177.193.252:27017"
},
{
"_id" : 1,
"host" : "10.177.215.176:27017"
}
]
}

and the shards:
> db.runCommand( { listshards : 1})
{
"shards" : [
{
"_id" : "shard0000",
"host" : "10.177.193.252:27018",
"maxSize" : NumberLong(1)
},
{
"_id" : "testr",
"host" : "testr/10.177.193.252",
"maxSize" : NumberLong(1)
}
],
"ok" : 1
}

So the stand-alone shard is on the same machine as one of the replica
nodes. I added the replica set to the sharding configuration with the
host of just one of the nodes rather than supplying both.

Now, with .215.176 as the master, I run

testr:PRIMARY> rs.remove("10.177.193.252:27017")

With a mongos connected to my config server and a mongo connected to
that mongos, I still see the same result for listshards, even after
restarting the config server.

Greg Studer

unread,
Jun 24, 2011, 12:25:41 PM6/24/11
to mongod...@googlegroups.com
How does one upgrade a shard node to a replica set (without draining
> the node)? I didn't see anything on
http://www.mongodb.org/display/DOCS/Upgrading+to+Replica+Sets
> about reconfiguring the configdb.
>

The first thread has the info you need - in short, stop mongos, modify
the config server collection "config.shards" (on all config servers)
with the replica set connection strings (i.e.
name/host1:port,host2:port), restart mongos. The doc page is meant for
upgrading single servers to replica sets.

> With a mongos connected to my config server and a mongo connected to
> that mongos, I still see the same result for listshards, even after
> restarting the config server.

Was mongos running when you removed the primary? Also, there have been
some issues reported when not explicitly specifying port #s in conn
strings, like "testr/10.177.193.252", I'd recommend always using port #s
for now.

raylu

unread,
Jun 24, 2011, 2:28:22 PM6/24/11
to mongodb-user
mongos was running when I removed the primary. Should it have been?
If not, is there anything I can do if I change a shard to a replica
set but I accidentally left a mongos running?

What if my original configuration already had hosts added without port
numbers?

-raylu

On Jun 24, 9:25 am, Greg Studer <g...@10gen.com> wrote:
> How does one upgrade a shard node to a replica set (without draining> the node)? I didn't see anything on
>
> http://www.mongodb.org/display/DOCS/Upgrading+to+Replica+Sets
>
> > about reconfiguring the configdb.
>

Greg Studer

unread,
Jun 24, 2011, 4:43:52 PM6/24/11
to mongod...@googlegroups.com
> mongos was running when I removed the primary. Should it have been?

Yes, mongos should have detected this change and updated the config
server data.

There's two levels of changes here - changes to the shards sometimes
require a restart of mongos, but changes to the replica set should not.

I suspect it may be related to the port # thing, but I've opened a JIRA
in any case to look more: https://jira.mongodb.org/browse/SERVER-3333

> If not, is there anything I can do if I change a shard to a replica
> set but I accidentally left a mongos running?

Basically the mongos just caches what's in the config server, so
restarting the mongos will get it up-to-date again. Definitely try to
avoid manually editing the config server with running mongoses though.

> What if my original configuration already had hosts added without port
> numbers?

You can use the same trick as before, just shut down all the mongos
instances, update config.shards, and restart the mongos instances.

On Fri, 2011-06-24 at 11:28 -0700, raylu wrote:

Reply all
Reply to author
Forward
0 new messages