Ruby on rails Elastic Beanstalk Redis失败,Webapp无响应
无法通过sidekiq错误 正在尝试从Heroku迁移到AWS EB。我有一个在linux机器上运行rails 4.2.0和ruby 2.3的rails应用程序,但一直遇到问题。webapp不会加载-它只是一次又一次地超时Ruby on rails Elastic Beanstalk Redis失败,Webapp无响应,ruby-on-rails,redis,amazon-elastic-beanstalk,sidekiq,Ruby On Rails,Redis,Amazon Elastic Beanstalk,Sidekiq,无法通过sidekiq错误 正在尝试从Heroku迁移到AWS EB。我有一个在linux机器上运行rails 4.2.0和ruby 2.3的rails应用程序,但一直遇到问题。webapp不会加载-它只是一次又一次地超时 INFO: Running in ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux] INFO: See LICENSE and the LGPL-3.0 for licensing details. INFO:
INFO: Running in ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
INFO: See LICENSE and the LGPL-3.0 for licensing details.
INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org
INFO: Booting Sidekiq 3.5.4 with redis options {:url=>nil}
ERROR: heartbeat: 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.
Redis一直告诉我它的url为零
,尽管它的设置似乎很可靠。(它可以在另一个应用程序上运行,我设法使用相同的配置运行。我还发现错误错误通知也很麻烦,但Redis URL甚至没有设置。此外,两者都在同一个安全组中
这是我的配置/sidekiq.rb:
rails_root = Rails.root || File.dirname(__FILE__) + '/../..'
rails_env = Rails.env || 'development'
redis_config = YAML.load_file(rails_root.to_s + '/config/redis.yml')
redis_config.merge! redis_config.fetch(Rails.env, {})
redis_config.symbolize_keys!
Sidekiq.configure_server do |config|
config.redis = { url: "redis://#{ENV['REDIS_HOST']}:#{redis_config[:port]}/12" }
end
Sidekiq.configure_client do |config|
config.redis = { url: "redis://#{ENV['REDIS_HOST']}:#{redis_config[:port]}/12" }
end
development:
host: localhost
port: 6379
test:
host: localhost
port: 6379
production:
host: ENV['REDIS_HOST']
port: 6379
REDIS_HOST: project-name-001.random-token.0001.use1.cache.amazonaws.com
我的配置/redis.yml:
rails_root = Rails.root || File.dirname(__FILE__) + '/../..'
rails_env = Rails.env || 'development'
redis_config = YAML.load_file(rails_root.to_s + '/config/redis.yml')
redis_config.merge! redis_config.fetch(Rails.env, {})
redis_config.symbolize_keys!
Sidekiq.configure_server do |config|
config.redis = { url: "redis://#{ENV['REDIS_HOST']}:#{redis_config[:port]}/12" }
end
Sidekiq.configure_client do |config|
config.redis = { url: "redis://#{ENV['REDIS_HOST']}:#{redis_config[:port]}/12" }
end
development:
host: localhost
port: 6379
test:
host: localhost
port: 6379
production:
host: ENV['REDIS_HOST']
port: 6379
REDIS_HOST: project-name-001.random-token.0001.use1.cache.amazonaws.com
我的应用程序位于.yml:
rails_root = Rails.root || File.dirname(__FILE__) + '/../..'
rails_env = Rails.env || 'development'
redis_config = YAML.load_file(rails_root.to_s + '/config/redis.yml')
redis_config.merge! redis_config.fetch(Rails.env, {})
redis_config.symbolize_keys!
Sidekiq.configure_server do |config|
config.redis = { url: "redis://#{ENV['REDIS_HOST']}:#{redis_config[:port]}/12" }
end
Sidekiq.configure_client do |config|
config.redis = { url: "redis://#{ENV['REDIS_HOST']}:#{redis_config[:port]}/12" }
end
development:
host: localhost
port: 6379
test:
host: localhost
port: 6379
production:
host: ENV['REDIS_HOST']
port: 6379
REDIS_HOST: project-name-001.random-token.0001.use1.cache.amazonaws.com
setup\u swap.config
、sidekiq.config
和nginx.config
我也看到过这个问题,但我认为它是不相关的。也许我错了?如果不相关,将在另一篇文章中讨论
Starting nginx: nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
可能是什么?
我遗漏了什么重要的东西吗
编辑:添加nginx.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
index index.html index.htm;
server {
listen 80 ;
listen [::]:80 ;
server_name localhost;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
# redirect server error pages to the static page /40x.html
#
error_page 404 /404.html;
location = /40x.html {
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 ;
# listen [::]:443 ssl http2 ;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# ssl_ciphers <redacted>;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}
此外,以下情况依然存在:
ERROR: heartbeat: 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.
更新2删除了对localhost端口80的重复引用,nginx停止抱怨,但我仍然收到心跳错误,因为Redis配置为保存RDB快照,但当前无法在磁盘上保留。
错误
Sidekiq.redis(&:info)
的输出:
有趣的是,我找不到我的redis日志进行进一步的调查。在我的redis.conf
中,我看到的只是这些
# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile ""
我甚至运行了find/-path/sys-prune-o-path/proc-prune-o-name*redis*
,没有看到任何日志文件(╯°□°)╯︵ ┻━┻
同样奇怪的是,production.log根本没有写入,请检查权限:rw-r--r--1 webapp webapp 0 May 8 20:01 production.log请共享您的
/etc/nginx/nginx.conf
,我猜nginx.conf
文件夹中包含其他服务器conf文件,检查行include/etc/nginx/conf.d/*.conf;
在您的nginx.conf
中,如果是这样,它可能会加载两次文件或其他具有相同服务器名称的默认文件,您可以将其更改为include/etc/nginx/conf.d/webapp\u healthd.conf
或您想要的任何名称,但在检查机器上的文件是什么之前
如果有任何临时文件,如~default
或等,请检查/etc/nginx/sites enabled/
目录。保存。使用ls-lah
检查它,删除它们,重新启动nginx并检查错误,或通过ebextensions
执行此操作,然后重新部署
更新
尝试从nginx.conf
中删除服务器{…}
的所有部分,确保在http
中包含您的文件/etc/nginx/conf.d/webapp\u healthd.conf
,您已经有了服务器侦听80;
和本地主机
nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/webapp_healthd.conf;
index index.html index.htm;
}
003\u nginx.config
files:
"/etc/nginx/conf.d/webapp_healthd.conf" :
mode: "000755"
owner: root
group: root
content: |
upstream my_app {
server unix:///var/run/puma/my_app.sock;
}
log_format healthd '$msec"$uri"'
'$status"$request_time"$upstream_response_time"'
'$http_x_forwarded_for';
server {
listen 80;
server_name _ localhost; # need to listen to localhost for worker tier
root /var/app/current/public;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
}
access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
try_files $uri/index.html $uri @my_app;
location @my_app {
proxy_pass http://my_app; # match the name of upstream directive which is defined above
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /assets {
alias /var/app/current/public/assets;
gzip_static on;
gzip on;
expires max;
add_header Cache-Control public;
}
# redirect server error pages to the static page /40x.html
#
error_page 404 /404.html;
location = /40x.html {
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
"/opt/elasticbeanstalk/hooks/appdeploy/post/03_restart_nginx.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
rm /etc/nginx/conf.d/webapp_healthd.conf.bak
rm /etc/nginx/conf.d/custom.conf
service nginx restart
谢谢你的回复!我已经添加了nginx.conf
文件,我确实注意到了include/etc/nginx/conf.d/*.conf;
,但是当我去检查/etc/nginx/sites enabled/
时,我没有发现任何东西。没有这样的目录……这意味着什么?另外,更改为includewebapp\u healthd.conf
(在机器上)。请参阅更新的描述@Berlini,认为这是因为在nginx conf
和webapp\u healthd.conf
中,您有一个侦听端口的服务器80@Berlin-非常感谢-出现了一个重复!仍然有错误,因为Redis当前无法在磁盘上保存。
错误。尝试进行调查,但Redis日志
简单y不存在于/var/logs中!?有什么想法吗?redis.conf就像阅读拉丁语一样。奇怪的是production.log根本没有被写入,请检查权限:rw-r--r--1 webapp webapp 0 May 8 20:01 production.log
您在这台机器上为此env安装了本地redis吗?如果是,请告诉我,然后我们更改redisconf文件,什么是redis版本?您的redis.conf
上唯一一行是logfilg
?更改nginx.conf
后现在发生的情况,您是否能够通过浏览器访问您的应用程序?