Start mongod via service

In, it gives a way of starting mongod via service, i.e., sudo service mongod start.

When staring mongod this way, does it read /etc/mongod.conf automatically? If not, how to make mongod read the configuration file?

Do not use sudo to start mongod
Use vagrant
Please check this link

Mongod was not started by the correct user - remember NOT to run mongod as root

Thank you for the response. I could run mongod using vagrant without sudo for the course.

I need to set up a mongodb cluster at work. The installation guild in official document says using service to start mongod, without mentioning using /et/mongod.conf. This is a bit different from what was taught in the course.

On Windows it uses the installation config file when you run MongoDB as a service. I would imagine that the same applies to Linux. Give it a try and let us know.

The course doesn’t discuss running MongoDB as a service to “keep things simple and focused”… this is my view.

Hi @Songfang_60099,

You can start your mongod instance as a service by running this command but from the perspective of completing this course I would suggest you to stick with the process that is being taught in this course so that you don’t have any difficulty in doing the labs and the final exam questions.

It depends upon how you have installed MongoDB on your system. If you have followed the instructions mentioned in the link shared by you then yes, the /etc/mongod.conf will be read by mongod.

Yes, the instructions laid out in the installation guide is for deploying MongoDB in a production environment. However, the course content has been designed with a different goals in mind.

Hope it helps!

Shubham Ranjan
Curriculum Support Engineer