patternMinor
mongodb could not find host matching read preference { mode: \"primary\" } for set?
Viewed 0 times
primaryreadsetmodemongodbcouldhostforfindnot
Problem
I am deploy a monodb sharding, I have deploy a replica set in three machines:
and
and also a mongos in machine:
at last I try to add my replica into mongos:
then I got errors:
dev41:27017,dev42:27017,dev193:27017and
configsvr in three machine:dev41:27019,dev42:27019,dev193:27019and also a mongos in machine:
dev41:28000at last I try to add my replica into mongos:
mongo dev41:28000/admin
sh.addShard('rs0/dev41,dev42,dev193')then I got errors:
{
"ok" : 0,
"errmsg" : "could not find host matching read preference { mode: \"primary\" } for set rs0",
"code" : 133
}Solution
I faced the same issue then looked into Mongos log file and it was saying
can't authenticate to hostname as internal user, error: Authentication failed.
Please see here: internal user authentication and happens with SecKey file and auth- Enabled.
Resolution
I opened mongod.conf file and
was missing so I added that and restart the mongod. Then I created shard again from Mongos and it is working now.
can't authenticate to hostname as internal user, error: Authentication failed.
Please see here: internal user authentication and happens with SecKey file and auth- Enabled.
Resolution
I opened mongod.conf file and
security: authorization: enabled
keyFile: /var/run/mongodb/secKey.key
was missing so I added that and restart the mongod. Then I created shard again from Mongos and it is working now.
Context
StackExchange Database Administrators Q#135240, answer score: 3
Revisions (0)
No revisions yet.