HW 1.3 mongod options

Trying to start first node
and getting an error in setting up the mongod options

At this point the content of the log file is important to share so that we can help you.

Did I do something wrong?

Yes, you did.

You specify a file that .pem file that does not exist. That the meaning of the error message cannot read certificate file … No such file or directory*.

Which directory should I copy the .pem files from the lab handout?

Please check your lab instructions
It should be under your shared dir

“Make sure to copy the certs folder directly to the m310-vagrant-env/shared folder. If the certificates are not in this location then your results will be incorrect”

after doing it again the same

Actually the problem was that I should have been in /home/vagrant/shared this location before starting in mongod.

now it works,
Thank you.

One more issue:

After I made all three mongod running, opened a new CMD
connected to mongo

and then tried to initiate a replica set, get this error.

You are already at primary of your replicaset
Why do you want to run rs.initiate() again?
Just run rs.status()

I did not do it first time.

And that was my outcome (below), but the answer was not accepted

{ unauthorizedStatus: {“ok”:0,“errmsg”:“not authorized on admin to execute command { replSetGetStatus: 1.0 }”,“code”:13}, memberStatuses: [“PRIMARY”] }

You should have 3 members.It shows only one?
The command you used is to connect to a replica with x509 once everything is setup
We do rs.initiate() at a early stage
Right after bringing up your 3 mongods you should connect to primary port and run rs.initiate()


You mean I have to run just rs.initiate() after I am connected to a primary port?

instead of

rs.initiate({_id: ‘myReplSet’, members: [{ _id: 0, host: ‘database.m310.mongodb.university:31130’}, { _id: 1, host: ‘database.m310.mongodb.university:31131’}, { _id: 2, host: ‘database.m310.mongodb.university:31132’},]});
I sort of followed the documentation as in

If you have PRIMARY in your prompt there you are already connected to a replica set that has been initialized. That’s why you get already initialized. The next step is to add the other members.

I already did that as described in the link below and I get the following error:

You have to authenticate by giving a user name and password that has access to the admin database.

Is it possible that you already have created the user? If you are not too sure, I would wipe out the data directories and start over. I strongly recommend that you use a configuration file rather than using command line options.

scrapped everything, wiped directories, started over:

started a new Mongo and it starts as a Secondary, how come?

and it starts

In previous tries created the user following way:

use $external
createUser: “C=US,ST=New York,L=New York City,O=MongoDB,OU=University2,CN=M310 Client”,
roles: [{role: ‘root’, db: ‘admin’}]

After killing mongods did you remove all dbpath/logpath dirs?

Your rs.status() shows only 2 nodes
How did you run rs.initiate()
hostnames should all be same but it shows database:31130 and database.m310.mongodb.university:31131
Also startup status is not ok It means it is not part of any replicaset

I did all of this, including reinstallation of VMs all together .
I even downloaded the handout file and renamed it and created brand new directories. Please see below:

I am extremely frustrated not being able to resolve it.

If you started fresh it should work
What does rs.status() and rs.conf() show
Show the output of ps -ef|grep mongo
or its possible old replicaset is registered somewhere and when you try to connect going to old configuration