Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Velotio - HashiCorp Consul Part 2 - MongoDB Replica Set Configuration
var config = {
_id: "consuldemo",
version: 1,
members: [{
_id: 0,
host: "mongo_1:27017",
}, {
_id: 1,
host: "mongo_2:27017",
}, {
_id: 2,
host: "mongo_3:27017",
}],
settings: {
chainingAllowed: true
}
};
rs.initiate(config, { force: true });
rs.slaveOk();
db.getMongo().setReadPref("nearest");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment