Replica set mode
Present the cluster as a replica set to applications that connect with replicaSet=.
By default every node presents itself to drivers as a mongos. If an application or tool expects a replica set (it
connects with replicaSet=, reads the oplog or uses the replSet* commands), change the presentation live, without
restarting any node.
Requirements
- A running cluster and access to
teseladb adminfrom one of its nodes. - A name for the replica set, the one your applications will put in
replicaSet=.
Change the presentation
teseladb admin topology set replicaset --name rs0You can also change it from mongosh with the topologyPresentation cluster parameter, with the same effect as the
administration command.
What drivers see
The designated node answers hello as primary and the others as secondaries, with setName, hosts, primary and
electionId. If the designated node stops being alive, the cluster designates another on its own and
drivers see it as a MongoDB election.
mongodb://node-01:27017,node-02:27017,node-03:27017/?replicaSet=rs0&tls=trueOplog
local.oplog.rs is a read-only collection generated from the versions of the documents. Tools that read the oplog and
mongodump --oplog work in both modes. applyOps applies entries as in MongoDB.
Check
In mongosh, db.hello() returns setName: "rs0" and the node acting as primary in primary.
Common problems
- If the driver finds no primary, the
replicaSet=name in the string does not match the--nameyou gave when changing the presentation.
See also
- Sharding and zones, the default presentation.
- Differences with MongoDB, with reading the oplog under the
mongospresentation.