Deploy replicaSet

I’ve been trying for two weeks to do the deploy to replica set task, but there’s no way. When it doesn’t find the node, the path doesn’t exist. Now it doesn’t replicate because the replicaSet is not there but I don’t know when to insert it.

mkdir -p /var/mongodb/pki/
openssl rand -base64 741 > /var/mongodb/pki/m103-keyfile
chmod 400 /var/mongodb/pki/m103-keyfile
user@M103# mkdir -p /var/mongodb/db/mongod_1
user@M103# mongod -f mongod_1.conf
user@M103# cp mongod_1.conf mongod_2.conf
user@M103# vi mongod_2.conf
user@M103# cp mongod_1.conf mongo_3.conf
user@M103# vi mongod_3.conf
user@M103# mongod -f mongod_2.conf
about to fork child process, waiting until server is ready for connections.
forked process: 381
child process started successfully, parent exitinguser@M103# mongod -f mongod_3.conf
about to fork child process, waiting until server is ready for connections.
forked process: 417
child process started successfully, parent exiting
user@M103# mongo --port 27001
MongoDB shell version v4.0.5
connecting to: mongodb://
Implicit session: session { "id" : UUID("b53dd372-069e-4b62-9018-704c27ddbdec") }
MongoDB server version: 4.0.5
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
Questions? Try the support group
> rs.initiate()
        "ok" : 0,
        "errmsg" : "This node was not started with the replSet option",
        "code" : 76,
        "codeName" : "NoReplicationEnabled"
> exit 

when I do a:

vi mongod_1.conf

  dbPath: /var/mongodb/db/1          
  bindIp: localhost
  port: 27001     
  keyFile: /var/mongodb/pki/m103-keyfile
  destination: file
  path: /var/mongodb/logs/mongod1.log
  logAppend: true                    
  fork: true      
  replSetName: m103-repl       
  • mongod_1.conf 15/15 100%

Please, if somebody can help me to do the task I would be grateful for.

The dirs you created are not matching with what is shown in your config files
Also check security parameter
You are missing authorization

If I may add to @Ramachandra_Tummala comment and if you are doing Lab: Deploy a Replica Set, the lab starts with:

  1. There are three configuration files in your IDE workspace, but they are incomplete.

Update these configuration files so that all three mongod processes:

By doing

You overwritten all the correct configuration parameters that were already present in the file. But probably for instance 3 because you had a typo in your cp command.

Editing with vi rather than the integrated editor might cause problem. There is no saved button in the editor, so I suspect that the text is automatically saved when the mouse leave the editor pane, which would overwrite your vi edits.

In addition to the wrong path as mentioned the log path, destination and logAppend is not under the appropriate configuration. In this under security but should be under systemLog. That configuration file would produced errors when used to start mongod.

I strongly recommend that you Reset Workspace and start over by following the instructions.

1 Like

Thank you very much, in a moment I managed to set up the replicas.
But I have to say that I wasted a lot of time repeating what the course videos and exercises said.
The good thing is that I have learned the keywords and how to use them.
Thank you very much for the hints.

1 Like