无法连接到独立的mongodb:找不到候选服务器

时间:2013-08-15 14:48:32

标签: php mongodb

我有debian dev服务器和库存mongodb; 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;但这不是解决方案。

2 个答案:

答案 0 :(得分:2)

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

我在安装10-gen版mongodb后解决了我的问题。

答案 1 :(得分:2)

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

pecl uninstall mongo
pecl install mongo-1.3.6