话语服务器无法启动与redis相关的错误

问题描述 投票:0回答:1

Rails服务器无法在开发或生产中的Discourse项目中启动。以下是尝试以开发模式启动服务器时的日志。该应用程序已安装并一直在运行,它已在生产模式下部署在AWS上,并且重新启动unicorn会将应用程序加载一段时间,并且url会再次停止响应并显示错误消息。

来自$ rails的开发日志

rb t@ip-XXX-XX-XX-XX-app:/var/www/discourse# vi 
config/environments/development.r
root@ip-172-31-25-46-app:/var/www/discourse# rails s
=> Booting Puma
=> Rails 5.1.4 application starting in production 
=> Run `rails server -h` for more startup options
Exiting
bundler: failed to load command: script/rails (script/rails)
Redis::CommandError: ERR Error running script (call to f_b06356ba4628144e123b652c99605b873107c9be): @user_script:14: @user_script: 14: -MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.   
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis/client.rb:121:in `call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:2399:in `block in _eval'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:58:in `block in synchronize'
/usr/local/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:58:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:2398:in `_eval'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:2450:in `evalsha'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/message_bus-2.1.1/lib/message_bus/backends/redis.rb:380:in `cached_eval'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/message_bus-2.1.1/lib/message_bus/backends/redis.rb:140:in `publish'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/message_bus-2.1.1/lib/message_bus.rb:248:in `publish'
/var/www/discourse/lib/distributed_cache.rb:72:in `publish'

**生产日志**

/var/www/discourse/lib/demon/base.rb:109:in `ensure_running'
            /var/www/discourse/lib/demon/base.rb:34:in `block in ensure_running'
            /var/www/discourse/lib/demon/base.rb:33:in `each'
            /var/www/discourse/lib/demon/base.rb:33:in `ensure_running'
            config/unicorn.conf.rb:145:in `master_sleep'
            /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:284:in `join'
            /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/unicorn-5.1.0/bin/unicorn:126:in `<top (required)>'
            /var/www/discourse/vendor/bundle/ruby/2.3.0/bin/unicorn:23:in `load'
            /var/www/discourse/vendor/bundle/ruby/2.3.0/bin/unicorn:23:in `<main>'
            E, [2018-01-04T08:43:37.949928 #60] ERROR -- : reaped #<Process::Status: pid 5870 exit 1> worker=unknown
            Detected dead worker 5870, restarting...
            Loading Sidekiq in process id 5883
            Failed to report error: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. 4 Redis::CommandError (MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.)
            /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.0/lib/redis/client.rb:121:in `call' web-exception

Redis日志

   47:M 17 Jan 09:38:01.070 # Can't save in background: fork: Cannot allocate memory
   47:M 17 Jan 09:38:07.087 * 10000 changes in 60 seconds. Saving...
ruby-on-rails redis ruby-on-rails-5 unicorn discourse
1个回答
0
投票

问题已修复,编辑此文件

/etc/sysctl.conf并最后添加了该行

   vm.overcommit_memory=1 

在此重新启动的sysctl之后。

  $ sudo sysctl -p /etc/sysctl.conf

Redis不需要操作系统认为的内存量,状态1意味着总是过度使用,从不检查。更多细节可以在Redis Docs找到。

© www.soinside.com 2019 - 2024. All rights reserved.