Setting up a replica set

I am having problems setting the replica set in Chapter 2.

when I run openssl rand -base64 741 > /var/mongodb/pki/m103-keyfile , I ge a Permission Denied message. I have tried to find help online but it seems a Linux permission issue.

The directory /var/mongodb/pki/ must exists and be writable by the current user.

The chown command may be used to assign the correct user.

Thank you steeve, the directory was created. I just followed the instructions step by step. I wonder why is this happening if I went thru the instructions in chapter 1 and 2

Exactly as in Unit 2

sudo mkdir -p /var/mongodb/pki/
sudo chown vagrant:vagrant /var/mongodb/pki/
openssl rand -base64 741 > /var/mongodb/pki/m103-keyfile
chmod 400 /var/mongodb/pki/m103-keyfile

Does anyone has a solution for this?

chmod 400 is read only
touch test
-rw------- 1 vagrant vagrant 0 Jan 20 03:14 test

vagrant@m103:/var/mongodb/db$ chmod 400 test
vagrant@m103:/var/mongodb/db$ ls -lrt test
-r-------- 1 vagrant vagrant 0 Jan 20 03:14 test

Please try with chmod 600
In earlier class it was created with chmod 600

To be fair I had chmod 600, and it worked. Though in principle, it should be read only.

Are you sure it’s the file that’s the problem, and not the permissions for the directory pki

@Ramachandra_37567. I have tried many things, two days actually just to put this up and runing. The 600 was suggested in the video but revoked in the lesson text and modified with the 400.

@Ernesto_47832, it looks like you already have the file. If this is the case then you do not have recreate it by calling openssl. Both 600 and 400 are go when running. However, if you need to recreate the file then it must be 600 in order to be able to overwrite it.

@steevej-1495, Thank you, my solution yesterday late night was to create everything in local folders. My problem is really not with MongoDB but with Linux, When I went to the Army 22 years ago I had to learn Unix but I never had to use it again. My next course purchase is defenetly Linux.

Now , when checking the replica set restepdown() I get “ok” : 0
No selectable secondaries caught up.

But I have the others nodes running

I also noticed on my other 2 nodes (I run both without --fork) showing messages about “Session collection is not set up”

Thank you for all the help. I delete everything and astarted all over. I got stuck with the same problem but this time I openned the mongod.conf file and found out that this folder was read only. After that I took a crash course in chmod and everything is up and running with the following:

sudo chmod -R 0777 /var/mongodb/db

1 Like