2

I need to set up a mongodb cluster with redundant private networks connecting all the nodes. Mongo's documentation states:

... you should place each mongod instance on a separate host server serviced by redundant power circuits and redundant network paths.

https://docs.mongodb.com/manual/tutorial/deploy-replica-set/

I am able to make mongod listen on multiple nics using the --bind_ip parameter, which I set to:

--bind_ip localhost,10.1.1.101,10.1.2.101

But then when doing rs.initiate()/rs.reconfig()/rs.add() I see no way to specify multiple IP addresses for the members[n].host fields. I tried multiple values separated with a comma:

> rs.initiate({ _id : 'rs', version : 1, members : [{ _id : 0, host : '10.1.1.101:27107,10.1.2.101:27017' } ] })
{
    "ok" : 0,
    "errmsg" : "FailedToParse: More than one ':' detected. If this is an ipv6 address, it needs to be surrounded by '[' and ']'; 10.1.1.101:27107,10.1.2.101:27017 for member:{ _id: 0.0, host: \"10.1.1.101:27107,10.1.2.101:27017\" }",
    "code" : 93,
    "codeName" : "InvalidReplicaSetConfig"
}

I tried making host an array:

> rs.initiate({ _id : 'rs', version : 1, members : [{ _id : 0, host : [ '10.1.1.101:27107', '10.1.2.101:27017'] } ] })
{
    "ok" : 0,
    "errmsg" : "TypeMismatch: \"host\" had the wrong type. Expected string, found array for member:{ _id: 0.0, host: [ \"10.1.1.101:27107\", \"10.1.2.101:27017\" ] }",
    "code" : 93,
    "codeName" : "InvalidReplicaSetConfig"
}

I tried specifying host multiple times, which mongo accepted, but it only used the last host specified.

> rs.initiate({ _id : 'rs0', version : 1, members : [{ _id : 0, host : '10.1.1.101:27107', host: '10.1.2.101:27017' } ] })
{ "ok" : 1 }

All this is just getting the first node set up. I had similar issues when adding nodes 2 and 3 with rs.add() and rs.reconfig().

Any help would be much appreciated.

2 Answers 2

1

Yes, you can have mongod at multiple networks, but when you configure replica set, you use only addresses of one network. Like network 10.1.1.x addresses. To clients you can give list of addresses from 10.1.2.x network, if that is preferred.

Those addresses what you configure with --bindip are addresses where mongod answers connection attempts.

2
  • This does not work. If the network used to configure the replica set fails, then mongod is unable to communicate with the other nodes. There needs to be a way to specify BOTH networks in the replica set configuration.
    – Ed Tyrrill
    Commented May 8, 2018 at 20:06
  • 1
    That's impossible. You must do network redundancy at HW level, bonding multiple network devices, with the connection to multiple switches.
    – JJussi
    Commented May 9, 2018 at 7:03
0

Did get any solution for this issue? I have same problem with redundant networks. I try to add multiple members to config setting. But i got the this message. "all map to this node in new configuration with~~"

Please give your advices. Thanks.

1
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. Commented Oct 21, 2022 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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