奇怪的是,插入操作可以正常工作,但不能删除。我正在使用 MongoDB 3.0.1 副本集、PHP 驱动程序 > 1.5.4 和 Apache 服务器
已经浏览了讨论MongoConnectionException - 未找到候选服务器。
我的代码工作方式如下:
\MongoLog::setModule( \MongoLog::ALL );
\MongoLog::setLevel( \MongoLog::ALL );
$m = new \MongoClient($this->dbConnectionstring, $this->dbOptions);
$db = $m->$dbName;
$c = $db->$collectionName;
try{
$affected = $c->remove($criteria);
} catch (\MongoException $e) {
echo $e->getMessage();
}
但是,它只显示一行:
CON INFO: mongo_get_read_write_connection: finding a REPLSET connection (write)
我尝试了一个更短的is_master_interval
,ping_interval
并重新启动了 Apache。
它不起作用。
与我的远程副本集的连接很好,因为 Mongo Management Studio 工作正常。
它可以显示rs.status()
如下:
{
"set" : "rs0",
"date" : ISODate("2015-07-14T12:15:30.291Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "HIDDEN:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 528078,
"optime" : Timestamp(1436862181, 2),
"optimeDate" : ISODate("2015-07-14T08:23:01Z"),
"lastHeartbeat" : ISODate("2015-07-14T12:15:29.982Z"),
"lastHeartbeatRecv" : ISODate("2015-07-14T12:15:29.982Z"),
"pingMs" : 0,
"syncingTo" : "HIDDEN:27017",
"configVersion" : 633800
},
{
"_id" : 1,
"name" : "HIDDEN:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 528078,
"optime" : Timestamp(1436862181, 2),
"optimeDate" : ISODate("2015-07-14T08:23:01Z"),
"lastHeartbeat" : ISODate("2015-07-14T12:15:29.989Z"),
"lastHeartbeatRecv" : ISODate("2015-07-14T12:15:29.985Z"),
"pingMs" : 0,
"syncingTo" : "HIDDEN:27017",
"configVersion" : 633800
},
{
"_id" : 2,
"name" : "HIDDEN:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 528220,
"optime" : Timestamp(1436862181, 2),
"optimeDate" : ISODate("2015-07-14T08:23:01Z"),
"electionTime" : Timestamp(1436844293, 1),
"electionDate" : ISODate("2015-07-14T03:24:53Z"),
"configVersion" : 633800,
"self" : true
}
],
"ok" : 1
}