Skip to content

Instantly share code, notes, and snippets.

@tfitch
Last active August 29, 2015 14:06
Show Gist options
  • Save tfitch/1d346c8631b68ddb1fdd to your computer and use it in GitHub Desktop.
Save tfitch/1d346c8631b68ddb1fdd to your computer and use it in GitHub Desktop.
MongoDB Replica Set configuration file
rsconf = {
"_id" : "<% replicaset %>",
"version" : 1,
"members" : [
<% idCounter = 1 %>
<%- @secondaries.each do |secondary| %>
{
"_id" : <%= idCounter %>,
"host" : "<%= secondary.fqdn %>:27017"
},
<% idCounter += 1 %>
<%- end %>
// in order to gracefully handle trailing commas, put the known Primary last
{
"_id" : 0,
"host" : "<%= node.fqdn %>:27017"
}
<% end %>
]
}
rs.initiate( rsconf )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment