VPC 中的 Amazon ELB [英] Amazon ELB in VPC

查看:36
本文介绍了VPC 中的 Amazon ELB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用 Amazon EC2,并且我们希望将一个 ELB(负载均衡器)放置到私有子网上的 2 个实例上.如果我们只是将私有子网添加到 ELB,它不会获得任何连接,如果我们将两个子网都附加到 ELB,那么它可以访问实例,但它经常会超时.是否有人在其 VPC 的私有子网中成功实施了 ELB?如果是这样,您能否向我解释一下程序?

We're using Amazon EC2, and we want to put an ELB (load balancer) to 2 instances on a private subnet. If we just add the private subnet to the ELB, it will not get any connections, if we attach both subnets to the ELB then it can access the instances, but it often will get time-outs. Has anyone successfully implemented an ELB within the private subnet of their VPC? If so, could you perhaps explain the procedure to me?

谢谢

推荐答案

我和我的队友刚刚在一个 VPC 中实现了 ELB,该 VPC 在不同的可用区中有 2 个私有子网.出现超时的原因是,对于添加到负载均衡器的每个子网,它都会获得一个外部 IP 地址.(尝试'dig elb-dns-name-here',你会看到几个IP地址).如果这些 IP 地址之一映射私有子网,它将超时.映射到您的公共子网的 IP 将起作用.因为 DNS 可能会给你任何一个 IP 地址,所以有时它会起作用,有时它会超时.

My teammate and I just have implemented ELB in a VPC with 2 private subnets in different availability zones. The reason you get timeouts is that for each subnet you add to the load balancer, it gets one external IP address. (try 'dig elb-dns-name-here' and you will see several IP addresses). If one of these IP address maps a private subnet, it will timeout. The IP that maps into your public subnet will work. Because DNS may give you any one of the IP addresses, sometimes it works, sometimes it times out.

在与 amazon 交流之后,我们发现 ELB 应该只放置在公共"子网中,即具有到 Internet 网关的路由的子网.我们希望将我们的 Web 服务器保留在我们的私有子网中,但允许 ELB 与它们通信.为了解决这个问题,我们必须确保每个可用区都有一个对应的公共子网,我们在其中拥有私有子网.然后我们将每个可用区的公共子网添加到 ELB.

After some back and forth with amazon, we discovered that the ELB should only be placed in 'public' subnets, that is subnets that have a route out to the Internet Gateway. We wanted to keep our web servers in our private subnets but allow the ELB to talk to them. To solve this, we had to ensure that we had a corresponding public subnet for each availability zone in which we had private subnets. We then added to the ELB, the public subnets for each availability zone.

起初,这似乎不起作用,但在尝试了一切之后,我们重新创建了 ELB,一切正常.我认为这是一个错误,或者 ELB 只是因为如此多的变化而处于一种奇怪的状态.

At first, this didn't seem to work, but after trying everything, we recreated the ELB and everything worked as it should. I think this is a bug, or the ELB was just in an odd state from so many changes.

这或多或少是我们所做的:

Here is more or less what we did:

  1. WebServer-1 在可用性区域 us-east-1b 中的 PrivateSubnet-1 中运行,安全组称为 web-server.
  2. WebServer-2 在可用区 us-east-1c 中的 PrivateSubnet-2 中运行,安全组称为 web-server.
  3. 在区域 us-east-1b 中创建了一个公共子网,我们将其命名为 PublicSubnet-1.我们确保将包含到 Internet 网关 (ig-xxxxx) 的路由的路由表与这个新子网相关联.(如果您使用向导创建公共/私有 VPC,则此路由已存在.)
  4. 在区域 us-east-1c 中创建了一个公共子网,我们将其命名为 PublicSubnet-2.我们确保将包含到 Internet 网关 (ig-xxxxx) 的路由的路由表与这个新子网相关联.(如果您使用向导创建公共/私有 VPC,则此路由已存在.)
  5. 创建了一个新的 ELB,向其中添加了 PublicSubnet-1 和 PublicSubnet-2(不是 PrivateSubnet-X).此外,选择要在 ELB 中运行的实例,在本例中为 WebServer-1 和 WebServer-2.确保分配一个允许传入端口 80 和 443 的安全组.让我们将此组称为 elb-group.
  6. 在 web-server 组中,允许来自 elb-group 的端口 80 和 443 的流量.

希望能帮到你!

这篇关于VPC 中的 Amazon ELB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆