Mongodb – A bit confused on how mongo and mongod load configuration files

mongodb

I'm new to MongoDB and was working on getting my first replica set up and running using the MongoDB Cloud Manager. However, the server I deployed to already had mongodb installed.

I currently have everything seemingly working, including SSL and authentication, but I'm wondering how mongodb decides what config files to use and which mongod to run.

When I used the deploy option in Cloud Manager to my remote server, it had me set up an automation agent, which included its own mongo and mongod executables. I would have thought I needed to use these to connect to my database, but regardless of what mongo or mongods I'm running (I've tried all 4 combos of the automation agent's and the preinstalled ones in /usr/bin), as long as I type:

mongo --host localhost:port#

and specify the port number for the primary in my replica set, I connect with the proper configuration settings. I've noticed the replica set has an automation_agent.conf file on the primary, but how does merely specifying the port # tell mongo to use that configuration file?

On a somewhat related note (I was trying some command line diagnostics in the mongo shell to figure out the configuration behavior), is the normal process to log in once you've set up authentication to use the admin database, and then authenticate in the mongo shell? Am I overcomplicating things?

Sorry if these questions seem a bit scattered, I'm just unsure I'm not shooting myself in the foot later by not uninstalling the old mongo and mongod executables.

Best Answer

When you are using automation agent, configuration is done at OPS manager (or cloud front) and there is not much what you can do at actual machine. Yes, in this case, automation agents config file includes information of port and other parameters.

When you start locally installed mongod (f.ex. systemctl start mongod), it is set at (systemctl) mongod.service file that startup command is mongod -f /etc/mongod.conf, so config file is /etc/mongod.conf where all startup parameters has been defined.