Mongo连接失败 [英] Mongo Connection Failure

查看:115
本文介绍了Mongo连接失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Rails的新手。我想将一个简单的Rails应用程序推送到cloudfoundry,但出现错误:

I'm new to rails. I would like to push a simple rails application to cloudfoundry and I am getting an error:

 ====> /logs/stderr.log <====
/var/vcap/data/dea/apps/mytestapp-0
-4a068e3fd2b22422bdd29f3762e9bc9b/app/rubygems/ruby/1.9.1/gems/mongo-
1.6.4/lib/mongo/connection.rb:420:in `connect': Fail:27017  (Mongo::ConnectionFailure)

示例应用程序gemfile:

The sample app gemfile:

source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'mongo_mapper'
gem 'bson_ext'

mongo.yml:

mongo.yml:

defaults: &defaults
host: 127.0.0.1
port: 27017

development:
<<: *defaults 
database: cloud_foundry_rails_tutorial_development

test:
<<: *defaults
database: cloud_foundry_rails_tutorial_test

# set these environment variables on your prod server
production: 
host: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-2.0'].first['credentials']['hostname']  
rescue 'localhost' %>

port: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-2.0'].first['credentials']['port']    
rescue '27017' %>

database: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-2.0'].first['credentials']['db'] 
rescue 'cloud_foundry_rails_tutorial' %>

username: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-2.0'].first['credentials']['username'] 
rescue '' %>

password: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-2.0'].first['credentials']['password'] 
rescue '' %>

我上周能够顺利使用CF,但是现在不起作用了吗? CF方面有什么变化吗?
谢谢

I was able to push to CF last week without any issue but now it doesn't work? Is there something that changed on the CF side? Thanks

推荐答案

CloudFoundry.com上周从MongoDB 1.8升级到了2.0,这很可能会影响您的应用程序。我将与CF.com工程团队联系,并在必要时提交错误。

CloudFoundry.com upgraded from MongoDB 1.8 to 2.0 last week, and that's likely affecting your app. I will be checking with the CF.com engineering team and filing a bug if necessary.

但是,因为您是在中手动指定连接信息mongo.yml ,您是否禁用了服务的自动配置?为此,请创建文件 config / cloudfoundry.yml 并添加:

However, since you're manually specifying connection information in mongo.yml, have you disabled auto-config of services? To do so, create the file config/cloudfoundry.yml and add:

autoconfig: false

有关在Ruby应用程序中自动配置服务的更多信息,请参见 http:// blog.cloudfoundry.com/2012/03/12/using-cloud-foundry-services-with-ruby-part-1-auto-reconfiguration/

For more information on auto-config of services in Ruby apps, see http://blog.cloudfoundry.com/2012/03/12/using-cloud-foundry-services-with-ruby-part-1-auto-reconfiguration/

这篇关于Mongo连接失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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