Cannot start MongoDB as a service

后端 未结 24 1530
情话喂你
情话喂你 2020-12-07 10:07

I have been developing for MongoDB for some months now and would like to install it as a service on my Windows 7 Enterprise machine. The following is the command that I hav

24条回答
  •  心在旅途
    2020-12-07 10:31

    If you did not specify absolute file paths for the data directory, or the log directory, you will get the same Windows error, but no log file.

    I used the information from "Install MongoDB Service on Windows 7", pushed on Webiyo to correct the registered service arguments:

    1. Download MongoDB and extract it to the C:\ drive.
    2. Add "data" and "logs" subdirectories under the "C:\mongodb165" directory.
    3. Add a log file name "mongolog.txt" at "C:\mongodb165\logs\mongolog.txt".
    4. Change the directory to "C:\mongodb165\bin".
    5. Execute the following command:

      mongod --install --rest –master –logpath=C:\mongodb165\logs\mongolog.txt
      
    6. Open the registry editor (regedit.exe), go to HKEY_LOCAL_MACHINE → SYSTEM → CurrentControlSet → Services.

    7. Find the MongoDB key and set the "ImagePath" value to:

      C:\mongodb165\bin\mongod --service  --rest  --master  --logpath=C:\mongodb165\logs\mongolog.txt  --dbpath=C:\mongodb165\data
      
    8. Save the changes to the registry and exit the registry editor.

    9. Open ComponentServices, click on "Services (Local)", and find the MongoDB service. Start it.
    10. Check at the URL http://localhost:28017/ to verify that MongoDB returns stats.

提交回复
热议问题