HW.3.1 Validation Script Error

Getting the below error, please find the rs.status() output as well and provide any clue to find the issue.

vagrant@database:~/shared$ ./validate-hw-3.1.sh
{ numMembers: 2019-09-05T06:39:15.143+0000 E QUERY [thread1] TypeError: rs.status(…).members is undefined : @(shell eval):1:22, auditLog: 1 }

FYR.
vagrant@database:~/shared$ mongo --host “HomeWork31/database.M310.mongodb.university:31310” -u “kirby” -p “password” --authenticationDatabase “admin”
MongoDB shell version: 3.2.22
connecting to: HomeWork31/database.M310.mongodb.university:31310/test
2019-09-05T06:39:34.782+0000 I NETWORK [thread1] Starting new replica set monitor for HomeWork31/database.M310.mongodb.university:31310
2019-09-05T06:39:34.787+0000 I NETWORK [thread1] Successfully connected to database.M310.mongodb.university:31310 (1 connections now open to database.M310.mongodb.university:31310 with a 5 second timeout)
2019-09-05T06:39:34.787+0000 I NETWORK [thread1] changing hosts to HomeWork31/database.M310.mongodb.university:31310,database.M310.mongodb.university:31311,database.M310.mongodb.university:31312 from HomeWork31/database.M310.mongodb.university:31310
2019-09-05T06:39:34.791+0000 I NETWORK [ReplicaSetMonitorWatcher] starting
Server has startup warnings:
2019-09-05T05:52:17.158+0000 I CONTROL [initandlisten]
2019-09-05T05:52:17.158+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2019-09-05T05:52:17.158+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-09-05T05:52:17.158+0000 I CONTROL [initandlisten]
2019-09-05T05:52:17.158+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2019-09-05T05:52:17.158+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-09-05T05:52:17.158+0000 I CONTROL [initandlisten]
MongoDB Enterprise HomeWork31:PRIMARY> rs.status2019-09-05T06:39:44.795+0000 I NETWORK [ReplicaSetMonitorWatcher] Successfully connected to database.M310.mongodb.university:31312 (1 connections now open to database.M310.mongodb.university:31312 with a 5 second timeout)
2019-09-05T06:39:44.797+0000 I NETWORK [ReplicaSetMonitorWatcher] Successfully connected to database.M310.mongodb.university:31311 (1 connections now open to database.M310.mongodb.university:31311 with a 5 second timeout)
() rs.status()
{
“set” : “HomeWork31”,
“date” : ISODate(“2019-09-05T06:39:51.406Z”),
“myState” : 1,
“term” : NumberLong(1),
“heartbeatIntervalMillis” : NumberLong(2000),
“members” : [
{
“_id” : 0,
“name” : “database.M310.mongodb.university:31310”,
“health” : 1,
“state” : 1,
“stateStr” : “PRIMARY”,
“uptime” : 2855,
“optime” : {
“ts” : Timestamp(1567662795, 1),
“t” : NumberLong(1)
},
“optimeDate” : ISODate(“2019-09-05T05:53:15Z”),
“electionTime” : Timestamp(1567662775, 2),
“electionDate” : ISODate(“2019-09-05T05:52:55Z”),
“configVersion” : 3,
“self” : true
},
{
“_id” : 1,
“name” : “database.M310.mongodb.university:31311”,
“health” : 1,
“state” : 2,
“stateStr” : “SECONDARY”,
“uptime” : 2798,
“optime” : {
“ts” : Timestamp(1567662795, 1),
“t” : NumberLong(1)
},
“optimeDate” : ISODate(“2019-09-05T05:53:15Z”),
“lastHeartbeat” : ISODate(“2019-09-05T06:39:50.900Z”),
“lastHeartbeatRecv” : ISODate(“2019-09-05T06:39:49.647Z”),
“pingMs” : NumberLong(0),
“syncingTo” : “database.M310.mongodb.university:31310”,
“configVersion” : 3
},
{
“_id” : 2,
“name” : “database.M310.mongodb.university:31312”,
“health” : 1,
“state” : 2,
“stateStr” : “SECONDARY”,
“uptime” : 2795,
“optime” : {
“ts” : Timestamp(1567662795, 1),
“t” : NumberLong(1)
},
“optimeDate” : ISODate(“2019-09-05T05:53:15Z”),
“lastHeartbeat” : ISODate(“2019-09-05T06:39:50.942Z”),
“lastHeartbeatRecv” : ISODate(“2019-09-05T06:39:50.335Z”),
“pingMs” : NumberLong(0),
“syncingTo” : “database.M310.mongodb.university:31310”,
“configVersion” : 3
}
],
“ok” : 1
}
MongoDB Enterprise HomeWork31:PRIMARY>

From the audit log, could see the below entries with non-zero value for result field , after the execution of validation script.

{ “atype” : “authCheck”, “ts” : { “$date” : “2019-09-05T05:53:30.259+0000” }, “local” : { “ip” : “127.0.0.1”, “port” : 31310 }, “remote” : { “ip” : “127.0.0.1”, “port” : 34414 }, “users” : , “roles” : , “param” : { “command” : “drop”, “ns” : “test.myTestCollection”, “args” : { “drop” : “myTestCollection” } }, “result” : 13 }
{ “atype” : “authCheck”, “ts” : { “$date” : “2019-09-05T05:53:30.348+0000” }, “local” : { “ip” : “127.0.0.1”, “port” : 31310 }, “remote” : { “ip” : “127.0.0.1”, “port” : 34415 }, “users” : , “roles” : , “param” : { “command” : “create”, “ns” : “test.myTestCollection”, “args” : { “create” : “myTestCollection” } }, “result” : 13 }

Able to resolve the issue by disabling the below parameters in the config file. Thank you.

security:
keyFile: /home/vagrant/mongodb-keyfile
authorization: enabled

1 Like