0

我对 MongoDB 有疑问。

首先,在运行时mongod,然后mongo(在另一个终端窗口中),我得到:

MongoDB shell version: 2.2.2
connecting to: test
> 
> 

然而。当我输入rails console我的 Heroku 应用程序终端时,我得到:

Failed to connect to a master node at 127.0.0.1:9100 (Mongo::ConnectionFailure)
from /Users/musetr/.rvm/gems/ruby-1.9.3-p327@rails3tutorial2ndEd/gems/mongo-1.6.4/lib/mongo/connection.rb:594:in `setup'
from /Users/musetr/.rvm/gems/ruby-1.9.3-p327@rails3tutorial2ndEd/gems/mongo-1.6.4/lib/mongo/connection.rb:130:in `initialize'
from /Users/mmusetr/.rvm/gems/ruby-1.9.3-p327@rails3tutorial2ndEd/gems/mongo_mapper-0.12.0/lib/mongo_mapper/connection.rb:79:in `new'
from /Users/musetr/.rvm/gems/ruby-1.9.3-p327@rails3tutorial2ndEd/gems/mongo_mapper-0.12.0/lib/mongo_mapper/connection.rb:79:in `connect'
from /Users/musetr/.rvm/gems/ruby-1.9.3-p327@rails3tutorial2ndEd/gems/mongo_mapper-0.12.0/lib/mongo_mapper/connection.rb:89:in `setup'

.. 任何帮助将不胜感激。

4

1 回答 1

0

如果没有端口选项,mongod 和 mongo 都使用默认端口号 27017。rails 控制台的输出报告它正在尝试连接到端口 9100。请检查 config/mongo.yml 中的 MongoMapper 配置,与您的环境检查相关变量 RAILS_ENV。

于 2013-02-21T20:25:03.743 回答