Tôi đang cố gắng tự động hóa việc tạo trang trại máy chủ trong PowerShell. Qua sự sáng tạo của nhãn hiệu Tôi đã có XML sau đây:Tạo trang trại trên PowerShell
<webFarms>
<webFarm name="alwaysup" enabled="true">
<server address="alwaysup-blue" enabled="true">
<applicationRequestRouting httpPort="8001" />
</server>
<server address="alwaysup-green" enabled="true">
<applicationRequestRouting httpPort="8002" />
</server>
<applicationRequestRouting>
<healthCheck url="http://alwaysup/up.html" interval="00:00:05" responseMatch="up" />
</applicationRequestRouting>
</webFarm>
<applicationRequestRouting>
<hostAffinityProviderList>
<add name="Microsoft.Web.Arr.HostNameRoundRobin" />
</hostAffinityProviderList>
</applicationRequestRouting>
</webFarms>
Đang cố gắng để thực hiện điều này thông qua PS chứng minh phiền hà tuy nhiên: như xa như tôi có thể nói không có API chuyên dụng để làm điều này thông qua (WebFarmSnapin có nghĩa là cho một cũ phiên bản).
Tôi đã chuyển sự chú ý của mình sang IIS Administration Cmdlets nhưng chỉ nhận được một nửa hoạt động.
Mã mà tôi có:
#####
# Overwriting the server farm
#####
Write-Host "Overwriting the server farm $($webFarmName)"
$webFarm = @{};
$webFarm["name"] = 'siteFarm'
Set-WebConfiguration "/webFarms" -Value $webFarm
#####
# Adding the servers
#####
Write-Host "Adding the servers"
$blueServer = @{}
$blueServer["address"] = 'site-blue'
$blueServer["applicationRequestRouting"] = @{}
$greenServer = @{}
$greenServer["address"] = 'site-green'
$greenServer["applicationRequestRouting"] = @{}
$servers = @($blueServer, $greenServer)
Add-WebConfiguration -Filter "/webFarms/webFarm[@name='siteFarm']" -Value $servers
#####
# Adding routing
#####
Write-Host "Adding the routing configurations"
$blueServerRouting = @{}
$blueServerRouting["httpPort"] = "8001"
Add-WebConfiguration -Filter "/webFarms/webFarm[@name='siteFarm']/server[@address='site-blue']" -Value $blueServerRouting
này tạo
<webFarms>
<webFarm name="siteFarm">
<server address="site-blue" />
<server address="site-green" />
</webFarm>
<applicationRequestRouting>
<hostAffinityProviderList>
<add name="Microsoft.Web.Arr.HostNameRoundRobin" />
</hostAffinityProviderList>
</applicationRequestRouting>
</webFarms>
Như bạn có thể nhìn thấy nó thiếu các cổng liên quan đến việc định tuyến. Và tôi thậm chí không bắt đầu với việc cố gắng thêm healthcheck vào thời điểm này.
Tôi đang làm gì sai? Có một số Cmdlet mà tôi đã không tìm thấy mà làm cho điều này dễ dàng hơn?
Related nhưng không có nhiều câu trả lời hữu ích (tab PowerShell có mã được tạo vẫn trống).
Bạn có thể thử và xem liệu nhà cung cấp IIS có thể thực hiện những gì bạn muốn https://technet.microsoft.com/en-us/library/ee909471(v=ws.10).aspx Có thể cho là có nhiều hơn một chút -gritty hơn bằng cách sử dụng các lệnh ghép ngắn IIS, nhưng đôi khi đó là những gì nó cần. – mtnielsen
Bạn đã xem lệnh ghép ngắn này để cấu hình cổng chưa? 'Set-WebBinding -Name 'Default Web Site' -BindingInformation '*: 80:" -PropertyName "Port" -Value "1234" 'Tôi không quen thuộc lắm với webfarms để biết liệu điều này có giúp ích cho bạn hay không. – FoxDeploy
Nếu bạn chưa có, tôi khuyên bạn nên xem xét [tài nguyên xWebAdministration DSC] (https://github.com/PowerShell/xWebAdministration) để tự động hóa trạng thái tạo/cấu hình/mong muốn của webfarm. Các mô-đun WebAdministration lá rất nhiều để được mong muốn (nói từ kinh nghiệm sau khi tự động hóa một số thiết lập IIS đầu năm nay) – TheIncorrigible1