Database Reference
In-Depth Information
started. You can set tags on your replica set by adding them to the tags section of your replica set config file. Let's start by
adding tags for
sites
of
a
and
b
to our replica set config:
conf=rs.conf()
conf.members[0].tags = {site : "a"}
conf.members[1].tags = {site : "b"}
conf.members[2].tags = {site : "a"}
rs.reconfigure(conf)
Now we can check out our new config and you can see that we have set our two sites in place; they are defined in
the
tags
section of each configuration document.
rs.conf()
{
"_id" : "testset",
"version" : 8,
"members" : [
{
"_id" : 0,
"host" : "Pixl.local:27021",
"tags" : {
"site" : "a"
}
},
{
"_id" : 1,
"host" : "Pixl.local:27022",
"tags" : {
"site" : "b"
}
},
{
"_id" : 2,
"host" : "Pixl.local:27023",
"priority" : 0,
"hidden" : true,
"tags" : {
"site" : "a"
}
},
{
"_id" : 3,
"host" : "Pixl.local:27024",
"arbiterOnly" : true
}
]
}