部署到Elastic Beanstalk失败,并显示“无法分配内存"错误 [英] Deployment to Elastic Beanstalk fails with 'Cannot allocate memory' error

查看:65
本文介绍了部署到Elastic Beanstalk失败,并显示“无法分配内存"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我构建了一个Rails应用程序,该应用程序要部署到弹性beantalk.我能够将其部署到我的AWS账户,但是现在我想将其部署到我的客户账户.由于某种原因,在尝试部署它时出现错误.能够从头开始将其部署到我的帐户,并能够将其部署到heroku,但是每次尝试将其部署到我的客户帐户时,我都会遇到很多错误.两个帐户之间是否有可能会有所不同的设置?我不明白为什么部署到两个帐户会有什么不同.我尝试了所有可以找到的解决方案.

I built a rails application that I want to deploy to elastic beanstalk. I was able to deploy it to my AWS account but now I want to deploy it to my clients account. For some reason it I get errors when trying to deploy it. Have been able to deploy it to my account from scratch and been able to deploy it to heroku but every time I try to deploy it to my clients account I get a bunch of errors. Are there possible settings that would be different between the two accounts? I don't understand why deploying to the two accounts would be any different. I have tried every solution I could find.

这是日志.我不确定他们是否会帮助

Here are the logs. I am not sure if they will help

  gem 'bootstrap-sass'
  gem 'autoprefixer-rails'
  gem 'puma'

  group :development, :test do
    gem "letter_opener"
    gem 'byebug'
  end

  group :development do
    gem 'web-console', '~> 2.0'
    gem 'spring'
  end

  group :production do
    # gem 'pg'
    gem 'rails_12factor'
  end
  + '[' -d /var/app/ondeck/vendor/cache ']'
  + bundle install
  Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
  installing your bundle as root will break this application for all non-root
  users on this machine.
  Warning: the running version of Bundler is older than the version that created the lockfile. We sugg
est you upgrade to the latest version of Bundler by running `gem install bundler`.
  Fetching gem metadata from https://rubygems.org/
  Fetching version metadata from https://rubygems.org/
  Fetching dependency metadata from https://rubygems.org/
  Using rake 11.1.2
  Using i18n 0.7.0
  Installing json 1.8.3 with native extensions

  Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

      /opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-1pc5aw8.rb extconf.rb
  Cannot allocate memory - /opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-1pc5aw8.rb extcon
f.rb 2>&1

  Gem files will remain installed in /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/json-1.8.3 for in
spection.
  Results logged to /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0-static/js
on-1.8.3/gem_make.out
  Using minitest 5.9.0
  Using thread_safe 0.3.5
  Using builder 3.2.2
  Using erubis 2.7.0
  Using mini_portile2 2.1.0
  Using pkg-config 1.1.7
  Using rack 1.6.4
  Using mime-types-data 3.2016.0521
  Using arel 6.0.3
  Using execjs 2.7.0
  Installing bcrypt 3.1.10 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

      /opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-myt7e8.rb extconf.rb
  Cannot allocate memory - /opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-myt7e8.rb extconf.rb 2>&1

  Gem files will remain installed in /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/bcrypt-3.1.10 for inspection.
  Results logged to /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0-static/bcrypt-3.1.10/gem_make.out
  Using sass 3.4.22
  Using coffee-script-source 1.10.0
  Using thor 0.19.1
  Using concurrent-ruby 1.0.2
  Using multi_json 1.12.1
  Using libv8 3.16.14.15
  Installing puma 3.4.0 with native extensions

  Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

      /opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-kv1g4s.rb extconf.rb
  Cannot allocate memory - /opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-kv1g4s.rb extconf.rb 2>&1

  Gem files will remain installed in /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/puma-3.4.0 for inspection.
  Results logged to /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0-static/puma-3.4.0/gem_make.out
  Using bundler 1.12.1
  Using rails_serve_static_assets 0.0.5
  Using rails_stdout_logging 0.0.4
  Using ref 2.0.0
  Using tilt 2.0.5
  Installing sqlite3 1.3.11 with native extensions

  Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

      /opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-5lnc3v.rb extconf.rb
  Cannot allocate memory - /opt/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160708-498-5lnc3v.rb extconf.rb 2>&1

  Gem files will remain installed in /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.11 for inspection.
  Results logged to /opt/rubies/ruby-2.2.5/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0-static/sqlite3-1.3.11/gem_make.out
  An error occurred while installing json (1.8.3), and Bundler cannot continue.
  Make sure that `gem install json -v '1.8.3'` succeeds before bundling. (Executor::NonZeroExitStatus)


[2016-07-08T19:47:55.300Z] INFO  [424]   - [Application update app-d3f5-160708_124551@2/AppDeployStage0/AppDeployPreHook/10_bundle_install.sh] : Activity failed.
[2016-07-08T19:47:55.301Z] INFO  [424]   - [Application update app-d3f5-160708_124551@2/AppDeployStage0/AppDeployPreHook] : Activity failed.
[2016-07-08T19:47:55.301Z] INFO  [424]   - [Application update app-d3f5-160708_124551@2/AppDeployStage0] : Activity failed.
[2016-07-08T19:47:55.302Z] INFO  [424]   - [Application update app-d3f5-160708_124551@2] : Completed activity. Result:
  Application update - Command CMD-AppDeploy failed
[2016-07-08T20:17:06.267Z] INFO  [1271]  - [CMD-TailLogs] : Starting activity...
[2016-07-08T20:17:06.268Z] INFO  [1271]  - [CMD-TailLogs/AddonsBefore] : Starting activity...
[2016-07-08T20:17:06.268Z] INFO  [1271]  - [CMD-TailLogs/AddonsBefore] : Completed activity.
[2016-07-08T20:17:06.268Z] INFO  [1271]  - [CMD-TailLogs/TailLogs] : Starting activity...
[2016-07-08T20:17:06.268Z] INFO  [1271]  - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...

推荐答案

我发现来自@osazemeu的答案基于

I found that the answer from @osazemeu based on the blog article needed a tweak, because the container_commands execute too late (after the application was already set up), and thus it was never run.

我将container_command更改为命令(请参见此AWS文档了解两者之间的区别的详细信息),还创建了内联文件,而不是使用单独的.sh文件,因为我不想跟踪部署时所放置的目录.我将文件命名为01setup_swap.config,并放置在项目根目录下的目录.ebextensions中.这帮了我大忙.内容如下:

I changed the container_command into a command (see this AWS documentation for detail on the difference between the two), and also created the file inline rather than having a separate .sh file since I didnt want to have to keep track of what directory that was being put in at deployment time. I called the file 01setup_swap.config and placed in the directory .ebextensions in the root of my project. This did the trick for me. The contents is as follows:

files:
  "/home/ec2-user/setup_swap.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/bin/bash
      # based on http://steinn.org/post/elasticbeanstalk-swap/

      SWAPFILE=/var/swapfile
      SWAP_MEGABYTES=2048

      if [ -f $SWAPFILE ]; then
        echo "Swapfile $SWAPFILE found, assuming already setup"
        exit;
      fi

      /bin/dd if=/dev/zero of=$SWAPFILE bs=1M count=$SWAP_MEGABYTES
      /bin/chmod 600 $SWAPFILE
      /sbin/mkswap $SWAPFILE
      /sbin/swapon $SWAPFILE

commands:
  01setup_swap:
    command: "bash setup_swap.sh"
    cwd: "/home/ec2-user/"

这篇关于部署到Elastic Beanstalk失败,并显示“无法分配内存"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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