Troubled with Repl Set

I followed the instructions in the lab to the letter and am having the following error when running the validation. Not sure where I went wrong. Individual mongod’s are up and running fine.

Client experienced a timeout when connecting to the database - check that mongod
processes are running on ports 27001, 27002 and 27003, and that the ‘m103-admin’
user authenticates against the admin database.

Any ideas?

Alex

Hi @farmbuoy,

I would suggest you to check if the replica set name is correct as mentioned in the lab notes.

Meanwhile, could you please share the output rs.status() and rs.isMaster() commands and the output of db.getUsers() from the mongo shell?

Hi. Still having trouble. Here is my rs.isMaster()–MongoDB Enterprise m103-example:PRIMARY> rs.isMaster()
{
“hosts” : [
“192.168.103.100:27001”,
“192.168.103.100:27002”,
“192.168.103.100:27003”
],
“setName” : “m103-example”,
“setVersion” : 3,
“ismaster” : true,
“secondary” : false,
“primary” : “192.168.103.100:27001”,
“me” : “192.168.103.100:27001”,
“electionId” : ObjectId(“7fffffff0000000000000006”),
“lastWrite” : {
“opTime” : {
“ts” : Timestamp(1572295515, 1),
“t” : NumberLong(6)
},
“lastWriteDate” : ISODate(“2019-10-28T20:45:15Z”),
“majorityOpTime” : {
“ts” : Timestamp(1572295515, 1),
“t” : NumberLong(6)
},
“majorityWriteDate” : ISODate(“2019-10-28T20:45:15Z”)
},
“maxBsonObjectSize” : 16777216,
“maxMessageSizeBytes” : 48000000,
“maxWriteBatchSize” : 100000,
“localTime” : ISODate(“2019-10-28T20:45:19.693Z”),
“logicalSessionTimeoutMinutes” : 30,
“minWireVersion” : 0,
“maxWireVersion” : 6,
“readOnly” : false,
“ok” : 1,
“operationTime” : Timestamp(1572295515, 1),
“$clusterTime” : {
“clusterTime” : Timestamp(1572295515, 1),
“signature” : {
“hash” : BinData(0,“xS0Ngbodthf+Yi3wVgPoDGcWxLk=”),
“keyId” : NumberLong(“6750782355507511297”)
}
}
}

And my rs.status() MongoDB Enterprise m103-example:PRIMARY> rs.status()
{
“set” : “m103-example”,
“date” : ISODate(“2019-10-28T20:49:08.084Z”),
“myState” : 1,
“term” : NumberLong(6),
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“heartbeatIntervalMillis” : NumberLong(2000),
“optimes” : {
“lastCommittedOpTime” : {
“ts” : Timestamp(1572295745, 1),
“t” : NumberLong(6)
},
“readConcernMajorityOpTime” : {
“ts” : Timestamp(1572295745, 1),
“t” : NumberLong(6)
},
“appliedOpTime” : {
“ts” : Timestamp(1572295745, 1),
“t” : NumberLong(6)
},
“durableOpTime” : {
“ts” : Timestamp(1572295745, 1),
“t” : NumberLong(6)
}
},
“members” : [
{
“_id” : 0,
“name” : “192.168.103.100:27001”,
“health” : 1,
“state” : 1,
“stateStr” : “PRIMARY”,
“uptime” : 688,
“optime” : {
“ts” : Timestamp(1572295745, 1),
“t” : NumberLong(6)
},
“optimeDate” : ISODate(“2019-10-28T20:49:05Z”),
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“infoMessage” : “”,
“electionTime” : Timestamp(1572295103, 1),
“electionDate” : ISODate(“2019-10-28T20:38:23Z”),
“configVersion” : 3,
“self” : true,
“lastHeartbeatMessage” : “”
},
{
“_id” : 1,
“name” : “192.168.103.100:27002”,
“health” : 1,
“state” : 2,
“stateStr” : “SECONDARY”,
“uptime” : 651,
“optime” : {
“ts” : Timestamp(1572295745, 1),
“t” : NumberLong(6)
},
“optimeDurable” : {
“ts” : Timestamp(1572295745, 1),
“t” : NumberLong(6)
},
“optimeDate” : ISODate(“2019-10-28T20:49:05Z”),
“optimeDurableDate” : ISODate(“2019-10-28T20:49:05Z”),
“lastHeartbeat” : ISODate(“2019-10-28T20:49:06.705Z”),
“lastHeartbeatRecv” : ISODate(“2019-10-28T20:49:07.564Z”),
“pingMs” : NumberLong(0),
“lastHeartbeatMessage” : “”,
“syncingTo” : “192.168.103.100:27001”,
“syncSourceHost” : “192.168.103.100:27001”,
“syncSourceId” : 0,
“infoMessage” : “”,
“configVersion” : 3
},
{
“_id” : 2,
“name” : “192.168.103.100:27003”,
“health” : 1,
“state” : 2,
“stateStr” : “SECONDARY”,
“uptime” : 614,
“optime” : {
“ts” : Timestamp(1572295745, 1),
“t” : NumberLong(6)
},
“optimeDurable” : {
“ts” : Timestamp(1572295745, 1),
“t” : NumberLong(6)
},
“optimeDate” : ISODate(“2019-10-28T20:49:05Z”),
“optimeDurableDate” : ISODate(“2019-10-28T20:49:05Z”),
“lastHeartbeat” : ISODate(“2019-10-28T20:49:06.831Z”),
“lastHeartbeatRecv” : ISODate(“2019-10-28T20:49:07.785Z”),
“pingMs” : NumberLong(0),
“lastHeartbeatMessage” : “”,
“syncingTo” : “192.168.103.100:27002”,
“syncSourceHost” : “192.168.103.100:27002”,
“syncSourceId” : 1,
“infoMessage” : “”,
“configVersion” : 3
}
],
“ok” : 1,
“operationTime” : Timestamp(1572295745, 1),
“$clusterTime” : {
“clusterTime” : Timestamp(1572295745, 1),
“signature” : {
“hash” : BinData(0,“PWWtmcg3gY6ArWNKIGdJHEMg/4Y=”),
“keyId” : NumberLong(“6750782355507511297”)
}
}
}

and my db.getUsers() [ ]

It appears that I don’t have the repl set name correct and I may not have set up the admin user correctly. Tried fixing but still no luck.

Not sure what to do next.

That’s the problem.

Also please enclose code in backticks so that it’s legible. Here’s how:
image

Sorry for the code separation. First time posting in a forum like this. So to fix. Do I have to delete everything and start from scratch or just fix the user and the repl set name. Changing the repl set name caused the dbs to show OTHER> as the rs state when logging in.

Up to you really. My suggestion would be to destroy the servers, delete the directories you created and start afresh. That way you’re working through it step by step instead of trying to debug. But keep your config files.

Basically db.getUsers() must return a user. Create the user as specified in the lab and ensure that your config file enforces authentication.

Hi @farmbouy,

In this particular case, you are getting error because you have not followed the instructions properly mentioned in the Lab and hence I would recommend you to start fresh if you want to take the easier route.

That being said, you can definitely change the name of your replica set but it would be a lot of work. Here is what you can do :

  1. Kill all running mongod instances by using the command killall mongod

  2. For each node make the following changes in its configuration file.

    2.1 Remove the replication parameter and all of its content.

    2.2 Remove the security parameter and all of its content.

Once you have removed the following fields in each of the configuration file then launch the mongod instances one by one and do the following for each one of them.

  1. Connect to each node seperately.

  2. Connect to the local database by using the use local command

  3. Drop the local database by running the following command db.dropDatabase()

Once you are done with all these then add all the parameters back to each configuration file that you removed (replication and security). Make sure you have changed the name of your replica set.

  1. Start the mongod instance again and initiate the replica set and add the user as instructed in the Lab.

Hope it helps!

If you have any other issue then please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer