ruby-on-rails - Discourse server启动失败,出现redis相关错误

标签 ruby-on-rails redis ruby-on-rails-5 unicorn discourse

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

来自 $rails s 的开发日志

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...

最佳答案

问题已修复,已编辑此文件

/etc/sysctl.conf 最后加入一行

   vm.overcommit_memory=1 

在此之后重新启动 sysctl。

  $ sudo sysctl -p /etc/sysctl.conf

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

关于ruby-on-rails - Discourse server启动失败,出现redis相关错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48298489/

相关文章:

MySQL 服务器已消失 : Rails on Passenger (Redmine)

redis - 所有实体的 Spring Data Redis 全局 TTL

ruby-on-rails - ActionCable 不在后台作业 rails 中运行 5

Rails 5 升级后 Activerecord 存储仅返回空哈希

ruby-on-rails - Rails : difference between ENV. fetch() 和 ENV[]

ruby-on-rails - Ruby on Rails 的最佳托管(截至 2012 年)

ruby-on-rails - 为什么 Rails 需要 JavaScript 运行时?

ruby-on-rails - 如何通过yaml将 secret 数据设置为kubernetes secret ?

redis - 来自 NodeJitsu 的可靠的 redis 托管

ruby-on-rails - 在 Passenger 中运行时使用 RedisStore 进行缓存时出现 Errno::EMFILE(打开的文件过多 - 套接字(2))