Chapter 1: The Mongod Lab: Configuration File

I have added below config in config file & when try to run this command i am getting this eror.

command : mongod --config mongod.conf
error : 2020-10-04T10:23:02.373+0000 F CONTROL [main] Failed global initialization: UnknownError: Cannot get current working directory: No such file or directory
bash-4.4# mongod --port 27000 --auth

fill out this configuration file, mongod.conf!

and then use it to run mongod with:

mongod -f mongod.conf

network interfaces

net:
#port: 27017
port: 27000
bindIp: 127.0.0.1

security:
authorization: enabled

Please show the output of
pwd
ls -lrt
Does the config file exist?

If requirement is to run with config file why it was run with params on command line
Make sure to kill the running instance when you try again with config file option

Hello,
i have also question regarding mongod.config file.

mongod.conf file:
storage:
dbPath: “/data/db”
systemLog:
path: “/data/mongod.log” # i have also tried /data/log/mongod.log
destination: “file”
net:
bindIp : “127.0.0.1”
port: 27000
security:
authorization: enabled
processManagement:
fork: true

When i press the Button “Run test” (after i wrote the command in terminal: mongod --config mongod.conf
), i get the message “Incorrect! Try again.”

3 total, 0 passed, 0 skipped:
[FAIL] “The server is running on localhost:27000”

Did you launch mongod on port 27000?

[FAIL] “The server requires authentication”

Don’t forget to launch mongod with authentication enabled!
You can do this using the configuration file.

[FAIL] “Mongod was started with a configuration file”

Did you launch mongod using a configuration file?

When i execute the same command in the terminal (this time press “Enter” button), every thing is fine.

ps -ef | grep mongo command:
bash-4.4# ps -ef | grep mongo
359 root 0:01 mongod --config mongod.conf
386 root 0:00 mongo --port 27000
394 root 0:00 grep mongo

Also connecting to mongo working fine:
bash-4.4# mongo --port 27000
MongoDB shell version v4.0.5
connecting to: mongodb://127.0.0.1:27000/?gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“a996df06-98c7-465a-9c83-17aa05ec0c37”) }
MongoDB server version: 4.0.5


Why it is not working over the Button “Run Test”?

May be the validation is picky and really wants localhost rather than 127.0.0.1.

Hi,
if it would be like you said, i would expect same Error when i press the enter button.
But i tried also with localhost :slight_smile: , same result…

Post screenshot of the mongod command after restarting with localhost.

The content of the log file might be of interest.

Log file is empty, i created new one before i tried to start, after i press the button log file was empty
When i start mongod pressing the Enter, log file is written, everything fine…

But, here is log file after mongod is running:

2020-10-08T15:45:14.373+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --ss
2020-10-08T15:45:14.380+0000 I CONTROL [initandlisten] MongoDB starting : pid=700 port=27000 dbpath=/data/db 64-bit
2020-10-08T15:45:14.380+0000 I CONTROL [initandlisten] db version v4.0.5
2020-10-08T15:45:14.380+0000 I CONTROL [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2020-10-08T15:45:14.380+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1g 21 Apr 2020
2020-10-08T15:45:14.380+0000 I CONTROL [initandlisten] allocator: system
2020-10-08T15:45:14.380+0000 I CONTROL [initandlisten] modules: none
2020-10-08T15:45:14.380+0000 I CONTROL [initandlisten] build environment:
2020-10-08T15:45:14.380+0000 I CONTROL [initandlisten] distarch: x86_64
2020-10-08T15:45:14.380+0000 I CONTROL [initandlisten] target_arch: x86_64
2020-10-08T15:45:14.380+0000 I CONTROL [initandlisten] options: { config: “mongod.conf”, net: { bindIp: “localhost”
2020-10-08T15:45:14.380+0000 I STORAGE [initandlisten] Detected data files in /data/db created by the ‘wiredTiger’
2020-10-08T15:45:14.403+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=256M,session_max=2
2020-10-08T15:45:15.758+0000 I STORAGE [initandlisten] WiredTiger message [1602171915:758868][700:0x7fe0c0a45ca8],
2020-10-08T15:45:16.149+0000 I STORAGE [initandlisten] WiredTiger message [1602171916:149775][700:0x7fe0c0a45ca8],
2020-10-08T15:45:16.345+0000 I STORAGE [initandlisten] WiredTiger message [1602171916:345138][700:0x7fe0c0a45ca8],
2020-10-08T15:45:16.544+0000 I STORAGE [initandlisten] WiredTiger message [1602171916:544125][700:0x7fe0c0a45ca8],
2020-10-08T15:45:16.620+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2020-10-08T15:45:16.630+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, w
2020-10-08T15:45:16.630+0000 I CONTROL [initandlisten]
2020-10-08T15:45:16.649+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with director
2020-10-08T15:45:16.650+0000 I NETWORK [initandlisten] waiting for connections on port 27000

OK, maybe will help someone…
mongod deamon should be started with pressing the Enter on keyboard, the command for creating user also.
“Run test” button should be used on the end, when everything is up and running… :frowning:
I would say it is my fault, wrong thinkin’ that i should verify each step pressing “Run test” Button.
Cheers