1

我有带有股票 mongodb 的 debian 开发服务器;php 5.4 和 pecl mongodb 驱动程序 v1.4.3。我尝试使用 PHP Cli 创建简单的连接并遇到异常:

php -r "MongoLog::setLevel(MongoLog::ALL); MongoLog::setModule(MongoLog::ALL); new MongoClient('mongodb://127.0.0.1:27017', array());"

下面的输出:

PHP Notice:  PARSE   INFO: Parsing mongodb://127.0.0.1:27017 in Command line code on line 1
PHP Notice:  PARSE   INFO: - Found node: 127.0.0.1:27017 in Command line code on line 1
PHP Notice:  PARSE   INFO: - Connection type: STANDALONE in Command line code on line 1
PHP Notice:  CON     INFO: mongo_get_read_write_connection: finding a STANDALONE connection in Command line code on line 1
PHP Notice:  CON     INFO: connection_create: creating new connection for 127.0.0.1:27017 in Command line code on line 1
PHP Notice:  CON     INFO: stream_connect: Not establishing SSL for 127.0.0.1:27017 in Command line code on line 1
PHP Notice:  CON     INFO: get_server_flags: start in Command line code on line 1
PHP Notice:  CON     FINE: send_packet: read from header: 36 in Command line code on line 1
PHP Notice:  CON     FINE: send_packet: data_size: 73 in Command line code on line 1
PHP Notice:  CON     FINE: get_server_flags: can't find maxBsonObjectSize, defaulting to 4194304 in Command line code on line 1
PHP Notice:  CON     FINE: get_server_flags: can't find maxMessageSizeBytes, defaulting to 8388608 in Command line code on line 1
PHP Notice:  CON     INFO: get_server_flags: found server type: UNKNOWN? in Command line code on line 1
PHP Notice:  CON     INFO: is_ping: pinging 127.0.0.1:27017;-;.;29554 in Command line code on line 1
PHP Notice:  CON     FINE: send_packet: read from header: 36 in Command line code on line 1
PHP Notice:  CON     FINE: send_packet: data_size: 69 in Command line code on line 1
PHP Notice:  CON     INFO: is_ping: last pinged at 1376577544; time: 0ms in Command line code on line 1
PHP Notice:  REPLSET FINE: finding candidate servers in Command line code on line 1
PHP Notice:  REPLSET FINE: - all servers in Command line code on line 1
PHP Notice:  REPLSET FINE: filter_connections: adding connections: in Command line code on line 1
PHP Notice:  REPLSET FINE: filter_connections: done in Command line code on line 1
PHP Notice:  REPLSET FINE: limiting by seeded/discovered servers in Command line code on line 1
PHP Notice:  REPLSET FINE: limiting by seeded/discovered servers: done in Command line code on line 1
PHP Notice:  REPLSET FINE: limiting by credentials in Command line code on line 1
    PHP Notice:  REPLSET FINE: limiting by credentials: done in Command line code on line 1
PHP Fatal error:  Uncaught exception 'MongoConnectionException' with message 'No candidate servers found' in Command line code:1
Stack trace:
#0 Command line code(1): MongoClient->__construct('mongodb://127.0...', Array)
#1 {main}
  thrown in Command line code on line 1

我找到了解决方法 - 将驱动程序版本降级到 1.3.6;但这不是解决方案。

4

2 回答 2

2

今天遇到了同样的问题,降级到 pecl 中的 1.3.6 版本的 mongo 驱动程序对我“有效”... 系统:Debian Squeeze 这为您完成了工作:

pecl uninstall mongo
pecl install mongo-1.3.6
于 2013-10-07T12:53:10.367 回答
2

看看:http ://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/

我在安装 10 代版本的 mongodb 后解决了我的问题。

于 2013-08-29T08:19:29.313 回答