使用 DNS 使用多个 A 记录进行故障转移 [英] Using DNS for failover using multiple A records

查看:81
本文介绍了使用 DNS 使用多个 A 记录进行故障转移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近注意到为一个主机名设置多个 A 记录不仅可以用于循环负载平衡,还可以用于自动故障转移.

It has recently come to my attention that setting up multiple A records for a hostname can be used not only for round-robin load-balancing but also for automatic failover.

所以我尝试测试它:

  1. 我从我们的域加载了一个页面
  2. 注意我们的哪些服务器为页面提供服务
  3. 关闭该主机上的网络服务器
  4. 重新加载页面

实际上浏览器会自动尝试不同的服务器来加载页面.这适用于 Opera、Safari、IE 和 Firefox.只有 Chrome 无法尝试其他服务器.

And indeed the browser automatically tried a different server to load the page. This worked in Opera, Safari, IE, and Firefox. Only Chrome failed to try a different server.

但在将该服务器离线几分钟并查看访问日志后,我发现对其他服务器的请求数量没有显着增加.3 台服务器中有 1 台离线,我原以为对其余 2 台服务器的访问量大约会增加 50%,但我只看到了 7-10%.这只能意味着基于 DNS 的故障转移对大多数浏览器/访问者不起作用,这与我刚刚测试的内容直接矛盾.

But after leaving that server offline for a few minutes and looking at the access logs, I found that the number of requests to the other servers had not significantly increased. With 1 out of 3 servers offline, I had expected accesses to each of the remaining 2 servers to roughly increase by 50%, but instead I only saw 7-10%. That can only mean DNS-based failover does not work for the majority of browsers/visitors, which directly contradicts what I had just tested.

有人知道基于 DNS 的 Web 浏览器故障转移是怎么回事吗?为什么自动故障转移对我有效,但对我们的大多数访问者无效?

Does anyone have an idea what is up with DNS-based web browser failover? What possible reason could there be why automatic failover works for me but not the majority of our visitors?

推荐答案

发生的事情是浏览器没有进行自动 DNS 故障转移.

What's happening is that the browsers are not doing automatic DNS failover.

如果您在一个域上有多个 A 记录,那么当您的名称服务器请求您在浏览器中键入的域的 IP 时,它会从 SOA 请求一个.它可以是那些 A 记录中的任何一个.然后它传递它.

If you have multiple A records on a domain then when your nameserver requests the IP for the domain you typed into your browser, it'll request one from the SOA. It could be any of those A records. Then it passes it along.

有些域名服务器足够聪明",可以在它获得的 A 记录无效时请求新的 A 记录,而有些则无效.因此,如果您设置了多个 A 记录,那么您将设置伪冗余故障转移,但仅适用于那些拥有智能"名称服务器的人.其余的人会在他们获得的 IP 上掷骰子,如果它可以正常工作,那么它就很好,如果不能,那么它将无法像在 Chrome 中那样加载.

Some nameservers are 'smart' enough to request a new A record if the one it gets doesn't work and some aren't. So if you set multiple A records then you will have set up a pseudo redundancy failover, but only for those people with 'smart' nameservers. The rest get a toss of the dice on which IP they get and if it works then good, and if not then it will fail to load as it did for you in Chrome.

如果你想专门测试这个,那么你可以在 Windows 和 /etc/hosts 中使用你的主机文件 C:Windowssystem32driversetchosts在 Linux 中指定您想要与哪个域一起使用的 IP 以查看您是否获得真正的故障转移 - 因为您在实际中会遇到的是网络上的 DNS 服务器将根据其 TTL 缓存您的域名解析.因此,如果/当您遇到真正的故障时,仍需要解析该 IP,否则将转移到另一个名称服务器.

If you want to specifically test this then you can use your hosts file C:Windowssystem32driversetchosts in Windows and /etc/hosts in Linux to specify what IP you want to go with what domain to see if you get a true failover - as what you'll run into in practicality is that DNS servers across the net will cache your domain name resolution based on its TTL. So if/when you get a real failure, that IP will still need to be resolve and be otherwise farmed out to another nameserver.

这篇关于使用 DNS 使用多个 A 记录进行故障转移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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