Config file doesn't work

hello

i create a directory and a sub directory for logpath but when i run mongod with my config file, i have this message : F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open “/mymongo/logs/mongod.log”

someone can help me please ??

Hi @ajulio4,

Can you please check if the directory/file that you mentioned has the appropriate permissions?

Also, I would advise you to create the directories with names as mentioned in the labs as the validation scripts would throw an error if this is not the case.

Please get back if you have any more questions.

Thanks,
Muskan
Curriculum Support Engineer

I try to create the directories with sudo, but same issue.

Hi @ajulio4,

Can you please share a screenshot of your terminal where you are getting this error message and also share the output of below commands:

ls -lrt /mymongo/logs/mongod.log
ls -lrt /mymongo/logs
ls -lrt /mymongo

Creating the directories with sudo will just ensure that you are able to create your directories now in the directory which you were not able to do before since it was owned by root.

Also, try creating your directory inside /var/mongodb/db.

Thanks,
Muskan
Curriculum Support Engineer

vagrant@m103:~$ ls -lrt mymongo/

total 4

drwxr-xr-x 2 root root 4096 Oct 16 14:39 logs

vagrant@m103:~$ ls -lrt mymongo/logs/

total 0

Hey @ajulio4,

This shows that the directory is owned by root and is not writable by any other user, in your case which is “vagrant”.

Please change the owner of the directory to vagrant using below commands:

sudo chown vagrant:vagrant mymongo/
sudo chown vagrant:vagrant mymongo/logs

Let me know if this helps.

Thanks,
Muskan
Curriculum Support Engineer

Just “eyesdropping” guys :eyeglasses: :slightly_smiling_face:

@Muskan_Sharma, @ajulio4 ran mymongo/ and not /mymongo/, i.e. it’s missing the first backslash. Is this what you want? Just thought I should bring it up with you guys :wink:

1 Like

thks with mymongo/ and not /mongo/ i dont have the problem anymore but i cant launch the mongod with my config file here is my config file . :slight_smile:
systemLog:
destination: file
path: “mymongo/logs/mongod.log”
logAppend: true
storage:
dbPath: “data/db/”
net:
bindIp: "127.1.0.0, 192.168.103.100
port: 27000
processManagement:
fork: true

i have this if i execute the validationn script : Client experienced a timeout when connecting to the database - check that mongod is running on the correct port, and that your user was created with the correct settings.

and the log show this :

nfig.conf", net: { bindIp: "127.1.0.0, 192.168.103.100 port: 27000 processManagement: fork: true " }, storage: { dbPath: “data/db/” }, systemLog: { destination: “file”, logAppend: true, path: “mymongo/logs/mongod.log” } }
2019-10-16T15:29:09.045+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Cannot assign requested address
2019-10-16T15:29:09.045+0000 I CONTROL [initandlisten] now exiting
2019-10-16T15:29:09.045+0000 I CONTROL [initandlisten] shutting down with code:48

Means wrong IP address or another process is listening to given port.

The leading quote, or missing end quote of bindIp: can be culprit. The space after the colon on bindId is also suspect.

Means there is no mongod listening to the requested IP and port.

same issue when i change the file :slight_smile:1 systemLog:
2 destination: file
3 path: “mymongo/logs/mongod.log”
4 logAppend: true
5 storage:
6 dbPath: “data/db/”
7 net:
8 bindIp: “localhost,192.168.103.100”
9 port: 27000
10 processManagement:
11 fork: true

output :slight_smile:
nfig.conf", net: { bindIp: "127.1.0.0, 192.168.103.100 port: 27000 processManagement: fork: true " }, storage: { dbPath: “data/db/” }, systemLog: { destination: “file”, logAppend: true, path: “mymongo/logs/mongod.log” } }
2019-10-16T15:29:09.045+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Cannot assign requested address
2019-10-16T15:29:09.045+0000 I CONTROL [initandlisten] now exiting
2019-10-16T15:29:09.045+0000 I CONTROL [initandlisten] shutting down with code:48

Same problem with the paths in your config file… it’s missing the first backslash :slight_smile:
… and ensure that both directories exist.

Hi @ajulio4,

If it doesn’t work after correcting your dbpath as @007_jb has suggested, please follow the below given steps:

  • Check ifconfig from your vagrant box. Look for IP: 192.168.103.100 .
  • If you can see the IP, then restart vagrant and try again.
  • If you don’t see the IP, then provision your vagrant again.
  • Exit your vagrant. Run these commands.
  • vagrant halt
  • vagrant up --provision
  • Try mongod again

Thanks,
Muskan
Curriculum Support Engineer

The fact that the logs show net: as a non valid document.

Since end quotes for bindIp: are missing and there is no comma before port: and processManagement it means your quotes are messed up. Probably by using a editor that puts fancy quotes.

rally… you use which editor on the vagrantbox? i use vi to create the file… i delete the file and recreate it… i have issues…

systemLog:

destination: file

path: “/mymongo/logs/mongod.log”

logappend: true

storage:

dbpath: “/data/db/”

net:

bindIp: “127.1.0.0,192.168.103.100”

port:27000

processManagement:

fork: true

Error parsing YAML config file: yaml-cpp: error at line 10, column 18: illegal map value

try ‘mongod --help’ for more information

same issue :::
vagrant@m103:~$ mongod -f myconfig.conf

about to fork child process, waiting until server is ready for connections.

forked process: 3209

ERROR: child process failed, exited with error number 48

To see additional information in this output, start without the “–fork” option.

2019-10-16T19:16:26.873+0000 I CONTROL [initandlisten] options: { config: “myconfig.conf”, net: { bindIp: “127.1.0.0,192.168.103.100”, port: 27000 }, processManagement: { fork: true }, storage: { dbPath: “/data/db/” }, systemLog: { destination: “file”, logAppend: true, path: “mymongo/logs/mongod.log” } }
2019-10-16T19:16:26.874+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Cannot assign requested address
2019-10-16T19:16:26.874+0000 I CONTROL [initandlisten] now exiting
2019-10-16T19:16:26.874+0000 I CONTROL [initandlisten] shutting down with code:48

I use vi. Your quotes are correct this time. The log show the net: document with 2 members, bindIp and port. Are you sure of IP 127.1.0.0 ? Can you ping it?

now i have this message when i try to validate the lab with this file

1 systemLog:
2 destination: file
3 path: “mymongo/logs/mongod.log”
4 logAppend: true
5 storage:
6 dbPath: “/data/db/”
7 net:
8 bindIp: “127.0.0.1 192.168.103.100”
9 port: 27000
10 processManagement:
11 fork: true
~
with this config file, the mongod lauch normaly but i can’t validate the lab with this output
vagrant@m103:~$ validate_lab_configuration_file

You need to bind the IP address to 127.0.0.1 or localhost

vagrant@m103:~$

Hi @ajulio4,

Please correct your bindIp - you need to separate the two IPs using a comma.

bindIp: “127.0.0.1,192.168.103.100”

Let me know if this helps.

Thanks,
Muskan
Curriculum Support Engineer