私は AWS のすべてにまったく慣れておらず、Beanstalk で Rails アプリを起動しようとしています。最近のチュートリアルに従っていますが、アプリを RDS に接続するのに行き詰まっています。パッセンジャー スクリーンに次のエラーが表示されます。
production database is not configured (ActiveRecord::AdapterNotSpecified)
私database.yml
のように見えます:
production:
adapter: mysql2
encoding: utf8
database: <%= ENV['RDS_DB_NAME'] %>
username: <%= ENV['RDS_USERNAME'] %>
password: <%= ENV['RDS_PASSWORD'] %>
host: <%= ENV['RDS_HOSTNAME'] %>
port: <%= ENV['RDS_PORT'] %>
RDS インスタンスを構成して実行しています。また、EC2 インスタンスに ssh 接続し、RDS_USERNAME、RDS_HOSTNAME などを介して RDS に正常に接続できることを確認しました。
おそらく、MySQL でデータベースを手動で作成する必要があると考えて、MySQL クライアントを使用して作成しましたが、それでも同じエラーが発生します。
そこで、再び EC2 インスタンスでプロジェクトを手動でチェックアウトし、実行bundle exec rake db:migrate --trace
して、失敗している場所のより完全な全体像を取得しました。
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
rake aborted!
production database is not configured
/usr/share/ruby/1.9/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:39:in `resolve_string_connection'
/usr/share/ruby/1.9/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
/usr/share/ruby/1.9/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:129:in `establish_connection'
/usr/share/ruby/1.9/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
/usr/share/ruby/1.9/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/usr/share/ruby/1.9/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/usr/share/ruby/1.9/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
/usr/share/ruby/1.9/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:42:in `each'
/usr/share/ruby/1.9/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
/usr/share/ruby/1.9/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/base.rb:721:in `<top (required)>'
/usr/share/ruby/1.9/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:6:in `block (2 levels) in <top (required)>'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:227:in `call'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:227:in `block in execute'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:222:in `each'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:222:in `execute'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/usr/share/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:187:in `block in invoke_prerequisites'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:185:in `each'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:185:in `invoke_prerequisites'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:165:in `block in invoke_with_call_chain'
/usr/share/ruby/1.9/monitor.rb:211:in `mon_synchronize'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:152:in `invoke'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:141:in `invoke_task'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `block (2 levels) in top_level'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `each'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `block in top_level'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:108:in `run_with_threads'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:93:in `top_level'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:71:in `block in run'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:158:in `standard_exception_handling'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:68:in `run'
/usr/share/ruby/1.9/gems/1.9.1/gems/rake-10.0.2/bin/rake:37:in `<top (required)>'
/usr/bin/rake:23:in `load'
/usr/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate => db:load_config