how to rename a shard?

320 views
Skip to first unread message

Tomasz Chmielewski

unread,
Dec 6, 2014, 4:02:15 AM12/6/14
to mongod...@googlegroups.com
I have a mongo shard setup which wasn't deployed correctly IMO and is using fixed addresses for shards:

mongos> db.runCommand({listshards:1})
{
        "shards" : [
                {
                        "_id" : "shard0001",
                        "host" : "ec2-aa-bb-cc-dd.compute-1.amazonaws.com:27018"
                },
                {
                        "_id" : "shard0002",
                        "host" : "ec2-bb-cc-dd-ee.compute-1.amazonaws.com:27018"
                },
                {
                        "_id" : "shard0003",
                        "host" : "xx.yy.zz.aa:27018"
(...)

How can I rename the shards, say, to shard0001.example.com, shard0002.example.com etc.?


--
Tomasz Chmielewski
http://www.sslrack.com

Tomasz Chmielewski

unread,
Dec 11, 2014, 5:29:33 PM12/11/14
to mongod...@googlegroups.com
Nobody knows? I'm running mongo 2.6.x if that helps.

Asya Kamsky

unread,
Dec 11, 2014, 9:50:10 PM12/11/14
to mongodb-user
It's this section of the docs:

http://docs.mongodb.org/manual/tutorial/convert-standalone-to-replica-set/#sharding-considerations

Asya
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user"
> group.
>
> For other MongoDB technical support options, see:
> http://www.mongodb.org/about/support/.
> ---
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mongodb-user...@googlegroups.com.
> To post to this group, send email to mongod...@googlegroups.com.
> Visit this group at http://groups.google.com/group/mongodb-user.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mongodb-user/6bc4b5a7-f237-4722-816c-db8295ad820a%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Tomasz Chmielewski

unread,
Dec 12, 2014, 8:13:33 AM12/12/14
to mongod...@googlegroups.com
Cool, thanks.

For reference, for my 3-shard system, I've used something in the line of:

mongos> db.getSiblingDB("config").shards.save( {_id: "shard0001", host: "shard0001.example.com" } )
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })

mongos> db.getSiblingDB("config").shards.save( {_id: "shard0002", host: "shard0002.example.com" } )
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })

mongos> db.getSiblingDB("config").shards.save( {_id: "shard0003", host: "shard0003.example.com" } )
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })


mongos> db.runCommand({listshards:1})
{
        "shards" : [
                {
                        "_id" : "shard0001",
                        "host" : "shard0001.example.com"
                },
                {
                        "_id" : "shard0002",
                        "host" : "shard0002.example.com"
                },
                {
                        "_id" : "shard0003",
                        "host" : "shard0003.example.com"
                }
        ],
        "ok" : 1

}

--
Tomasz Chmielewski
http://www.sslrack.com

Reply all
Reply to author
Forward
0 new messages