Lab - Configure a Sharded Cluster

I’m trying to launch the 3 nodes of my csrs. Already launch 2 and 3, but csrs_1.conf does not work.

At the image attached you can see what I tried. When I tried to see the PID of the node, its not there.

image

Here are my csrs files (csrs_1.conf, csrs_2.conf, csrs_3.conf)

image

What can I try?

I would start with tail /var/mongodb/db/csrs1/mongod.log.

Do I have to run it on vagrant?

You are already running on vagrant.

It looks like the directory has been initialized with an bad configuration. I would remove all the files in *** /var/mongodb/db/csrs1/ and retry.

All the files and directories from the /var/mongodb/db/csrs1/? Or is there things that I cannot delete?


All the files. You may want to do a backup. But it is a new lab. There is nothing to lose.

From the initial screenshots, port 26001 is for csrs_1.conf and this mongod hasn’t been started.

From what I see. It has been started twice but it fails after the fork. I am starting to suspect that one of the mongod_repl.*.conf refers to the same directory as csrs1.

Yeah, potentially a clash. Good call!

Have you removed the files and start over for csrs1?

not yet
But I will now

should I remove the WiredTiger files? They ask if I really want to do it, and I remeber something about never messing with those files. I have only removed the collections and indexes to the moment.

You remove everything. It is a new configuration. There is nothing to be lost. But that is true. Do not mess around those files once it is running fine.

It seems that I don’t have the permission

I tried to add the node from the primary and this message appeared.“errmsg” : “Found two member configurations with the same host field, members.2.host == members.3.host == 192.168.103.100:26001”

This is what I tried to do afterwards:















The node is there but is “not reachable”, I already tried to remove it and bring it back.

What can I do?

Wiredtiger is owned by vagrant.You should be able to remove
-rw------- 1 vagrant vagrant 45 Jan 16 12:26 WiredTiger
vagrant@m103:/var/mongodb/db/2$ rm -rf *
vagrant@m103:/var/mongodb/db/2$ ls -ltr
total 0

As Steve & 007_jb suggested best thing is to restart from scratch
Or try to remove db dir itself.Create dir again
You attempted to start crs_1.conf multiple times but it is giving error
Did you check the log why it is failing

Yes… @Guy_40794 you’ve taken a lot of different actions and it’s going to take a lot of effort to debug. Not unless @steevej-1495 has time and would like the challenge? :slight_smile:

To start with a clean slate, suggest the following steps:

  1. Destroy, re-provision and login to the VM
    vagrant destroy
    vagrant up
    vagrant ssh
  2. Create all relevant parent and sub directories, give vagrant ownership to parent dir, and create keyfile. Copy, paste and execute the entire block of code in one go:
    sudo mkdir -p /var/mongodb/pki/
    sudo chown -R vagrant:vagrant /var/mongodb/
    mkdir -p /var/mongodb/db/{1,2,3}
    mkdir -p /var/mongodb/db/csrs{1,2,3}
    openssl rand -base64 741 > /var/mongodb/pki/m103-keyfile
    chmod 400 /var/mongodb/pki/m103-keyfile

NB: vagrant now owns /var/mongodb directory so if you ever need to create subsequent sub directories, you won’t need sudo.

Now you’re ready to start building all the replica sets using mongod -f. And remember that you’ll need to create the user.