Homework 1.3 - No Primary node

I have a replica set running with X509 authentication setup, but when I’m login each node says it not the primary node

Login Command

mongo -ssl --sslPEMKeyFile client.pem --sslCAFile ca.pem --port 31130 --host database.m310.mongodb.university

terminal

MongoDB Enterprise TO_BE_SECURED:OTHER> db.isMaster()

result of db.isMaster()

{
“hosts” : [
“database.m310.mongodb.university:31120”,
“database.m310.mongodb.university:31121”,
“database.m310.mongodb.university:31122”
],
“setName” : “TO_BE_SECURED”,
“ismaster” : false,
“secondary” : false,
“info” : “Does not have a valid replica set config”,
“isreplicaset” : true,
“maxBsonObjectSize” : 16777216,
“maxMessageSizeBytes” : 48000000,
“maxWriteBatchSize” : 1000,
“localTime” : ISODate(“2019-02-19T06:01:33.641Z”),
“maxWireVersion” : 4,
“minWireVersion” : 0,
“ok” : 1
}

do we need to set it as Primary manually?

After mongods were started did you complete rs.initiate and other nodes addition
It says about replicaset config issue
Please check config files,ports,replset etc

In my case i used this
MongoDB Enterprise > rs.initiate({
… _id: ‘X509REPL’,
… members: [
… { _id: 1, host: ‘database.m310.mongodb.university:31130’ },
… { _id: 2, host: ‘database.m310.mongodb.university:31131’ },
… { _id: 3, host: ‘database.m310.mongodb.university:31132’ }
… ]
… })
{ “ok” : 1 }
MongoDB Enterprise X509REPL:OTHER> rs.status()

Look over this message:

“info” : “Does not have a valid replica set config”,

Look at the mongo port in your connection string: --port 31130
The three replica set ports are: 31120, 31121, 31122

It could be a typo

1 Like

Got the same issue, rs.initiate() resolved the issue. Thanks.