This is bat script which helps to create Mongo Services and set the replication on local machine.
The purpose for this script is to create the 3 MongoDB services by setting different engine (inMemory, wiredTiger, Mmapv1) and enabling replication for the same
- Installed MongoDB Enterprise V3.4 (Enterprise for InMemory engine)
- MongoDB installed in default path (If not, change the path in script)
-
Open CMD as administrator (Important)
-
Navigate to current folder (cd dir)
-
Run Setup.bat from command line
> setup.bat
Service | Port | Engine | Type | Data Folder |
---|---|---|---|---|
MongoInMemory | 40001 | inMemory | Primary | c:\mongodata\inMemory\db |
MongoWiredTiger | 40002 | wiredTiger | Secondary | c:\mongodata\wiredTiger\db |
MongoMmapv1 | 40003 | mmapv1 | Arbiter | c:\mongodata\mmapv1\db |
-
If you get
notMasterNoSlaveOk
on secondary instance for reading collection Connect to secondary instance and enable slave>db.getMongo().setSlaveOk()
- Create data folders for mongodb
- Copy configuration files
- Create 3 services of MongoDB
- Start all the services
- Enable replication
- Add 40002, 40003 into replication set
- Add mongo to PATH
- Create test
emp
collection and add first records to test replication
run zremovemongo.bat
It does all the reverse thing to clean !!!