gpt4 book ai didi

ruby-on-rails - EC2 实例在负载均衡器中停止服务

转载 作者:数据小太阳 更新时间:2023-10-29 07:06:30 24 4
gpt4 key购买 nike

我有一个 EC2 实例正在运行。我有一个负载均衡器,它与 EC2 实例相关联。

Ping Target         : HTTP:3001/healthCheck
Timeout : 5 seconds
Interval : 24 seconds
Unhealthy threshold : 2
Healthy threshold : 10

enter image description here现在该实例显示为 OutofService。我什至尝试更改监听端口等等。一切正常,直到重新启动我的 EC2 实例。任何帮助将不胜感激。

仅供引用:我有一个在端口 3001 上运行的 Rails 应用程序,我有一个用于 HTTP:80(loadbalancer) 到 HTTP:3001 的监听器。

我还在终端中通过 ssh 检查了正在运行的应用程序。

最佳答案

建议#1:

If the current state of some or all your instances is OutOfService and the description field displays the message that the Instance has failed at least the Unhealthy Threshold number of health checks consecutively, the instances have failed the load balancer health check.

以下是要查找的问题、潜在原因以及您可以通过以下链接解决问题的步骤:Troubleshoot a Classic Load Balancer: Health Checks

建议#2:

chrisa_pm针对这个问题给出了一些建议:

If you can confirm that your EC2 instance is reachable, you can remove it from your Load Balancer and add it back again. The Load Balancer will recognize it after a few minutes though.

Keep in mind that you need to confirm the health as it is set in your Health Check configuration:

  1. For HTTP:80 you need to specify a page that is actually reachable (like index.html)
  2. For TCP:80 it will only be needed access to the 80 TCP port.

建议#3:

qh2通过以下方式给出了解决方案

在启动时创建一个服务以取消注册并重新注册您的实例。

示例:文件 awsloadbalancer

#!/bin/sh
chkconfig: 2345 95 20

当一个实例停止时,一个负载均衡器就会丢失。这个重建负载 平衡器

case "$1" in
start)
aws --region eu-west-1 elb deregister-instances-from-load-balancer --load-balancer-name test --instances i-3c339b7c
aws --region eu-west-1 elb register-instances-with-load-balancer --load-balancer-name test --instances i-3c339b7c
;;
stop)
echo "stopping aws instances"
;;
restart)
echo "Restarting aws, nothing to do"
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac

之后在/etc/init.d/中创建文件,注册为服务。

建议#4:

Kenneth Snyder还解决了特定 ELB 问题。

I also had similar issue but I was able to fix that.

I had created a security group for ELB which accepts request on port 80 and forward to EC2 on port 80. The security group that was earlier created for EC2 has also inbound rules for port 80 and RDP.

Still the instances were showing as OutOfService under ELB. Later i tried to add another inbound rule in the EC2's security group to allow port 80 for the SG that was created for ELB. and that worked.

I guess it requires the ELB SG to be allowed in the rules created for individual instance's SG. Hope that helps.

资源链接:

https://forums.aws.amazon.com/thread.jspa?messageID=733153

关于ruby-on-rails - EC2 实例在负载均衡器中停止服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40462678/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com