MongoDB Documentation, Release 3.0.4 conf = rs.conf() conf.members[0].tags = { "dc.va": "rack1"} conf.members[1].tags = { "dc.va": "rack2"} conf.members[2].tags = { "dc.gto": "rack1"} conf.members[3].tags = { "dc.gto": "rack2"} conf.members[4].tags = { "dc.va": "rack1"} rs.reconfig(conf) conf.settings = { getLastErrorModes: { MultipleDC : { "dc.va": 1, "dc.gto": 1 } } } rs.reconfig(conf) conf = rs.conf() rs.reconfig(conf) conf.settings = { getLastErrorModes: { MultipleDC : { "dc.va": 2, "dc.gto": 2}} db.users.insert( { id: "xyz", status: "A" }, { writeConcern: { w: "MultipleDC" } } ) 637 9.3. Replica Set Tutorials 20 Since read preferences and write concerns use the value of fields in tag sets differently, larger deployments may have some redundancy. Where each member of the set has a tag set that resembles one of the following: 20 Given a replica set with tag sets that reflect: Now, the following write operation will only return after the write operation propagates to at least two different racks in the each facility: Changed in version 2.6: A new protocol for write operations (page 852) integrates write concerns with the write operations. Previous versions used the getLastError command to specify the write concerns. Alternatively, if you want to ensure that each write operation propagates to at least 2 racks in each facility, reconfigure the replica set as follows in the mongo shell: 2. Add tags to the replica set members reflecting their locations: 3. Create a custom getLastErrorModes setting to ensure that the write operation will propagate to at least one member of each facility: 4. Reconfigure the replica set using the modified conf configuration object: To ensure that a write operation propagates to at least one member of the set in both data centers, use the MultipleDC write concern mode as follows: db.users.insert( { id: "xyz", status: "A" }, { writeConcern: { w: "MultipleDC" } } ) 1. Create a replica set configuration object conf : 2. Redefine the getLastErrorModes value to require two different values of both dc.va and dc.gto : 3. Reconfigure the replica set using the modified conf configuration object: • data center facility, • physical rack location of instance, and • storage system (i.e. disk) type. Configure Tag Sets for Functional Segregation of Read and Write Operations