Chapter 2 replication:Lab - initiate a replica set locally

Can someone take a look and tell me why I can not get mongod to start.

This is how my Config file looks.


Did you run the mongod without fork option?
It will throw the error messages on your terminal
You can investigate further from that
Most likely missing dirs or wrong permissions or mongod already running on same port
Please check again

mongod is not running on the same port.
This is what I have for permissions.


Did you try to run your command without fork?
As i told your dir structure may not be correct

Your config file shows dbpath as /var/mongodb/1 but your ls command shows different
Can you type pwd at the location where you listed the files?


This is your home dir.Your lab requires a different dir path
Please create dbpath and logpath directories under /var as per your config file
Go through you lectures on how to create dirs under /var
You have to use sudo privs to create subdirs as /var is owned by root


this is what I have but connote cd into the mongodb dir as root

Your cd is failing as root or vagrant?
Seems some permission issues
How was this dir created?

Should be something like this
sudo mkdir -p your_dbpath
sudo chown vagrant:vagrant your_dbpath

or try to change permissions by sudo chown

this is my output. what am I doing wrong



You are missing steps while creating dirs
For the first error you already created dir
While changing ownership you missed the dir pki
Please check again
You attempted to create dir again by mkdir-it will not work
To create any subdir under /var which is owned by root you have to use sudo

For second error indentation may be problem
Don’t use tabs.Use space bar to move fork under processmanagement

Thank you I figured it out . done!!

Hi @Mathias_11469,

I’m glad your issue got resolved. If you have any other query then please feel free to get back to us.

Happy Learning :slight_smile:

Shubham Ranjan
Curriculum Support Engineer