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 C# datagridview 栏位进度
    • ¥15 vue3页面el-table页面数据过多
    • ¥100 vue3中融入gRPC-web
    • ¥15 kali环境运行volatility分析android内存文件,缺profile
    • ¥15 写uniapp时遇到的问题
    • ¥15 vs 2008 安装遇到问题
    • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
    • ¥15 找一个网络防御专家,外包的
    • ¥100 能不能让两张不同的图片md5值一样,(有尝)
    • ¥15 informer代码训练自己的数据集,改参数怎么改