Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb fork in windows

Tags:

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?

like image 413
sadaf2605 Avatar asked Mar 03 '13 11:03

sadaf2605


People also ask

How do I run Mongod?

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.

What is Mongod process?

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 .

Where MongoDB data is stored?

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.


2 Answers

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

...

like image 99
Hersh Avatar answered Sep 19 '22 13:09

Hersh


--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()?

like image 39
Sammaye Avatar answered Sep 22 '22 13:09

Sammaye