MongoDB Enterprise m103-repl:SECONDARY>

Hi

Regarding lab " Lab - Initiate a Replica Set Locally"
i am runing the command “mongo --port 27001”
and the results is not like in the video example , i am getting this line
“MongoDB Enterprise m103-repl:SECONDARY>”
why it connects to secondary node , i have only one node up?

Thanks

Is your setup complete?
Please check rs.status()
You should see one primary and two secondaries

i follow all the instructions, its the second time i do this course
because there are a lot of problems with the labs.

MongoDB Enterprise m103-repl:SECONDARY> rs.status()
{
“set” : “m103-repl”,
“date” : ISODate(“2019-05-19T14:41:16.875Z”),
“myState” : 2,
“term” : NumberLong(3),
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“heartbeatIntervalMillis” : NumberLong(2000),
“optimes” : {
“lastCommittedOpTime” : {
“ts” : Timestamp(0, 0),
“t” : NumberLong(-1)
},
“appliedOpTime” : {
“ts” : Timestamp(1555970106, 1),
“t” : NumberLong(3)
},
“durableOpTime” : {
“ts” : Timestamp(1555970106, 1),
“t” : NumberLong(3)
}
},
“members” : [
{
“_id” : 0,
“name” : “m103:27001”,
“health” : 1,
“state” : 2,
“stateStr” : “SECONDARY”,
“uptime” : 4128,
“optime” : {
“ts” : Timestamp(1555970106, 1),
“t” : NumberLong(3)
},
“optimeDate” : ISODate(“2019-04-22T21:55:06Z”),
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“infoMessage” : “”,
“configVersion” : 4,
“self” : true,
“lastHeartbeatMessage” : “”
},
{
“_id” : 1,
“name” : “m103-repl:27002”,
“health” : 0,
“state” : 8,
“stateStr” : “(not reachable/healthy)”,
“uptime” : 0,
“optime” : {
“ts” : Timestamp(0, 0),
“t” : NumberLong(-1)
},
“optimeDurable” : {
“ts” : Timestamp(0, 0),
“t” : NumberLong(-1)
},
“optimeDate” : ISODate(“1970-01-01T00:00:00Z”),
“optimeDurableDate” : ISODate(“1970-01-01T00:00:00Z”),
“lastHeartbeat” : ISODate(“2019-05-19T14:41:14.945Z”),
“lastHeartbeatRecv” : ISODate(“1970-01-01T00:00:00Z”),
“pingMs” : NumberLong(0),
“lastHeartbeatMessage” : “Couldn’t get a connection within the time limit”,
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“infoMessage” : “”,
“configVersion” : -1
},
{
“_id” : 2,
“name” : “m103-repl:27003”,
“health” : 0,
“state” : 8,
“stateStr” : “(not reachable/healthy)”,
“uptime” : 0,
“optime” : {
“ts” : Timestamp(0, 0),
“t” : NumberLong(-1)
},
“optimeDurable” : {
“ts” : Timestamp(0, 0),
“t” : NumberLong(-1)
},
“optimeDate” : ISODate(“1970-01-01T00:00:00Z”),
“optimeDurableDate” : ISODate(“1970-01-01T00:00:00Z”),
“lastHeartbeat” : ISODate(“2019-05-19T14:41:14.786Z”),
“lastHeartbeatRecv” : ISODate(“1970-01-01T00:00:00Z”),
“pingMs” : NumberLong(0),
“lastHeartbeatMessage” : “Couldn’t get a connection within the time limit”,
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“infoMessage” : “”,
“configVersion” : -1
}
],
“ok” : 1,
“operationTime” : Timestamp(1555970106, 1),
“$clusterTime” : {
“clusterTime” : Timestamp(1555970106, 1),
“signature” : {
“hash” : BinData(0,“5P/6GNgwYr7b1CN+JpCmKNJsmUs=”),
“keyId” : NumberLong(“6682430652526100481”)
}
}
}

Please check mongods started on ports 27002 and 27003.Did you get any errors.How many mongods running now?
ps -ef|grep mongod
It says not healthy/not reachable
Are you able to connect to individual mongods with user/pwd?

Hi

There are 3 mongods running.
regarding connecting to individual mongods:

vagrant@m103:~$ mongo admin --port 27002 -u m103-admin -p m103-pass
MongoDB shell version v3.6.12
connecting to: mongodb://127.0.0.1:27002/admin?gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“c252a60e-6df5-4688-a0e9-db0cf633d251”) }
MongoDB server version: 3.6.12
Server has startup warnings:
2019-05-19T13:42:37.088+0000 I STORAGE [initandlisten]
2019-05-19T13:42:37.088+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-05-19T13:42:37.088+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-05-19T13:42:38.056+0000 I CONTROL [initandlisten]
2019-05-19T13:42:38.056+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2019-05-19T13:42:38.056+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-05-19T13:42:38.056+0000 I CONTROL [initandlisten]
2019-05-19T13:42:38.056+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2019-05-19T13:42:38.056+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-05-19T13:42:38.056+0000 I CONTROL [initandlisten]
MongoDB Enterprise m103-repl:OTHER>

vagrant@m103:~$ mongo admin --port 27003 -u m103-admin -p m103-pass
MongoDB shell version v3.6.12
connecting to: mongodb://127.0.0.1:27003/admin?gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“b48d5501-8ae5-40de-a498-949cf2a620e8”) }
MongoDB server version: 3.6.12
Server has startup warnings:
2019-05-19T13:48:35.213+0000 I STORAGE [initandlisten]
2019-05-19T13:48:35.213+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-05-19T13:48:35.213+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-05-19T13:48:36.249+0000 I CONTROL [initandlisten]
2019-05-19T13:48:36.249+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2019-05-19T13:48:36.249+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-05-19T13:48:36.249+0000 I CONTROL [initandlisten]
2019-05-19T13:48:36.249+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2019-05-19T13:48:36.249+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-05-19T13:48:36.249+0000 I CONTROL [initandlisten]
MongoDB Enterprise m103-repl:OTHER>

regarding errors there are alot of errors in mongod.log

2019-05-20T06:14:09.320+0000 I ASIO [NetworkInterfaceASIO-Replication-0] Connecting to m103-repl:27003
2019-05-20T06:14:09.807+0000 I REPL [rsBackgroundSync] waiting for 4 pings from other members before syncing
2019-05-20T06:14:10.020+0000 I REPL_HB [replexec-40] Error in heartbeat (requestId: 66113) to m103-repl:27003, response status: NetworkInterfaceExceededTimeLimit: Coul
dn’t get a connection within the time limit
2019-05-20T06:14:10.058+0000 I REPL_HB [replexec-40] Error in heartbeat (requestId: 66114) to m103-repl:27002, response status: NetworkInterfaceExceededTimeLimit: Coul
dn’t get a connection within the time limit
2019-05-20T06:14:15.215+0000 I REPL [replexec-40] Not starting an election, since we are not electable due to: Not standing for election because I cannot see a majo
rity (mask 0x1)

i dont understand why when i am running the rs.conf() command i am getting wrong hostname

“_id” : “m103-repl”,
“version” : 4,
“protocolVersion” : NumberLong(1),
“members” : [
{
“_id” : 0,
“host” : “m103:27001”,
“arbiterOnly” : false,
“buildIndexes” : true,
“hidden” : false,
“priority” : 1,
“tags” : {

                    },
                    "slaveDelay" : NumberLong(0),
                    "votes" : 1
            },
            {
                    "_id" : 1,
                    "host" : "m103-repl:27002",
                    "arbiterOnly" : false,
                    "buildIndexes" : true,
                    "hidden" : false,
                    "priority" : 1,
                    "tags" : {

                    },
                    "slaveDelay" : NumberLong(0),
                    "votes" : 1
            },
            {
                    "_id" : 2,
                    "host" : "m103-repl:27003",
                    "arbiterOnly" : false,
                    "buildIndexes" : true,
                    "hidden" : false,
                    "priority" : 1,
                    "tags" : {

                    },
                    "slaveDelay" : NumberLong(0),
                    "votes" : 1
            }
    ],
    "settings" : {
            "chainingAllowed" : true,
            "heartbeatIntervalMillis" : 2000,
            "heartbeatTimeoutSecs" : 10,
            "electionTimeoutMillis" : 10000,
            "catchUpTimeoutMillis" : -1,
            "catchUpTakeoverDelayMillis" : 30000,
            "getLastErrorModes" : {

            },
            "getLastErrorDefaults" : {
                    "w" : 1,
                    "wtimeout" : 0
            },
            "replicaSetId" : ObjectId("5cbcc34416f9a0002748c050")
    }

}

Can anyone help?
its the second time i do that course and still with the same lab problems.

Hi @Tal_38236,

I can see that you are able to launch all three nodes. Now, please follow these steps:

  1. Connect to Node1 running on port 27001 and do rs.initiate().

  2. Then switch to the admin database and create the user m103-admin using the localhost exception on primary node i.e. Node1 and exit the shell.

  3. Again try connecting to the node1 by specifying the hostname, username, password and authentication database parameters.

  4. Then add the other 2 nodes in the replica set.

  5. Now you can check the topology of the replica set using rs.isMaster() or check the status using rs.status().

I hope it helps!!

Please keep going through the lab along with the steps above.
If you still face any issue in above mentioned steps, please share the screenshot of the command with the error.

Thanks,
Sonali

Hi
Thanks for the quick reply.

regarding step 1 it stuck

vagrant@m103:/shared$ mongo --port 27001
MongoDB shell version v3.6.12
connecting to: mongodb://127.0.0.1:27001/?gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“56315084-ef3e-4f4b-8287-67c34af31155”) }
MongoDB server version: 3.6.12
MongoDB Enterprise m103-repl:SECONDARY> rs.initiate().

Hi @Tal_38236,

Please refer to the screenshot below:

Are you able to see any such message after you do rs.initiate().

Thanks,
Sonali

Hi @Tal_38236,

It is correct!!

Please go ahead and create the user and follow the further steps.

Let me know, if you have any doubt.

Thanks,
Sonali

MongoDB Enterprise m103-repl:SECONDARY> use admin
switched to db admin
MongoDB Enterprise m103-repl:SECONDARY> db.createUser({
… user: “m103-admin”,
… pwd: “m103-pass”,
… roles: [
… {role: “root”, db: “admin”}
… ]
… })
2019-05-21T09:52:31.250+0000 E QUERY [thread1] Error: couldn’t add user: there are no users authenticated :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1437:15
@(shell):1:1

any suggestions?..