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.

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.

  • 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 May 8 '18 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 May 9 '18 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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