Setting Up a Replica

Good Afternoon All.
In a previous post I was having difficulty in even starting the course - the problem has been rectified , and I got past chapter 1.

Chap 2 Replication - - it appears that I am encountering challenges in set-up on a per chater basis((lol)

I am having problems setting up the replicas in the Lab environment.

Below is a screenshot of a local CMD(Windows) connection to MongoDB


In the highlighted section section reference is made to "
2020-11-15T09:13:18.410-0400 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost…“Remote systems will be unable to connect to this server.”

This sounds a bit obtuse; but I am assuming that the above status is contributing somewhat to my inability to get the replica set functioning properly in the Lab question:

" Chapter 2: Replication

Lab: Deploy a Replica Set"

You have to use the lab IDE for the lab to be able to validate.

Steve, Thanks

BUt my fault - the image , that I posted earlier is indeed from my local machine – I posted that as an “intro” and possible explanation for the “angst” {self-inflicted} that I am currently experiencing.

Below is my somewhat “progress” I have made thus far in the lab (it’s been a struggle to get this far!!):MongoDB shell version v4.0.5
connecting to: mongodb://192.168.103.100:27011/?authSource=admin&gssapiServiceName=mongodb&replicaSet=m103-example
2020-11-15T18:31:47.945+0000 I NETWORK [js] Starting new replica set monitor for m103-example/192.168.103.100:27011
2020-11-15T18:31:52.972+0000 W NETWORK [js] Unable to reach primary for set m103-example
2020-11-15T18:31:52.972+0000 I NETWORK [js] Cannot reach any nodes for set m103-example. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2020-11-15T18:31:58.477+0000 W NETWORK [js] Unable to reach primary for set m103-example
2020-11-15T18:31:58.477+0000 I NETWORK [js] Cannot reach any nodes for set m103-example. Please check network connectivity and the status of the set. This has happened for 2 checks in a row.
2020-11-15T18:32:03.982+0000 W NETWORK [js] Unable to reach primary for set m103-example
2020-11-15T18:32:03.982+0000 I NETWORK [js] Cannot reach any nodes for set m103-example. Please check network connectivity and the status of the set. This has happened for 3 checks in a row.
2020-11-15T18:32:03.982+0000 E QUERY [js] Error: connect failed to replica set m103-example/192.168.103.100:27011 :
connect@src/mongo/shell/mongo.js:328:13
@(connect):1:6
exception: connect failed
bash-4.4#

Work done to get to above point:

Terminal #1 :
bash-4.4# chown root /var/mongodb/pki/
<ase64 741 > /var/mongodb/pki/m103-keyfile
bash-4.4# chmod 400 /var/mongodb/pki/m103-keyfile
bash-4.4# mongod -f mongod_1.conf
about to fork child process, waiting until server is ready for connections.
forked process: 333
child process started successfully, parent exiting
bash-4.4# mongo --port 27001
MongoDB shell version v4.0.5
connecting to: mongodb://127.0.0.1:27001/?gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“be40a704-c35b-4c06-b949-502929fb20d4”) }
MongoDB server version: 4.0.5
Welcome to the MongoDB shell.
For interactive help, type “help”.
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user

rs.initiate()
{
“info2” : “no configuration specified. Using a default configuration for the set”,
“me” : “localhost:27001”,
“ok” : 1
}
m103-repl:OTHER>
m103-repl:PRIMARY>
m103-repl:PRIMARY> use admin
switched to db admin
m103-repl:PRIMARY> db.createUser({
… user: “m103-admin”,
… pwd: “m103-pass”,
… roles: [
… {role: “root”, db: “admin”}
… ]
… })
Successfully added user: {
“user” : “m103-admin”,
“roles” : [
{
“role” : “root”,
“db” : “admin”
}
]
}
m103-repl:PRIMARY> exit
bye
bash-4.4# mongod -f mongod_2.conf
about to fork child process, waiting until server is ready for connections.
forked process: 400
child process started successfully, parent exiting
bash-4.4# mongod -f mongod_3.conf
about to fork child process, waiting until server is ready for connections.
forked process: 432
child process started successfully, parent exiting
<le/192.168.103.100:27011" -u “m103-admin”
MongoDB shell version v4.0.5
Enter password:
connecting to: mongodb://192.168.103.100:27011/?gssapiServiceName=mongodb&replicaSet=m103-example
2020-11-15T18:30:39.385+0000 I NETWORK [js] Starting new replica set monitor for m103-example/192.168.103.100:27011
2020-11-15T18:30:44.419+0000 W NETWORK [js] Unable to reach primary for set m103-example
2020-11-15T18:30:44.420+0000 I NETWORK [js] Cannot reach any nodes for set m103-example. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2020-11-15T18:30:49.920+0000 W NETWORK [js] Unable to reach primary for set m103-example
2020-11-15T18:30:49.920+0000 I NETWORK [js] Cannot reach any nodes for set m103-example. Please check network connectivity and the status of the set. This has happened for 2 checks in a row.
^[[^[[A2020-11-15T18:30:55.425+0000 W NETWORK [js] Unable to reach primary for set m103-example
2020-11-15T18:30:55.425+0000 I NETWORK [js] Cannot reach any nodes for set m103-example. Please check network connectivity and the status of the set. This has happened for 3 checks in a row.
2020-11-15T18:30:55.425+0000 E QUERY [js] Error: connect failed to replica set m103-example/192.168.103.100:27011 :
connect@src/mongo/shell/mongo.js:328:13
@(connect):1:6
exception: connect failed
<03-pass" --authenticationDatabase “admin”
MongoDB shell version v4.0.5
connecting to: mongodb://192.168.103.100:27011/?authSource=admin&gssapiServiceName=mongodb&replicaSet=m103-example
2020-11-15T18:31:47.945+0000 I NETWORK [js] Starting new replica set monitor for m103-example/192.168.103.100:27011
2020-11-15T18:31:52.972+0000 W NETWORK [js] Unable to reach primary for set m103-example
2020-11-15T18:31:52.972+0000 I NETWORK [js] Cannot reach any nodes for set m103-example. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2020-11-15T18:31:58.477+0000 W NETWORK [js] Unable to reach primary for set m103-example
2020-11-15T18:31:58.477+0000 I NETWORK [js] Cannot reach any nodes for set m103-example. Please check network connectivity and the status of the set. This has happened for 2 checks in a row.
2020-11-15T18:32:03.982+0000 W NETWORK [js] Unable to reach primary for set m103-example
2020-11-15T18:32:03.982+0000 I NETWORK [js] Cannot reach any nodes for set m103-example. Please check network connectivity and the status of the set. This has happened for 3 checks in a row.
2020-11-15T18:32:03.982+0000 E QUERY [js] Error: connect failed to replica set m103-example/192.168.103.100:27011 :
connect@src/mongo/shell/mongo.js:328:13
@(connect):1:6
exception: connect failed
bash-4.4# ^C
bash-4.4#

=========================Config Files=============================

Num. 1
storage:
dbPath: /var/mongodb/db/1
net:
bindIp: localhost
port: 27001
security:
authorization: enabled
keyFile: /var/mongodb/pki/m103-keyfile
systemLog:
destination: file
path: /var/mongodb/logs/mongod1.log
logAppend: true
processManagement:
fork: true
replication:
replSetName: m103-repl

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Config NUm 2
storage:
dbPath: /var/mongodb/db/2
net:
bindIp: localhost
port: 27002
security:
authorization: enabled
keyFile: /var/mongodb/pki/m103-keyfile
systemLog:
destination: file
path: /var/mongodb/logs/mongod2.log
logAppend: true
processManagement:
fork: true
replication:
replSetName: m103-repl

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Config Num 3

storage:
dbPath: /var/mongodb/db/3
net:
bindIp: localhost
port: 27003
security:
authorization: enabled
keyFile: /var/mongodb/pki/m103-keyfile
systemLog:
destination: file
path: /var/mongodb/logs/mongod3.log
logAppend: true
processManagement:
fork: true
replication:
replSetName: m103-repl

The above is not a valid IP address for the IDE. The lab says to use localhost. The configuration files seem ok as bindIp is set to localhost. When you start mongo, you must connect to localhost.

1 Like

Thanks, for the rapid responses will try out the solution now.

Steve ,

Thanks man!

Thanks @steevej-1495 for helping out @Roger_De_Four!!

~ Shubham