无法加载数据库配置。没有这样的文件 - database.yml - OpsWorks

时间:2015-01-22 15:05:30

标签: mysql ruby-on-rails git ruby-on-rails-4 aws-opsworks

我正在使用OpsWorks(Ubuntu 14.04)首次部署我的应用程序,当迁移运行时,我收到此错误:

无法加载数据库配置。没有这样的文件 - /srv/www/todoapp/releases/20150122121517/config/database.yml

我不明白这个错误,因为我的rails应用程序中有一个/config/database.yml,正在被正确推送到bitbucket。

你可以在这里看到我的.gitignore文件:

# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
#   git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp

2 个答案:

答案 0 :(得分:2)

我相信Amazon Opsworks会覆盖您的database.yml文件。您必须添加自定义JSON才能配置生产数据库。

无论如何,这是你的JSON应该是什么样的。

{
  "deploy": {
    "app_short_name": {  # this should be the short name Opsworks has given your app.
      "database": {
        "adapter": "postgresql", # change if you are using mysql
        "encoding": "unicode",
        "host": "your-host",
        "port": "5432", # change if you are using mysql
        "database": "your_database_name",
        "pool": "10",
        "username": "your_database_username",
        "password": "your_database_password"
      }
    }
  }
}

您可以在Opsworks堆栈设置中添加它。

  • 登录您的Opsworks
  • 点击左侧边栏中的Stack
  • 点击Stack settings按钮。
  • 在底部,您会看到配置管理部分。您可以在那里添加自定义JSON以正确配置数据库。

以上设置适用于Postgres数据库配置。您可能需要使用mysql进行一些更改..

我使用Amazon RDS postgres数据库进行此设置。 RDS也支持mysql。

希望这有助于您更快地部署应用程序。祝你好运。

答案 1 :(得分:0)

对于使用RDS实例的任何人,请务必:

  • 创建RDS图层(图层>>添加图层,RDS)
  • 使用您的应用注册实例(应用>>编辑,数据源)
相关问题