Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have this configuration:

mongos> db.adminCommand('getShardMap')
{
"map" : {
    "RS13" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "RS13/mongo09-02:27003,mongo09-01:27001" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "RS26" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002",
    "RS26/mongo09-04.de.prod:27008,mongo09-01:27002" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002",
    "RS45" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "RS45/mongo09-02:27004,mongo09-03:27005" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "RS67" : "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007" : "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "config" : "mongo09-01:27011,mongo09-02:27012,mongo09-03:27013",
    "mongo09-01:27001" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "mongo09-01:27002" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002",
    "mongo09-02:27003" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "mongo09-02:27004" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "mongo09-03.de.prod:27006" : "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "mongo09-03:27005" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "mongo09-03:27006" : "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "mongo09-04.de.prod:27007" : "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "mongo09-04.de.prod:27008" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002"
},
"ok" : 1
}

Actually mongo09-03 it seems to be duplicated:

    "mongo09-03.de.prod:27006" : "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "mongo09-03:27006" : "RS67/mongo09-03:27006,mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",

And please consider replica set RS67 is also part of a sharding cluster.

May I remove a mongodb replica set when it is into a sharding cluster ? And if yes, how?

Can I use rs.remove(hostname) ?

share|improve this question

2 Answers 2

It isn't an easy run one command type thing. See the following on the doc site

http://docs.mongodb.org/manual/tutorial/remove-shards-from-cluster/

To remove a replicaset member

 rs.remove("mongo09-03.de.prod:27006")
share|improve this answer
    
Thanks Mike, I would like to know if I can remove only one host from the replica sets leaving the sharding cluster alive –  freedev Mar 27 '13 at 1:21
    
yes you can do that. As since there are at least 2 nodes + arbiter in the replicaset.. at least one will contain the data. Then it is as simple as a single command –  Mike Mar 27 '13 at 1:25
    
Do you know which command? Could we use db.shards.update({_id: "RS67"} , {$set: {"host" : "RS67/mongo09-03.de.prod:27006,mongo09-04.de.prod:27007"}}) ? –  freedev Mar 27 '13 at 1:27
    
I updated my answer –  Mike Mar 27 '13 at 1:43
    
Thanks Mike, actually waiting I have successfully tried with db.shards.update.... Anyway +1 thanks for your support :) –  freedev Mar 27 '13 at 1:53

We have successfully configured the replica set executing this command:

db.shards.update({_id: "RS67"} , {$set: {"host" : "RS67/mongo09-03.de.prod:27006,mongo09-04.de.prod:27007"}})

The shard map now it is correctly configured and extra mongo09-03 has been disappeared.

mongos> db.adminCommand('getShardMap') 
{
"map" : {
    "RS13" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "RS13/mongo09-02:27003,mongo09-01:27001" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "RS26" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002",
    "RS26/mongo09-04.de.prod:27008,mongo09-01:27002" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002",
    "RS45" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "RS45/mongo09-02:27004,mongo09-03:27005" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "RS67" : "RS67/mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "RS67/mongo09-03.de.prod:27006,mongo09-04.de.prod:27007" : "RS67/mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "config" : "mongo09-01:27011,mongo09-02:27012,mongo09-03:27013",
    "mongo09-01:27001" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "mongo09-01:27002" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002",
    "mongo09-02:27003" : "RS13/mongo09-02:27003,mongo09-01:27001",
    "mongo09-02:27004" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "mongo09-03.de.prod:27006" : "RS67/mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "mongo09-03:27005" : "RS45/mongo09-02:27004,mongo09-03:27005",
    "mongo09-04.de.prod:27007" : "RS67/mongo09-03.de.prod:27006,mongo09-04.de.prod:27007",
    "mongo09-04.de.prod:27008" : "RS26/mongo09-04.de.prod:27008,mongo09-01:27002"
},
"ok" : 1
}

please also consider that:

The list of hosts in the collection is only used when mongos first starts up, as a seed list. Once the process starts they auto-discover the rest of the members (just like any other client/driver in replica set mode) and keep track of each member in the replica set.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.