V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
holinhot
V2EX  ›  DNS

关于 dns 负载均衡

  •  
  •   holinhot · 2015-04-08 10:40:29 +08:00 · 5080 次点击
    这是一个创建于 3307 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如果我ns1.qq.com下配置了2台主机
    ns1.qq.com 192.168.1.101
    ns1.qq.com 192.168.1.102

    ns2.qq.com下配置了两台主机
    ns2.qq.com 192.168.1.201
    ns2.qq.com 192.168.1.202

    ns1和ns2下的两台是不是流量均衡分配。如果ns1下挂了一台客户端请求会不会出现无法获取解析记录。这个时候他会再向ns2查询 如果ns2也挂了一台。而流量刚好分配至挂的这台服务器上是不是网站就不法访问了

    18 条回复    2015-04-08 13:01:37 +08:00
    holinhot
        1
    holinhot  
    OP
       2015-04-08 10:47:02 +08:00
    或者是在ns1下配置一个ip 这个ip下用两台服务器建一个集群?
    9hills
        2
    9hills  
       2015-04-08 10:56:00 +08:00 via iPhone
    不一定的,DNS协议不保证均衡。只能说大部分情况下大致均衡。
    est
        3
    est  
       2015-04-08 11:03:05 +08:00
    dns 没有负载均衡。客户端查询用的是round robin。

    你得设置一个很短 ttl 不停变化的A记录才能实现负载均衡。例如 reddit.com
    holinhot
        4
    holinhot  
    OP
       2015-04-08 11:04:10 +08:00
    还有像dnspod那样ns3.dnsv4.com下如何实现不能区域分配不通的dns服务器
    因为在域名商设置Registered hosts的时候只能设置ns1.qq.com ip地址 根本没有分区域一说。而分域名解析应该是a记录这个层面 用户请求解析qq.com root返回请找ns1.qq.com ip192.168.1.101
    北京请求解析qq.com root返回请找ns1.qq.com ip192.168.1.101
    上海请求解析qq.com root返回还是请找ns1.qq.com ip192.168.1.101
    所以现在大公司使用了一种新的技术Anycast IP 国同网络环境复杂好像dnspod并未使用这种技术
    holinhot
        5
    holinhot  
    OP
       2015-04-08 11:05:01 +08:00
    @est 我不是说域名解析负载均衡。我是说dns本身的可用性负载均衡
    Admstor
        6
    Admstor  
       2015-04-08 11:14:17 +08:00
    ns和普通用户的访问关联性很小
    ns是域名所有者用来提交更新域名解析的服务器
    而大部分DNS服务器,本身有缓冲,你自己的ns挂了一段时间也不会影响到你的解析的...
    holinhot
        7
    holinhot  
    OP
       2015-04-08 11:21:47 +08:00
    @Admstor 对啊。我向根域名提交ns1.qq.com为解析权威服务器 ip 192.168.101然后为了加快解析时间会为ns1.qq.com创建一个A记录ip 192.168.101 我不能确定我的a记录可以分地区解析注册权威服务器的时候是不分地区的。然后在向根域名注册权威服务器的时候把我所有分地区的ip全加上?
    比如
    ns1.qq.com A 192.168.101 (北京) 分地区解析
    ns1.qq.com A 192.168.102 (上海) 分地区解析
    ns1.qq.com A 192.168.103(广东) 分地区解析
    ns1.qq.com A 192.168.104(海外) 分地区解析

    这个时候我向根域注册权威服务器的时候
    ns1.qq.com应该把
    192.168.101
    192.168.102
    192.168.103
    192.168.104
    全写上?
    holinhot
        8
    holinhot  
    OP
       2015-04-08 11:24:27 +08:00
    c0878
        9
    c0878  
       2015-04-08 11:56:02 +08:00
    ns记录把你的服务器全加上 如果一台挂掉无返回用户会到下一台查询 不影响的
    jsq2627
        10
    jsq2627  
       2015-04-08 12:12:08 +08:00
    提交 glue records 的时候是没法分地区的。
    也就是说没法让 ns1.qq.com 在不同区域解析为不同 IP。如果非要让不同的区域访问到不同机房的话,只能做 anycast。

    要做分区域解析,是在 name server 上根据来源 IP 返回不同的 A 记录的。
    jsq2627
        11
    jsq2627  
       2015-04-08 12:15:38 +08:00
    如果你提交 glue records 的时候,给
    ns1.qq.com 写了四个地址
    192.168.101
    192.168.102
    192.168.103
    192.168.104

    那么解析行为是由客户端决定的。客户端向根服务器查 ns1.qq.com 的时候,根会返回所有IP,到底选择哪个 IP 是客户端决定的。
    holinhot
        12
    holinhot  
    OP
       2015-04-08 12:25:19 +08:00
    @jsq2627 dnspod也没做anycast 怎么弄的。
    holinhot
        13
    holinhot  
    OP
       2015-04-08 12:28:11 +08:00
    @jsq2627 还有glue records 和a记录如果不一至会出现什么情况。我看介绍说为ns1建一个a记录加快域名解析时间
    wy315700
        14
    wy315700  
       2015-04-08 12:33:12 +08:00
    @louishothot 服务器多,,,企业旗舰版12台机器,,,然后国内其实不需要anycast,弄个BGP就行了
    jsq2627
        15
    jsq2627  
       2015-04-08 12:42:11 +08:00
    @louishothot RFC 里要求这样做,因为 ns1.qq.com 在 com 的 name server 里是被认为是“非权威记录”,为了保证“权威 name server 记录有该域下所有的记录”这个原则,所以 glue records 也得添加在 ns1.qq.com 下。

    http://www.rfcreader.com/#rfc1034

    One of the goals of the zone structure is that any zone have all the
    data required to set up communications with the name servers for any
    subzones. That is, parent zones have all the information needed to
    access servers for their children zones. The NS RRs that name the
    servers for subzones are often not enough for this task since they name
    the servers, but do not give their addresses. In particular, if the
    name of the name server is itself in the subzone, we could be faced with
    the situation where the NS RRs tell us that in order to learn a name
    server's address, we should contact the server using the address we wish
    to learn. To fix this problem, a zone contains "glue" RRs which are not
    part of the authoritative data, and are address RRs for the servers.
    These RRs are only necessary if the name server's name is "below" the
    cut, and are only used as part of a referral response.
    jsq2627
        16
    jsq2627  
       2015-04-08 12:44:16 +08:00
    接上。
    如果两个地方记录不一致,实际上也没什么大问题。只有存在根上的 glue records 才是实际解析时用到的记录。
    holinhot
        17
    holinhot  
    OP
       2015-04-08 13:00:10 +08:00
    @wy315700 想想其实也是。像softlayer cloudflare的dns都是anycast 他们的客户面向全世界 而dnspod只是国内而一所以bgp也够了
    holinhot
        18
    holinhot  
    OP
       2015-04-08 13:01:37 +08:00
    @jsq2627 然后了解到了没有anycast支持不可能做到不同地区分配不同的服务器
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2826 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 06:22 · PVG 14:22 · LAX 23:22 · JFK 02:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.