doufu9836 2014-09-22 11:08
浏览 54

在PHP中针对MongoDB副本集运行命令时出错

Running a small mongo replica set with a primary, a secondary and an arbiter. Below is an output of the rs.status() describing the set:

rs0:PRIMARY> rs.status()
{
    "set" : "rs0",
    "date" : ISODate("2014-09-22T11:01:11Z"),
    "myState" : 1,
    "members" : [
        {
            "_id" : 2,
            "name" : "mongo2:27017",
            "health" : 1,
            "state" : 1,
            "stateStr" : "PRIMARY",
            "uptime" : 66657,
            "optime" : Timestamp(1411383252, 1),
            "optimeDate" : ISODate("2014-09-22T10:54:12Z"),
            "electionTime" : Timestamp(1411383118, 1),
            "electionDate" : ISODate("2014-09-22T10:51:58Z"),
            "self" : true
        },
        {
            "_id" : 3,
            "name" : "warehouse:27017",
            "health" : 1,
            "state" : 7,
            "stateStr" : "ARBITER",
            "uptime" : 433,
            "lastHeartbeat" : ISODate("2014-09-22T11:01:10Z"),
            "lastHeartbeatRecv" : ISODate("2014-09-22T11:01:10Z"),
            "pingMs" : 0
        },
        {
            "_id" : 4,
            "name" : "mongo1:27017",
            "health" : 1,
            "state" : 2,
            "stateStr" : "SECONDARY",
            "uptime" : 419,
            "optime" : Timestamp(1411383252, 1),
            "optimeDate" : ISODate("2014-09-22T10:54:12Z"),
            "lastHeartbeat" : ISODate("2014-09-22T11:01:10Z"),
            "lastHeartbeatRecv" : ISODate("2014-09-22T11:01:09Z"),
            "pingMs" : 0,
            "syncingTo" : "mongo2:27017"
        }
    ],
    "ok" : 1
}

All servers are running mongo 2.6.4, the php MongoClient has been updated to the latest version. My computer is running osx 10.9. Running aggregation jobs in the mongo cli seems to be just fine, but as soon as I try to start an aggregation job, I get the following error:

CON FINE: Using 30000 from default with

I'm catching the exception and its code is 0. I can't really make sense of this exception, nor can I find any references to it online. The mongo logs seem to indicate that the connection is being opened and then closed, without any errors. Communication between the servers is also just fine, the keys are copied over and the hosts files are up to date.

I can't seem to be able to run even simple queries like

$m = new MongoClient('mongodb://mongo2/?replicaSet=rs0');
$m->admin->command(array("ismaster" => 1))

Any ideas are appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c