这是我在控制台中的代码和输出:
root@a:/home/rails/car_main# bundle install
You have requested:
rails = 4.2
The bundle currently has rails locked at 4.0.2.
Try running `bundle update rails`
这是我做的和输出:
root@a:/home/rails/car_main# bundle update rails
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies............
Using rake 10.5.0
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4 (was 4.7.5)
Using thread_safe 0.3.5
Using builder 3.2.2 (was 3.1.4)
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using rack 1.6.4 (was 1.5.5)
Using mime-types 2.99 (was 1.25.1)
Using arel 6.0.3 (was 4.0.2)
Installing bcrypt 3.1.10 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/bcrypt-3.1.10/ext/mri
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-e5ct6z.rb extconf.rb
Cannot allocate memory - /usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-e5ct6z.rb extconf.rb 2>&1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.0/gems/bcrypt-3.1.10 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/bcrypt-3.1.10/gem_make.out
Installing bcrypt-ruby 3.1.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/bcrypt-ruby-3.1.2/ext/mri
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-e88mem.rb extconf.rb
Cannot allocate memory - /usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-e88mem.rb extconf.rb 2>&1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.0/gems/bcrypt-ruby-3.1.2 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/bcrypt-ruby-3.1.2/gem_make.out
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using thor 0.19.1
Using bundler 1.11.2
Using hike 1.2.3
Using multi_json 1.11.2
Using tilt 1.4.1
Using sass 3.4.21
Using will_paginate 3.0.4
Installing ffi 1.9.10 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/ffi-1.9.10/ext/ffi_c
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-u62vla.rb extconf.rb
Cannot allocate memory - /usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-u62vla.rb extconf.rb 2>&1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.0/gems/ffi-1.9.10 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.10/gem_make.out
Using diff-lcs 1.2.5
Installing unf_ext 0.0.7.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/unf_ext-0.0.7.1/ext/unf_ext
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-1n8ty2l.rb extconf.rb
Cannot allocate memory - /usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-3939-1n8ty2l.rb extconf.rb 2>&1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.0/gems/unf_ext-0.0.7.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.1/gem_make.out
Using ffaker 2.1.0
在此之后,当我键入bundle install时,我仍然会收到错误
好。我怎么处理记忆?我用5美元的数字海洋水滴我的网站很简单。 我做了这个问题的建议: https://askubuntu.com/questions/253466/why-am-i-frequently-getting-this-cannot-allocate-memory-error 这是输出:
root@a:/home/rails/car_main# ps --sort -rss -eo rss,pid,command | head
RSS PID COMMAND
75920 1538 unicorn worker[0] -D -c /etc/unicorn.conf -E production
74176 1541 unicorn worker[1] -D -c /etc/unicorn.conf -E production
73988 1543 unicorn worker[2] -D -c /etc/unicorn.conf -E production
73828 1546 unicorn worker[3] -D -c /etc/unicorn.conf -E production
11972 1057 /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf
10464 1535 unicorn master -D -c /etc/unicorn.conf -E production
7508 4037 postgres: rails rails_project_production 127.0.0.1(56865) idle
6788 1630 -bash
5732 1563 postgres: rails rails_project_production 127.0.0.1(56745) idle
UPDATE2:
我按照评论链接中的建议打印出来
root@a:/home/rails/car_main# sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
问题依然存在。
我现在会尝试停止postgres
Update 3
我试图停止并开始发布postgres(我不确定我是否正确搜索了如何正确处理这些代码和输出:
root@a:/usr/bin# /etc/init.d/postgresql stop
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "ru_RU.UTF-8",
LC_MONETARY = "ru_RU.UTF-8",
LC_ADDRESS = "ru_RU.UTF-8",
LC_TELEPHONE = "ru_RU.UTF-8",
LC_NAME = "ru_RU.UTF-8",
LC_MEASUREMENT = "ru_RU.UTF-8",
LC_IDENTIFICATION = "ru_RU.UTF-8",
LC_NUMERIC = "ru_RU.UTF-8",
LC_PAPER = "ru_RU.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
* Stopping PostgreSQL 9.3 database server [ OK ]
root@a:/usr/bin# /etc/init.d/postgresql start
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "ru_RU.UTF-8",
LC_MONETARY = "ru_RU.UTF-8",
LC_ADDRESS = "ru_RU.UTF-8",
LC_TELEPHONE = "ru_RU.UTF-8",
LC_NAME = "ru_RU.UTF-8",
LC_MEASUREMENT = "ru_RU.UTF-8",
LC_IDENTIFICATION = "ru_RU.UTF-8",
LC_NUMERIC = "ru_RU.UTF-8",
LC_PAPER = "ru_RU.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
* Starting PostgreSQL 9.3 database server * perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "ru_RU.UTF-8",
LC_MONETARY = "ru_RU.UTF-8",
LC_ADDRESS = "ru_RU.UTF-8",
LC_TELEPHONE = "ru_RU.UTF-8",
LC_NAME = "ru_RU.UTF-8",
LC_MEASUREMENT = "ru_RU.UTF-8",
LC_IDENTIFICATION = "ru_RU.UTF-8",
LC_NUMERIC = "ru_RU.UTF-8",
LC_PAPER = "ru_RU.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
The PostgreSQL server failed to start. Please check the log output:
2016-02-18 12:42:32 EST FATAL: could not map anonymous shared memory: Cannot allocate memory
2016-02-18 12:42:32 EST HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory or swap space. To reduce the request size (currently 147783680 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
更新5:
我再次跑了bundle update
然后我收到了一些错误并承诺安装捆绑器,所以我安装了它
root@a:/home/rails/car_main# apt-get install bundler
然后我再次捆绑更新:
root@a:/home/rails/car_main# bundle update
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler (LoadError)
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/bin/bundle:7:in `<main>'
更新6: 所以我再次运行捆绑更新,它给了我一个错误,无法安装sqlite3并建议手动安装它所以我做了它,并在这里输出:
root@a:/home/rails/car_main# gem install sqlite3 -v '1.3.8'
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.3.0@railstutorial_rails_4_0/gems/sqlite3-1.3.8/ext/sqlite3
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160218-26242-ueiluc.rb extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
checking for sqlite3_initialize()... yes
checking for sqlite3_backup_init()... yes
checking for sqlite3_column_database_name()... yes
checking for sqlite3_enable_load_extension()... yes
checking for sqlite3_load_extension()... yes
checking for sqlite3_open_v2()... yes
checking for sqlite3_prepare_v2()... yes
checking for sqlite3_int64 in sqlite3.h... yes
checking for sqlite3_uint64 in sqlite3.h... yes
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/usr/local/rvm/gems/ruby-2.3.0@railstutorial_rails_4_0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.8/mkmf.log
current directory: /usr/local/rvm/gems/ruby-2.3.0@railstutorial_rails_4_0/gems/sqlite3-1.3.8/ext/sqlite3
make "DESTDIR=" clean
current directory: /usr/local/rvm/gems/ruby-2.3.0@railstutorial_rails_4_0/gems/sqlite3-1.3.8/ext/sqlite3
make "DESTDIR="
compiling database.c
compiling backup.c
compiling exception.c
compiling statement.c
statement.c: In function ‘bind_param’:
statement.c:261:7: warning: implicit declaration of function ‘RBIGNUM’ [-Wimplicit-function-declaration]
if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
^
In file included from statement.c:1:0:
./sqlite3_ruby.h:16:34: error: invalid type argument of ‘->’ (have ‘int’)
#define RBIGNUM_LEN(x) RBIGNUM(x)->len
^
statement.c:261:11: note: in expansion of macro ‘RBIGNUM_LEN’
if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
^
statement.c:261:32: error: ‘SIZEOF_BDIGITS’ undeclared (first use in this function)
if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
^
statement.c:261:32: note: each undeclared identifier is reported only once for each function it appears in
statement.c: In function ‘reset_bang’:
statement.c:293:7: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
int status;
^
statement.c: In function ‘clear_bindings’:
statement.c:313:7: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
int status;
^
make: *** [statement.o] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.0@railstutorial_rails_4_0/gems/sqlite3-1.3.8 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.0@railstutorial_rails_4_0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.8/gem_make.out
我将删除gemfile中的sqlite版本希望它有所帮助
答案 0 :(得分:0)
你的问题与内存不足有关,引用你的堆栈跟踪:Cannot allocate memory
考虑到独角兽工人吃掉你所有的公羊,你应该减少工人的数量,更多的信息here,
我注意到你已经杀死了所有进程;部署你的应用程序,如果它有足够的ram一切都应该没问题(顺便说一句:在部署时检查htop),如果问题仍然存在,或者某处存在内存泄漏(更新gem版本)或者你只是没有足够的内存 - 就像我说的那样价格你应该获得其他地方4倍的资源
如果您在服务器上运行所有这些命令,则应考虑在将来使用capistrano
关于更新5:
你应该运行gem install bundler
(我假设你没有rvm?)