可以';t连接到独立的mongodb:找不到候选服务器


Can't connect to standalone mongodb: No candidate servers found

我有一个debian dev服务器,带有stock mongodb;php5.4和peclmongodb驱动程序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

我已经找到了解决办法-是将dirver版本降级到1.3.6;但这不是一个解决方案。

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

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

今天也遇到了同样的问题,在pecl中降级为1.3.6版本的mongo驱动程序为我"工作"…系统:Debian Squeeze这为您完成了任务:

pecl uninstall mongo
pecl install mongo-1.3.6