I have seen on tutorials that they use --fork as parameter of mongod. But when I try to do so, it says unknown option --fork. So how to --fork mongodb on windows?
You can start MongoDB from a command line by issuing the mongod command and specifying options. For a list of options, see the mongod reference. MongoDB can also run as a Windows service. For details, see Start MongoDB Community Edition as a Windows Service.
mongod is the primary daemon process for the MongoDB system. It handles data requests, manages data access, and performs background management operations. This document provides a complete overview of all command line options for mongod .
By default MongoDB data files are stored in C:\ProgramData\FotoWare\FotoWeb\Operations\MongoDBData. Stop all FotoWare services on the server. Move the existing MongoDB data folder from C:\ProgramData\FotoWare\FotoWeb\Operations\MongoDBData to the new location where it should be stored.
You can write start /b (/b - means execute without new cmd window) before mongod command. It will start your mongod command asynchronous and release console prompt. So, has similar effect, like fork.
It can be used in .bat scripts, for example, starting replica set:
start /b mongod --replSet m101 --logpath "1.log" --dbpath data\rs1 --port 27017 --smallfiles
start /b mongod --replSet m101 --logpath "2.log" --dbpath data\rs2 --port 27018 --smallfiles
start /b mongod --replSet m101 --logpath "3.log" --dbpath data\rs3 --port 27019 --smallfiles
...
--fork is actually a Linux command not a Windows or mongod command. I do not believe the same exists on Windows at all.
Linux has two primitives here, fork and exec however Windows only really has createProcess which is effectively fork-and-exec.
Setting up a service and running it in fork mode is not the same, a service is more like a init.d script however that is currently the only way really.
Cygwin can emulate fork on Windows, very slowly, as described here: What is the closest thing windows has to fork()?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With