For MongoDB University course-related questions I recommend posting directly in the relevant MongoDB University course-specific forum for more expedient guidance
Your command line doesn’t specify a config file to use, so this invocation only uses the options you have specified (
If you use
less (or your favourite text editor) to view the contents of the log file you specified, the MongoDB log should include more informative reasons on why
mongod failed to start:
Assuming you are using MongoDB 4.4+, the log entries will be in JSON format so you may want to install something like
jq (see: Download
jq) to make entries easier to read. The MongoDB server manual also includes some examples of log filtering and printing with
jq: Log Parsing Examples.
Then you could run:
cat /var/mongodb/logs/mongod.log | jq
I suspect you will find a complaint similar to the following about
dbPath not found, because
dbPath defaults to
/data/db and you have not specified
--config with a path to a config file:
"msg": "DBException in initAndListen, terminating",
"error": "NonExistentPath: Data directory /data/db not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the 'storage.dbPath' option in the configuration file."
It also looks like you have used the intended value for a log file as your
Your config file should look more like the following (assuming the
storage.dbPath directories have been created):
You would then start
mongod manually with a
--config value specifying the path to your config file:
mongodb --config /path/to/mongodb.conf
Note: For persistent deployments MongoDB is typically started using a service definition which includes a default path to a configuration file so you would just start & stop the service rather than adding the config file path or command line options on every invocation.
For an example, see Run MongoDB Community Edition on Ubuntu.