@007_jb,
below is what i get after i add the node on port 31131 and then i am unable to connect on 31130 cause it becomes secondary…
last time i did rs.add i did is fast without checking the rs.status in between.
---------------------------------------------------------------------------------------------------------
MongoDB Enterprise CERT_SECURED:PRIMARY> db.getSiblingDB("$external").runCommand({createUser: “C=US,ST=New York,L=New York City,O=MongoDB,OU=University2,CN=M310 Client”, roles: [{role: ‘root’, db: ‘admin’}]})
{ “ok” : 1 }
MongoDB Enterprise CERT_SECURED:PRIMARY> db.getSiblingDB("$external").auth({user: “C=US,ST=New York,L=New York City,O=MongoDB,OU=University2,CN=M310 Client”, mechanism: “MONGODB-X509”})
1
MongoDB Enterprise CERT_SECURED:PRIMARY> rs.status()
{
“set” : “CERT_SECURED”,
“date” : ISODate(“2020-01-14T05:46:19.902Z”),
“myState” : 1,
“term” : NumberLong(1),
“heartbeatIntervalMillis” : NumberLong(2000),
“members” : [
{
“_id” : 0,
“name” : “database:31130”,
“health” : 1,
“state” : 1,
“stateStr” : “PRIMARY”,
“uptime” : 174,
“optime” : {
“ts” : Timestamp(1578980751, 4),
“t” : NumberLong(1)
},
“optimeDate” : ISODate(“2020-01-14T05:45:51Z”),
“infoMessage” : “could not find member to sync from”,
“electionTime” : Timestamp(1578980719, 2),
“electionDate” : ISODate(“2020-01-14T05:45:19Z”),
“configVersion” : 1,
“self” : true
}
],
“ok” : 1
}
MongoDB Enterprise CERT_SECURED:PRIMARY> rs.add(“database.m310.mongodb.university:31131”)
{ “ok” : 1 }
MongoDB Enterprise CERT_SECURED:PRIMARY> rs.status()
{
“set” : “CERT_SECURED”,
“date” : ISODate(“2020-01-14T05:50:58.005Z”),
“myState” : 1,
“term” : NumberLong(1),
“heartbeatIntervalMillis” : NumberLong(2000),
“members” : [
{
“_id” : 0,
“name” : “database:31130”,
“health” : 1,
“state” : 1,
“stateStr” : “PRIMARY”,
“uptime” : 453,
“optime” : {
“ts” : Timestamp(1578981051, 1),
“t” : NumberLong(1)
},
“optimeDate” : ISODate(“2020-01-14T05:50:51Z”),
“electionTime” : Timestamp(1578980719, 2),
“electionDate” : ISODate(“2020-01-14T05:45:19Z”),
“configVersion” : 2,
“self” : true
},
{
“_id” : 1,
“name” : “database.m310.mongodb.university:31131”,
“health” : 1,
“state” : 0,
“stateStr” : “STARTUP”,
“uptime” : 6,
“optime” : {
“ts” : Timestamp(0, 0),
“t” : NumberLong(-1)
},
“optimeDate” : ISODate(“1970-01-01T00:00:00Z”),
“lastHeartbeat” : ISODate(“2020-01-14T05:50:57.531Z”),
“lastHeartbeatRecv” : ISODate(“1970-01-01T00:00:00Z”),
“pingMs” : NumberLong(4),
“configVersion” : -2
}
],
“ok” : 1
}
MongoDB Enterprise CERT_SECURED:PRIMARY> rs.status()
2020-01-14T05:51:21.713+0000 E QUERY [thread1] Error: error doing query: failed: network error while attempting to run command ‘replSetGetStatus’ on host ‘localhost:31130’ :
DB.prototype.runCommand@src/mongo/shell/db.js:135:1
DB.prototype.adminCommand@src/mongo/shell/db.js:152:1
rs.status@src/mongo/shell/utils.js:1111:12
@(shell):1:1
2020-01-14T05:51:21.716+0000 I NETWORK [thread1] trying reconnect to localhost:31130 (127.0.0.1) failed
2020-01-14T05:51:21.735+0000 I NETWORK [thread1] reconnect localhost:31130 (127.0.0.1) ok
MongoDB Enterprise CERT_SECURED:SECONDARY>
MongoDB Enterprise CERT_SECURED:SECONDARY> exit
bye
---------------------------------------------------------------------------------------------------------
Also i cannot give the replset name casue there is no primary
Will redo the lab.
i think after i create the user i have to connect to replset first.
What i do not know is how do i connect to replset name using the user which essentially is the subject of client cert.
PS:- yeah i named the repl set CERT_SECURED
and will be deleting the post since it may possibly have answers to lab.
TA,
Samir