使用應用程式負載平衡 DNS 原則Use DNS Policy for Application Load Balancing

適用於:Windows Server(以每年次管道)、Windows Server 2016Applies To: Windows Server (Semi-Annual Channel), Windows Server 2016

您可以使用本主題以了解如何設定執行的應用程式負載平衡 DNS 原則。You can use this topic to learn how to configure DNS policy to perform application load balancing.

之前版本的 Windows Server DNS 只提供負載平衡所使用的回應循環配置資源。但是,您可以在 Windows Server 2016、 dns 設定 DNS 負載平衡] 應用程式的原則。Previous versions of Windows Server DNS only provided load balancing by using round robin responses; but with DNS in Windows Server 2016, you can configure DNS policy for application load balancing.

當您完成部署多個應用程式時,您可以使用 DNS 原則,以平衡不同的應用程式執行個體,藉此動態應用程式的配置流量載入間流量載入。When you have deployed multiple instances of an application, you can use DNS policy to balance the traffic load between the different application instances, thereby dynamically allocating the traffic load for the application.

應用程式負載平衡的範例Example of Application Load Balancing

以下是您如何使用的應用程式負載平衡 DNS 原則的範例。Following is an example of how you can use DNS policy for application load balancing.

此範例中使用虛構公司-Contoso 禮品服務-提供 online gifing 服務,並其網站名為contosogiftservices.comThis example uses one fictional company - Contoso Gift Services - which provides online gifing services, and which has a Web site named contosogiftservices.com.

多個能源各有不同的 IP 位址裝載 contosogiftservices.com 網站。The contosogiftservices.com website is hosted in multiple datacenters that each have different IP addresses.

北美洲,以 Contoso 禮品服務主要市場,三個能源裝載網站: 伊利諾州芝加哥、 達拉斯、 傳送與西雅圖縣。In North America, which is the primary market for Contoso Gift Services, the Web site is hosted in three datacenters: Chicago, IL, Dallas, TX and Seattle, WA.

西雅圖網頁伺服器具有最佳硬體設定,並為兩個網站倍載入處理。The Seattle Web server has the best hardware configuration and can handle twice as much load as the other two sites. Contoso 禮品服務想要以下列方式導向的應用程式流量。Contoso Gift Services wants application traffic directed in the following manner.

  • 西雅圖網頁伺服器包含更多資源,因為一半的應用程式的用導向這個伺服器Because the Seattle Web server includes more resources, half of the application's clients are directed to this server
  • Datacenter 達拉斯、 傳送導向的應用程式的用一季One quarter of the application's clients are directed to the Dallas, TX datacenter
  • 伊利諾州芝加哥,datacenter 導向的應用程式的用一季One quarter of the application's clients are directed to the Chicago, IL, datacenter

下圖描述此案例。The following illustration depicts this scenario.

DNS 應用程式負載平衡 DNS 原則

應用程式如何負載平衡運作How Application Load Balancing Works

您已經設定好之後 DNS 原則的應用程式的 DNS 伺服器載入平衡使用此案例,DNS 伺服器回應 50%的西雅圖網頁伺服器位址,25%的達拉斯網頁伺服器位址,以及 25%的芝加哥網址伺服器的時間。After you have configured the DNS server with DNS policy for application load balancing using this example scenario, the DNS server responds 50% of the time with the Seattle Web server address, 25% of the time with the Dallas Web server address, and 25% of the time with the Chicago Web server address.

因此的 DNS 伺服器接收每個四個查詢,它看具有兩個回應西雅圖和一個每個達拉斯和芝加哥。Thus for every four queries the DNS server receives, it responds with two responses for Seattle and one each for Dallas and Chicago.

負載平衡 DNS 原則的一個可能的問題,是 DNS 記錄 DNS client 並解析日 LDNS,這可能會干擾負載平衡,因為 client 或解析不要傳送查詢 DNS 伺服器的快取。One possible issue with load balancing with DNS policy is the caching of DNS records by the DNS client and the resolver/LDNS, which can interfere with load balancing because the client or resolver do not send a query to the DNS server.

您可以使用較低的 Time\ to\ 動態 (TTL) 值應負載平衡 DNS 記錄降低效果的這個問題。You can mitigate the effect of this behavior by using a low Time-to-Live (TTL) value for the DNS records that should be load balanced.

如何設定應用程式負載平衡How to Configure Application Load Balancing

下列區段會顯示如何設定 DNS 負載平衡] 應用程式的原則。The following sections show you how to configure DNS policy for application load balancing.

建立區域範圍Create the Zone Scopes

您必須先建立領域的區域 contosogiftservices.com 資料中心裝載的位置。You must first create the scopes of the zone contosogiftservices.com for the datacenters where they are hosted.

時區領域是區域的唯一執行個體。A zone scope is a unique instance of the zone. DNS 區域可以有多個區域領域,與每個包含 DNS 記錄它自己設定的區域範圍。A DNS zone can have multiple zone scopes, with each zone scope containing its own set of DNS records. 相同記錄可能會出現在多個領域,以不同的 IP 位址或相同的 IP 位址。The same record can be present in multiple scopes, with different IP addresses or the same IP addresses.

注意

根據預設,區域領域存在於 DNS 區域。By default, a zone scope exists on the DNS zones. 這個區域領域作為區域,具有相同的名稱,並在這個領域中工作舊版 DNS 作業。This zone scope has the same name as the zone, and legacy DNS operations work on this scope.

您可以使用下列的 Windows PowerShell 命令來建立區域範圍。You can use the following Windows PowerShell commands to create zone scopes.

Add-DnsServerZoneScope -ZoneName "contosogiftservices.com" -Name "SeattleZoneScope"

Add-DnsServerZoneScope -ZoneName "contosogiftservices.com" -Name "DallasZoneScope"

Add-DnsServerZoneScope -ZoneName "contosogiftservices.com" -Name "ChicagoZoneScope"

如需詳細資訊,請查看新增-DnsServerZoneScopeFor more information, see Add-DnsServerZoneScope

若要的區域領域加入資料Add Records to the Zone Scopes

現在,您必須新增到區域領域代表網頁伺服器主機記錄。Now you must add the records representing the web server host into the zone scopes.

SeattleZoneScope,您可以將使用碼表進行 www.contosogiftservices.com IP 位址 192.0.0.1,位於西雅圖資料中心。In SeattleZoneScope, you can add the record www.contosogiftservices.com with IP address 192.0.0.1, which is located in the Seattle datacenter.

ChicagoZoneScope,您可以新增的 IP 位址 182.0.0.1 相同使用碼表進行 (www.contosogiftservices.com) 芝加哥資料中心。In ChicagoZoneScope, you can add the same record (www.contosogiftservices.com) with IP address 182.0.0.1 in the Chicago datacenter.

同樣地,在DallasZoneScope,您可以新增的 IP 位址 162.0.0.1 記錄 (www.contosogiftservices.com) 芝加哥資料中心。Similarly in DallasZoneScope, you can add a record (www.contosogiftservices.com) with IP address 162.0.0.1 in the Chicago datacenter.

您可以使用下列 Windows PowerShell 命令若要的區域領域加入資料。You can use the following Windows PowerShell commands to add records to the zone scopes.

Add-DnsServerResourceRecord -ZoneName "contosogiftservices.com" -A -Name "www" -IPv4Address "192.0.0.1" -ZoneScope "SeattleZoneScope

Add-DnsServerResourceRecord -ZoneName "contosogiftservices.com" -A -Name "www" -IPv4Address "182.0.0.1" -ZoneScope "ChicagoZoneScope"

Add-DnsServerResourceRecord -ZoneName "contosogiftservices.com" -A -Name "www" -IPv4Address "162.0.0.1" -ZoneScope "DallasZoneScope"

如需詳細資訊,請查看新增-DnsServerResourceRecordFor more information, see Add-DnsServerResourceRecord.

建立 DNS 原則Create the DNS Policies

您所建立的磁碟分割 (區域領域) 並新增了記錄之後,您必須建立 DNS 原則,連入查詢分配這些範圍,讓 50%的查詢 contosogiftservices.com 交給西雅圖 datacenter 中的網頁伺服器的 IP 位址和其他同樣視訊光碟之間芝加哥與達拉斯資料中心。After you have created the partitions (zone scopes) and you have added records, you must create DNS policies that distribute the incoming queries across these scopes so that 50% of queries for contosogiftservices.com are responded to with the IP address for the Web server in the Seattle datacenter and the rest are equally distributed between the Chicago and Dallas datacenters.

您可以使用下列的 Windows PowerShell 命令建立的餘額下列三種資料中心上的應用程式資料傳輸 DNS 原則。You can use the following Windows PowerShell commands to create a DNS policy that balances application traffic across these three datacenters.

注意

在下列運算式範例命令 – ZoneScope 」 SeattleZoneScope,2。ChicagoZoneScope,1。DallasZoneScope,1 」 設定的 DNS 伺服器的包含參數組合陣列 \ < ZoneScope\,> \ < weight\ >。In the example command below, the expression –ZoneScope "SeattleZoneScope,2; ChicagoZoneScope,1; DallasZoneScope,1" configures the DNS server with an array that includes the parameter combination <ZoneScope>,<weight>.

Add-DnsServerQueryResolutionPolicy -Name "AmericaPolicy" -Action ALLOW – -ZoneScope "SeattleZoneScope,2;ChicagoZoneScope,1;DallasZoneScope,1" -ZoneName "contosogiftservices.com"

如需詳細資訊,請查看新增-DnsServerQueryResolutionPolicyFor more information, see Add-DnsServerQueryResolutionPolicy.

您現在已成功建立 DNS 原則,以提供應用程式負載平衡三個不同的資料中心中的網頁伺服器上。You have now successfully created a DNS policy that provides application load balancing across Web servers in three different datacenters.

您可以建立數千 DNS 原則根據您的資料傳輸管理的需求,且所有的新原則已經套用動態-不需要重新 DNS 伺服器-連入查詢。You can create thousands of DNS policies according to your traffic management requirements, and all new policies are applied dynamically - without restarting the DNS server - on incoming queries.