我正在尝试将我的VMSS更改为:
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2016-Datacenter-with-Containers",
"version": "latest"
}
收件人:
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServerSemiAnnual",
"sku": "Datacenter-Core-1803-with-Containers-smalldisk",
"version": "latest"
}
我尝试的第一件事是:
Update-AzureRmVmss -ResourceGroupName "DevServiceFabric" -VMScaleSetName "HTTP" -ImageReferenceSku Datacenter-Core-1803-with-Containers-smalldisk -ImageReferenceOffer WindowsServerSemiAnnual
哪个给我错误:
Update-AzureRmVmss:不允许更改属性“ imageReference.offer”。 错误代码:PropertyChangeNotAllowed
这已在文档中得到确认;您只能在创建比例集后设置报价。
接下来,我尝试Add-AzureRmServiceFabricNodeType
添加新的节点类型,以为以后可以删除旧的节点类型。但是,此命令似乎不允许您设置操作系统映像。您只能设置VM SKU(换句话说,群集中的所有VM必须具有相同的OS)。
是否可以在不删除整个群集并且从头开始的情况下更改此设置?
答案 0 :(得分:1)
编辑:如果您可以停留在当前的发布商+报价之内,则只需更改SKU即可轻松切换操作系统。 See the answer by Mike。
如果您确实需要更改报价,可以执行以下操作:
Upgrade the size and operating system of the primary node type VMs。
请注意,您需要考虑很多事情,例如可用性级别。集群也将暂时无法从外部使用。
大幅缩短:
# Variables.
$groupname = "sfupgradetestgroup"
$clusterloc="southcentralus"
$subscriptionID="<your subscription ID>"
# sign in to your Azure account and select your subscription
Login-AzAccount -SubscriptionId $subscriptionID
# Create a new resource group for your deployment and give it a name and a location.
New-AzResourceGroup -Name $groupname -Location $clusterloc
# Deploy the two node type cluster.
New-AzResourceGroupDeployment -ResourceGroupName $groupname -TemplateParameterFile "C:\temp\cluster\Deploy-2NodeTypes-2ScaleSets.parameters.json" `
-TemplateFile "C:\temp\cluster\Deploy-2NodeTypes-2ScaleSets.json" -Verbose
# Connect to the cluster and check the cluster health.
$ClusterName= "sfupgradetest.southcentralus.cloudapp.azure.com:19000"
$thumb="F361720F4BD5449F6F083DDE99DC51A86985B25B"
Connect-ServiceFabricCluster -ConnectionEndpoint $ClusterName -KeepAliveIntervalInSec 10 `
-X509Credential `
-ServerCertThumbprint $thumb `
-FindType FindByThumbprint `
-FindValue $thumb `
-StoreLocation CurrentUser `
-StoreName My
Get-ServiceFabricClusterHealth
# Deploy a new scale set into the primary node type. Create a new load balancer and public IP address for the new scale set.
New-AzResourceGroupDeployment -ResourceGroupName $groupname -TemplateParameterFile "C:\temp\cluster\Deploy-2NodeTypes-3ScaleSets.parameters.json" `
-TemplateFile "C:\temp\cluster\Deploy-2NodeTypes-3ScaleSets.json" -Verbose
# Check the cluster health again. All 15 nodes should be healthy.
Get-ServiceFabricClusterHealth
# Disable the nodes in the original scale set.
$nodeNames = @("_NTvm1_0","_NTvm1_1","_NTvm1_2","_NTvm1_3","_NTvm1_4")
Write-Host "Disabling nodes..."
foreach($name in $nodeNames){
Disable-ServiceFabricNode -NodeName $name -Intent RemoveNode -Force
}
Write-Host "Checking node status..."
foreach($name in $nodeNames){
$state = Get-ServiceFabricNode -NodeName $name
$loopTimeout = 50
do{
Start-Sleep 5
$loopTimeout -= 1
$state = Get-ServiceFabricNode -NodeName $name
Write-Host "$name state: " $state.NodeDeactivationInfo.Status
}
while (($state.NodeDeactivationInfo.Status -ne "Completed") -and ($loopTimeout -ne 0))
if ($state.NodeStatus -ne [System.Fabric.Query.NodeStatus]::Disabled)
{
Write-Error "$name node deactivation failed with state" $state.NodeStatus
exit
}
}
# Remove the scale set
$scaleSetName="NTvm1"
Remove-AzVmss -ResourceGroupName $groupname -VMScaleSetName $scaleSetName -Force
Write-Host "Removed scale set $scaleSetName"
$lbname="LB-sfupgradetest-NTvm1"
$oldPublicIpName="PublicIP-LB-FE-0"
$newPublicIpName="PublicIP-LB-FE-2"
# Store DNS settings of public IP address related to old Primary NodeType into variable
$oldprimaryPublicIP = Get-AzPublicIpAddress -Name $oldPublicIpName -ResourceGroupName $groupname
$primaryDNSName = $oldprimaryPublicIP.DnsSettings.DomainNameLabel
$primaryDNSFqdn = $oldprimaryPublicIP.DnsSettings.Fqdn
# Remove Load Balancer related to old Primary NodeType. This will cause a brief period of downtime for the cluster
Remove-AzLoadBalancer -Name $lbname -ResourceGroupName $groupname -Force
# Remove the old public IP
Remove-AzPublicIpAddress -Name $oldPublicIpName -ResourceGroupName $groupname -Force
# Replace DNS settings of Public IP address related to new Primary Node Type with DNS settings of Public IP address related to old Primary Node Type
$PublicIP = Get-AzPublicIpAddress -Name $newPublicIpName -ResourceGroupName $groupname
$PublicIP.DnsSettings.DomainNameLabel = $primaryDNSName
$PublicIP.DnsSettings.Fqdn = $primaryDNSFqdn
Set-AzPublicIpAddress -PublicIpAddress $PublicIP
# Check the cluster health
Get-ServiceFabricClusterHealth
# Remove node state for the deleted nodes.
foreach($name in $nodeNames){
# Remove the node from the cluster
Remove-ServiceFabricNodeState -NodeName $name -TimeoutSec 300 -Force
Write-Host "Removed node state for node $name"
}
答案 1 :(得分:1)
对于那些想切换到另一个操作系统,但可以在同一发布者/要约中切换到一个操作系统映像的人,这是另一个(简单)的答案。您可以使用以下命令获取可用的OS SKU列表:
def bfs_short(graph, source, target):
visited = set()
queue = collections.deque([source])
d={}
d[source]=0
while queue:
u = queue.pop()
if u==target:
return d[target]
if u not in visited:
visited.add(u)
for w in graph[u]:
if w not in visited:
queue.appendleft(w)
d[w]=d[u]+1
然后,您可以通过以下方式升级群集以使用该映像:
Get-AzureRmVMImageSku -Location 'westus2' -PublisherName MicrosoftWindowsServer -Offer WindowsServer
该命令将需要一个小时或更长时间才能运行。
我还遇到了一些SKU,尽管它们出现在列表中,但都会出现“找不到图像”错误。不知道是什么原因造成的。但是,在这种情况下,我能够找到对我有用的东西。