无法连接到独立的 mongodb:找不到候选服务器 [英] Can't connect to standalone mongodb: No candidate servers found

查看:67
本文介绍了无法连接到独立的 mongodb:找不到候选服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have debian dev server with stock mongodb; php 5.4 and pecl mongodb drivers v1.4.3. I tried to create simple conntection using PHP Cli and got exception:

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;但这不是解决方案.

I have found workaround - is downgrade dirver version to 1.3.6; but it is not a solution.

推荐答案

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

Had the same problem today, downgraded to the 1.3.6 version of mongo driver in pecl "worked" for me... System: Debian Squeeze This does the job for you:

pecl uninstall mongo
pecl install mongo-1.3.6

这篇关于无法连接到独立的 mongodb:找不到候选服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆