- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
无法解决 sidekiq 错误。
尝试从 Heroku 迁移到 AWS EB。我有一个在 Linux 机器上运行 Rails 4.2.0、Ruby 2.3 的 Rails 应用程序,但一直遇到问题。 Web 应用程序不会加载 - 它只是一遍又一遍地超时。
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 is nil
尽管看起来是一个可靠的设置。 (它适用于我设法使用相同配置运行的另一个应用程序。我还发现 ERROR MISCONF 通知也很麻烦,但 Redis URL 甚至没有设置。此外,两者都在同一个安全组中
这是我的config/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
还有我的config/redis.yml:
development:
host: localhost
port: 6379
test:
host: localhost
port: 6379
production:
host: ENV['REDIS_HOST']
port: 6379
我的applicatoin.yml:
REDIS_HOST: project-name-001.random-token.0001.use1.cache.amazonaws.com
Here's setup_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 {
# }
# }
}
更新响应: 我将 nginx.conf
更新为:include/etc/nginx/conf.d/webapp_healthd.conf;
但是仍然得到以下内容:
[root] service nginx restart
nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
Stopping nginx: [ OK ]
Starting nginx: nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
[ OK ]
此外,以下内容仍然存在:
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 停止了提示,但我仍然得到 Heartbeat MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on磁盘。
错误。
Sidekiq.redis(&:info)
的输出:
{
"redis_version"=>"3.2.8",
"redis_git_sha1"=>"00000000",
"redis_git_dirty"=>"0",
"redis_build_id"=>"12e5c8be08dc4d3",
"redis_mode"=>"standalone",
"os"=>"Linux 4.4.51-40.60.amzn1.x86_64 x86_64",
"arch_bits"=>"64",
"multiplexing_api"=>"epoll",
"gcc_version"=>"4.8.3",
"process_id"=>"24835",
"run_id"=>"83a8de8b50f482a4e271228435b2f0c8e3fa5b5c",
"tcp_port"=>"6379",
"uptime_in_seconds"=>"341217",
"uptime_in_days"=>"3",
"hz"=>"10",
"lru_clock"=>"1108155",
"executable"=>"/usr/local/bin/redis-server",
"config_file"=>"/etc/redis/redis.conf",
"connected_clients"=>"2",
"client_longest_output_list"=>"0",
"client_biggest_input_buf"=>"0",
"blocked_clients"=>"0",
"used_memory"=>"842664",
"used_memory_human"=>"822.91K",
"used_memory_rss"=>"3801088",
"used_memory_rss_human"=>"3.62M",
"used_memory_peak"=>"924360",
"used_memory_peak_human"=>"902.70K",
"total_system_memory"=>"1043574784",
"total_system_memory_human"=>"995.23M",
"used_memory_lua"=>"37888",
"used_memory_lua_human"=>"37.00K",
"maxmemory"=>"0",
"maxmemory_human"=>"0B",
"maxmemory_policy"=>"noeviction",
"mem_fragmentation_ratio"=>"4.51",
"mem_allocator"=>"jemalloc-4.0.3",
"loading"=>"0",
"rdb_changes_since_last_save"=>"177",
"rdb_bgsave_in_progress"=>"0",
"rdb_last_save_time"=>"1493941570",
"rdb_last_bgsave_status"=>"err",
"rdb_last_bgsave_time_sec"=>"0",
"rdb_current_bgsave_time_sec"=>"-1",
"aof_enabled"=>"0",
"aof_rewrite_in_progress"=>"0",
"aof_rewrite_scheduled"=>"0",
"aof_last_rewrite_time_sec"=>"-1",
"aof_current_rewrite_time_sec"=>"-1",
"aof_last_bgrewrite_status"=>"ok",
"aof_last_write_status"=>"ok",
"total_connections_received"=>"17",
"total_commands_processed"=>"141824",
"instantaneous_ops_per_sec"=>"0",
"total_net_input_bytes"=>"39981126",
"total_net_output_bytes"=>"72119284",
"instantaneous_input_kbps"=>"0.00",
"instantaneous_output_kbps"=>"0.00",
"rejected_connections"=>"0",
"sync_full"=>"0",
"sync_partial_ok"=>"0",
"sync_partial_err"=>"0",
"expired_keys"=>"3",
"evicted_keys"=>"0",
"keyspace_hits"=>"14",
"keyspace_misses"=>"533",
"pubsub_channels"=>"0",
"pubsub_patterns"=>"0",
"latest_fork_usec"=>"160",
"migrate_cached_sockets"=>"0",
"role"=>"master",
"connected_slaves"=>"0",
"master_repl_offset"=>"0",
"repl_backlog_active"=>"0",
"repl_backlog_size"=>"1048576",
"repl_backlog_first_byte_offset"=>"0",
"repl_backlog_histlen"=>"0",
"used_cpu_sys"=>"167.52",
"used_cpu_user"=>"46.03",
"used_cpu_sys_children"=>"0.00",
"used_cpu_user_children"=>"0.00",
"cluster_enabled"=>"0",
"db0"=>"keys=1,expires=0,avg_ttl=0"
}
有趣的是,我找不到我的 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.d
中包含其他服务器的conf文件文件夹,检查 include/etc/nginx/conf.d/*.conf;
在你的 nginx.conf
中,如果是这样,它可能会加载文件两次或其他具有相同服务器名称
的默认文件,您可以将其更改为include/etc/nginx/conf.d/webapp_healthd.conf
或任何您想要的名称,但在检查之前机器上的文件是什么。
同时检查 /etc/nginx/sites-enabled/
目录是否有任何临时文件,例如 ~default
或 .save
。使用 ls -lah
检查它,删除它们,重新启动 nginx 并检查错误或通过 ebextensions
执行并再次部署。
更新
尝试从 nginx.conf
中删除 server { ... }
的所有部分,确保在 http
中包含您的文件/etc/nginx/conf.d/webapp_healthd.conf
,你已经有了server listen 80;
和localhost
..
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_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
关于ruby-on-rails - Elastic Beanstalk Redis 失败,Web 应用程序无响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43812086/
我正在尝试将我的应用程序上载到Elastic Beanstalk,但是在节点预gyp安装--fallback-to-build上,npm安装失败。我尝试了各种版本的节点,但无济于事。似乎正在尝试获取一
设置 Elastic Beanstalk 的配置时,我没有获得解决方案堆栈的任何选项。 以下是有问题的行: `Select a solution stack. Available solution s
我正在尝试自定义 beanstalk 的默认 AMI,但每次我都会在一段随机时间后服务器重新启动。我什至没有改变任何东西,但没有任何效果。 我尝试过以下方法: 找到运行beanstalk的实例,创建A
我正在尝试使用sudo pip install awsebcli在新的Ubuntu 14.04(在Windows的Linux子系统上)上安装Elastic Beanstalk CLI(awsebcli
Amazon Beanstalk 是否会自动防止(分布式)拒绝服务攻击?如果没有,最方便的方法是什么? 最佳答案 我相信它会 New – AWS Shield AWS Shield is a new
每当我在 Elastic Beanstalk 中创建新环境时,我都会手动配置自定义 AMI ID、SNS 通知等,但我想自动完成,即,将设置(自定义 AMI ID、SNS、 key 对等)保存到一个配
我已使用以下方法连接到 Elastic Beanstalk: eb ssh XXXXXX --profile=xx 现在我想将一个文件复制到我的本地机器上,我该怎么做? 最佳答案 找出与 scp 一起
对于典型的 Java Web 应用程序,使用 Elastic Beanstalk 相对于手动创建 EC2 实例、设置 tomcat 服务器和部署等有哪些优势?负载平衡、监控和自动缩放是唯一的优势吗?
我有一个运行 PHP 的弹性 beanstalk 环境。在我的项目中,我有一个 .ebextensions 文件夹和一个名为“15-memorymonitor.config”的文件,其中包含以下内容;
我有 “更新”:Dockerrun.aws.json 中的“真” 当我更新 ECR 中的图像时,它应该自动更新 EC2 iontance 中的图像和容器。 但是当我在推送新图像后通过 ssh 进入实例
我有一个定义 Elastic Beanstalk 应用程序的 CloudFormation 模板。 我想扩展这个应用程序,即我希望端口 80 上的监听器重定向到 HTTPS。 AWS::Elastic
我在使用自定义 .ebextensions 文件部署 EB 实例时遇到问题。这是该文件中的相关部分: container_commands: 01_migrate: command: 'p
我已经使用带负载均衡器的 Elastic Beanstalk 创建了一个环境,并在各自的配置中分配了所有健康检查值 我也为ELB设置了应用健康检查url 但是当我检查自动缩放组配置时,健康检查类型是
我正在尝试部署我的 角申请通过GitHub Actions到 Elastic Beanstalk 。我正在使用这个 GitHub actions用于部署到 ELB。 我的问题是,部署失败,因为 ELB
我已阅读有关 Deploying Versions with Zero Downtime 的 AWS 文档,又名 CNAME 交换。 如 yegor256在 this answer 中有解释: The
我有一个弹性 beanstalk 设置,但无法访问环境中列出的 url,而如果我指向负载均衡器的 url,我可以访问它。 有什么建议吗? 最佳答案 将 LoadBalancer 安全组附加到实例。对我
我正在使用 AWS Elastic beanstalk 并希望为不同的环境配置不同的 ENV 变量。我发现的唯一方法是使用 ebextensions,但如果我将同一个数据包部署到多个环境,则无法覆盖在
我有一个应用程序,其中包含 nodejs 和 php 代码。 nodejs 用于运行应用程序所需的几个脚本。我如何使用 aws Elastic beanstalk 部署此类应用程序? 最佳答案 有两种
我今天遇到一个关于 Amazon Elastick BeanStalk 的奇怪问题:对于我的实例,我无法上传应用程序: XXX@-Vostro-2520:~/git_projects/ProjectB
我不断收到以下消息。但是在我的 nginx 日志中没有任何内容表明返回的请求状态为 5xx。此外,应用程序似乎按预期工作。我可能会得到这些的任何指示? 留言: Environment health h
我是一名优秀的程序员,十分优秀!