Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
legacy-1.0.0
-
None
Description
when I use simple connection string to connect, it works.
connection string:
|
mongodb://host3:27017
|
when I use connection string for replica set to connect:
connection string:
|
mongodb://host1:27017,host2:27017,host3:27017/MtxEventDatabase?replicaSet=MtxEventReplSet
|
I got following exceptions:
Caught a mongo::DBException.
|
Exception's what()=No replica set monitor active and no cached seed found for set: MtxEventReplSet
|
Here is the related code:
try {
|
std::string errString;
|
mongo::ConnectionString mongoConnectionString = mongo::ConnectionString::parse(hostAndPortStr_,
|
errString);
|
|
|
if (!mongoConnectionString.isValid()) {
|
return false;
|
}
|
|
|
mongoPtr_ = mongoConnectionString.connect(errString);
|
if (!mongoPtr_) {
|
return false;
|
};
|
|
|
if (!mongoPtr_->auth(mongodbDatabase_, mongodbUsername_, mongodbPassword_,
|
errString)) {
|
return false;
|
};
|
} catch (const mongo::DBException& exc) {
|
log_error("Caught a mongo::DBException.\n" <<
|
"Exception's what()=" << exc.what());
|
return false;
|
}
|
catch (...) {
|
return false;
|
}
|
return true;
|
when I try to login from command line it seems to work:
mongo -u <myUser> -p xxxxxxxx --authenticationDatabase <myAuthDb> --host MtxEventReplSet/host1:27017,host2:27017,host3:27017 MtxEventDatabase
|
MongoDB shell version: 3.0.0
|
connecting to: MtxEventReplSet/host1:27017,host2:27017,host3:27017/MtxEventDatabase
|
2015-08-04T15:56:20.015-0700 I NETWORK starting new replica set monitor for replica set MtxEventReplSet with seeds host1:27017,host2:27017,host3:27017
|
2015-08-04T15:56:20.016-0700 I NETWORK [ReplicaSetMonitorWatcher] starting
|
Server has startup warnings:
|
2015-07-31T16:01:59.497-0700 I CONTROL [initandlisten]
|
2015-07-31T16:01:59.497-0700 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 1024 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.
|
MtxEventReplSet:PRIMARY> rs.status()
|
{
|
"set" : "MtxEventReplSet",
|
"date" : ISODate("2015-08-04T22:57:04.777Z"),
|
"myState" : 1,
|
"members" : [
|
{
|
"_id" : 0,
|
"name" : "host1:27017",
|
"health" : 1,
|
"state" : 2,
|
"stateStr" : "SECONDARY",
|
"uptime" : 345298,
|
"optime" : Timestamp(1438725952, 2),
|
"optimeDate" : ISODate("2015-08-04T22:05:52Z"),
|
"lastHeartbeat" : ISODate("2015-08-04T22:57:02.911Z"),
|
"lastHeartbeatRecv" : ISODate("2015-08-04T22:57:04.755Z"),
|
"pingMs" : 0,
|
"syncingTo" : host3:27017",
|
"configVersion" : 1
|
},
|
{
|
"_id" : 1,
|
"name" : "host2:27017",
|
"health" : 1,
|
"state" : 2,
|
"stateStr" : "SECONDARY",
|
"uptime" : 345294,
|
"optime" : Timestamp(1438725952, 2),
|
"optimeDate" : ISODate("2015-08-04T22:05:52Z"),
|
"lastHeartbeat" : ISODate("2015-08-04T22:57:03.155Z"),
|
"lastHeartbeatRecv" : ISODate("2015-08-04T22:57:03.199Z"),
|
"pingMs" : 0,
|
"syncingTo" : "host3:27017",
|
"configVersion" : 1
|
},
|
{
|
"_id" : 2,
|
"name" : "host3:27017",
|
"health" : 1,
|
"state" : 1,
|
"stateStr" : "PRIMARY",
|
"uptime" : 345305,
|
"optime" : Timestamp(1438725952, 2),
|
"optimeDate" : ISODate("2015-08-04T22:05:52Z"),
|
"electionTime" : Timestamp(1438383726, 1),
|
"electionDate" : ISODate("2015-07-31T23:02:06Z"),
|
"configVersion" : 1,
|
"self" : true
|
}
|
],
|
"ok" : 1
|
}
|