Lab 3: Change the Default DB Path NonExistentPath

My config.conf file:

storage:
dbPath: /var/mongodb/db/
net:
bindIp: 192.168.103.100,localhost
port: 27000
security:
authorization: enabled

When trying:

sudo chown vagrant:vagrant /var/mongodb/db

I get this error:
chown: vagrant: illegal group name

So I can’t get mongod to work, beacuse I also get this error:

exception in initAndListen: NonExistentPath: Data directory /var/mongodb/db/ not found.

Let’s see a full screenshot of the command and the error message together

You got

If I remember correctly somewhere in the instructions they indicate that you must create the directory.

For

You may simply use

sudo chown vagrant /var/mongodb/db

and it should work, once the directory is created.

Hi @Diego_Hernandez_O_Hagan_03051,

Where are you running this command ?

Have you created the directory properly ?

As @007_jb has mentioned, it would be great if you can share the screenshot of the command that you are running and the error message that you are getting.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

I’m not sure the folders were created. I can’t see them in my “m103-vagrant-env” folder. Is that the folder they are supposed to be in?

After I took the screenshots, I created the folders manually in “m103-vagrant-env/var/mongodb/db”, gave all the folders “read and write” permissions and I got the same erorrs. I gave changed the permissions “right clicking” the file in “get info -> sharing & permissions”.

I appreciate your help.

Your dir iis created but chown command failed
That’s why logs show it as read only dir(owned by root)
Check sudo ls -l /var/mongodb
Does the user vagrant exist?
Please check by running the commands whoaim or id

Try using just the owner if no group

sudo chown user: /var/mongodb/db

You should not create dbpath dir in shared folder.
As per your config file the path is /var
Here / means top most dir on Unix box

1 Like

I suspected you were running something on your macOS terminal… so similar to what @Ramachandra_37567 said, any directories you create must be created in the vagrant machine, not on the shared directory.
The vagrant error you were getting is because the vagrant user only exists on the VM.

For this course, the only thing you use the shared folder for is to store config files. All other operations must be performed on the VM.

PS: Suggest you edit your post and delete the screenshot of your config file as it’s against forum guidelines to post possible answers to labs.

1 Like

Hi @Diego_Hernandez_O_Hagan_03051,

As others have mentioned, you are supposed to run this command in the vagrant prompt. From the m103-vagrant-env directory, please run the vagrant ssh command to ssh into the virtual machine.

In M103 course, whatever you are doing please do it in the ‘‘Vagrant@m103:~$’’ prompt.

Please run this command (in vagrant prompt) to change the ownership of the directories.

 sudo chown vagrant:vagrant /var/mongodb/db 

Hope it helps!

If you have any other query then please feel free to get back to us.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

1 Like

Thank you all,

I ssh to the VM, created the folders there and gace the permissions with

sudo chown vagrant:vagrant /var/mongodb/db

Now the problem I face is that I can’t reach my config file. My config file is in my shared folder, does ir have to be in the VM? If so, how do I pass it form my computer to the VM?

Good stuff!

Let’s see the outputs of ls -l /shared/ and ls -ld /shared/

These are the outputs

That’s peculiar! How did root become the owner of the /shared folder? Your screenshot also shows that there’s no file under this directory. There’s a possibility that your VM is disconnected from the shared dir.

Let’s do another:
ls -l /shared/..

Also, open VirtualBox > open the settings for the m103 VM > click Shared Folders > show us a screenshot

Ok here are the screen shots

Thanks! That’s quite odd!

I would suggest destroying and re-provisioning the VM and running the three ls commands again. Here’s how:

  1. Exit the VM
  2. Execute vagrant destroy
    Type y and hit Enter to confirm
  3. Execute vagrant up
  4. SSH back into the VM, run and share the three ls commands.
1 Like

Thank you so much!!

ls -l /shared/ Now shows “total 4” instead of “total 0”

I

After these steps I was able to correctly complete the lab.

Help much appreciated!

Very good! Directories like shared, vagrant, data and dataset strangely were owned by root which shouldn’t have been the case.

:slightly_smiling_face::+1:

1 Like

Hi @Diego_Hernandez_O_Hagan_03051,

I’m glad your issue got resolved. If you have any other query then please feel free to create another thread.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

1 Like