简体   繁体   English

在Elastic Beanstalk环境上的Rails应用程序上部署ruby时发生AWS Database Migration Error

[英]AWS Database Migration Error while deploying ruby on rails app on Elastic Beanstalk Environment

As I'm trying to deploy my RoR app through AWS Elastic Beanstalk Environment, I'm getting the following error on the console : 在尝试通过AWS Elastic Beanstalk Environment部署RoR应用程序时,在控制台上出现以下错误:

ERROR: [Instance: i-0c1d25d2a182d8424] Command failed on instance. Return code: 1 Output: (TRUNCATED)...ly and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
/opt/rubies/ruby-2.5.0/bin/bundle:23:in `load'
/opt/rubies/ruby-2.5.0/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace). 
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
ERROR: Unsuccessful command execution on instance id(s) 'i-0c1d25d2a182d8424'. Aborting the operation.
ERROR: Failed to deploy application.  

The following is my configuration in the database.yml 以下是我在database.yml中的配置

production:
  <<: *default
  database: <%= ENV['RDS_DB_NAME'] %>
  username: <%= ENV['RDS_USERNAME'] %>
  host: <%= ENV['RDS_HOSTNAME'] %>
  password: <%= ENV['RDS_PASSWORD'] %>
  port: <%= ENV['RDS_PORT'] %>

And the following is the error as reported on the log : 以下是在日志中报告的错误:

  ++ export RUBY_ROOT=/opt/rubies/ruby-2.5.0
  ++ RUBY_ROOT=/opt/rubies/ruby-2.5.0
  ++ export RUBYOPT=
  ++ RUBYOPT=
  ++ export PATH=/opt/rubies/ruby-2.5.0/bin:/opt/elasticbeanstalk/lib/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
  ++ PATH=/opt/rubies/ruby-2.5.0/bin:/opt/elasticbeanstalk/lib/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
  +++ /opt/rubies/ruby-2.5.0/bin/ruby -
  ++ eval 'export RUBY_ENGINE=ruby;
  export RUBY_VERSION=2.5.0;
  export GEM_ROOT="/opt/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0";'
  +++ export RUBY_ENGINE=ruby
  +++ RUBY_ENGINE=ruby
  +++ export RUBY_VERSION=2.5.0
  +++ RUBY_VERSION=2.5.0
  +++ export GEM_ROOT=/opt/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0
  +++ GEM_ROOT=/opt/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0
  ++ ((  0 != 0  ))
  + cd /var/app/ondeck
  + su -s /bin/bash -c 'bundle exec /opt/elasticbeanstalk/support/scripts/check-for-rake-task.rb db:migrate' webapp
  `/home/webapp` is not a directory.
  Bundler will use `/tmp/bundler/home/webapp' as your home directory temporarily.
  + '[' false = true ']'
  + su -s /bin/bash -c 'leader_only bundle exec rake db:migrate' webapp
  `/home/webapp` is not a directory.
  Bundler will use `/tmp/bundler/home/webapp' as your home directory temporarily.
  rake aborted!
  PG::ConnectionBad: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
  /opt/rubies/ruby-2.5.0/bin/bundle:23:in `load'
  /opt/rubies/ruby-2.5.0/bin/bundle:23:in `<main>'
  Tasks: TOP => db:migrate
  (See full trace by running task with --trace) (Executor::NonZeroExitStatus) 

Also, rake db:migrate works fine locally. 另外,rake db:migrate在本地也可以正常工作。 I have no idea what could be going on here, for the database I tried to import a snapshot of an instance of the database I already had on AWS RDS, but I also tried to create a new database. 我不知道这里会发生什么,对于该数据库,我试图导入一个我已经在AWS RDS上拥有的数据库实例的快照,但是我也尝试创建一个新数据库。

If you think if you have any idea of what could be hapening here, if would be really appreciated if you could let me know. 如果您认为自己对这里可能发生的事情有任何想法,请告诉我,我们将不胜感激。

Thanks in advance. 提前致谢。

As your comment, I believe that you missed configurate RDS_* in Elastic Beanstalk. 作为您的评论,我相信您没有在Elastic Beanstalk中配置RDS_ *。 To fix that: 要解决此问题:

  1. To configurate all RDS_*, please follow this guideline here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-cfg-softwaresettings.html#environments-cfg-softwaresettings-console . 要配置所有RDS_ *,请在此处遵循此准则: https ://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-cfg-softwaresettings.html#environments-cfg-softwaresettings-console。
  2. Redeploy your application. 重新部署您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM