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

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

问题描述

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



所以我试过测试:


  1. 我从我的域中加载了一个页面

  2. 我们的服务器已经提供了页面

  3. 关闭该主机上的Web服务器

  4. 重新加载页面



    1. 确实,浏览器自动尝试使用不同的服务器来加载页面。这在Opera,Safari,IE和Firefox中都有效。只有Chrome无法尝试其他服务器。



      但是,在离开该服务器几分钟后,查看访问日志,我发现对其他服务器的请求没有显着增加。离线3台服务器中的1台服务器预计对其余2台服务器的访问量大概增加了50%,而我只看到7-10%。这只能意味着基于DNS的故障切换对于大多数浏览器/访问者来说都不起作用,这与我刚刚测试的内容直接相矛盾。



      有人有什么想法基于DNS的Web浏览器故障转移?可能的原因可能是为什么自动故障转移适用于我,但不是我们大多数访问者?

      解决方案

      发生什么事情是浏览器没有进行自动DNS故障切换。



      如果您在域上有多个A记录,那么当您的域名服务器请求您输入到浏览器的域名的IP时,它会从SOA请求一个。这可能是任何这些A记录。然后它通过它。



      一些名称服务器是足够聪明的,要求一个新的A记录,如果它得到的不起作用,有些不是。因此,如果您设置多个A记录,那么您将设置伪冗余故障转移,但仅适用于具有智能名称服务器的人员。其余的可以得到一个骰子,他们得到的IP,如果它的工作,然后很好,如果不是,那么它将无法加载,因为它在Chrome中的。



      如果要专门测试这个,那么您可以在Windows中使用您的主机文件 C:\Windows\system32\drivers\etc\hosts code> / etc / hosts 在Linux中指定您想要访问什么IP地址,如果您得到真正的故障转移,您将会遇到什么,因为您将遇到的实际情况是DNS网络上的服务器将根据其TTL缓存您的域名解析。所以如果/当你得到一个真正的失败,这个IP仍然需要解决,否则被其他的遗产丢给另一个域名服务器。


      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.

      So I tried testing it:

      1. I loaded a page from our domain
      2. Noted which of our servers had served the page
      3. Turned off the web server on that host
      4. Reloaded the page

      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.

      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.

      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?

      解决方案

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

      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.

      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.

      If you want to specifically test this then you can use your hosts file C:\Windows\system32\drivers\etc\hosts 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天全站免登陆