-
Stop Mongod Service/Daemon/Process.
-
Find & open the mongod.conf.
- Windows:
<MongoDB-Server-Bin-Path>/mongod.conf
- Linux:
/etc/mongod.conf
- Windows:
-
Add the following to the File:
replication:
oplogSizeMB: 5000 # <-- Usual Value could be: 5% of Free-Disk-Space | Min: 990 | Max: 50000
replSetName: local-rs
enableMajorityReadConcern: true
-
Start the Mongod Service/Daemon/Process.
-
Run MongoDB Shell using mongosh.
-
Run:
rs.initiate()
- Now when connecting to your mongod instance make use of the replSet parameter:
- Local MongoDB Compass Example:
mongodb://localhost:27017/?replicaSet=local-rs&readPreference=primary
- mongosh seems to work without that option.
- Local MongoDB Compass Example: