教程:升级 Azure 中 Service Fabric 群集的运行时

本教程是四篇系列教程中的一篇,介绍如何升级 Azure Service Fabric 群集上的 Service Fabric 运行时。 本教程部分是针对 Azure 上运行的 Service Fabric 群集编写的,不适用于独立 Service Fabric 群集。

警告

本教程部分要求使用 PowerShell。 目前尚不支持使用 Azure CLI 工具升级群集运行时。 或者,可以在门户中升级群集。 有关详细信息,请参阅升级 Azure Service Fabric 群集

如果群集已在运行最新的 Service Fabric 运行时,则不需要执行此步骤。 但是,可以参考本文在 Azure Service Fabric 群集上安装任何受支持的运行时。

在本教程中,你将了解如何执行以下操作:

  • 读取群集版本
  • 设置群集版本

在此系列教程中,你会学习如何:

注意

建议使用 Azure Az PowerShell 模块与 Azure 交互。 请参阅安装 Azure PowerShell 以开始使用。 若要了解如何迁移到 Az PowerShell 模块,请参阅 将 Azure PowerShell 从 AzureRM 迁移到 Az

先决条件

在开始学习本教程之前:

登录 Azure

执行 Azure 命令之前,登录到你的 Azure 帐户并选择你的订阅。

Connect-AzAccount -Environment AzureChinaCloud
Get-AzSubscription
Set-AzContext -SubscriptionId <guid>

获取运行时版本

连接到 Azure 并选择包含 Service Fabric 群集的订阅之后,可获取群集的运行时版本。

Get-AzServiceFabricCluster -ResourceGroupName SFCLUSTERTUTORIALGROUP -Name aztestcluster `
    | Select-Object ClusterCodeVersion

或者,直接使用以下示例获取订阅中所有群集的列表:

Get-AzServiceFabricCluster | Select-Object Name, ClusterCodeVersion

请注意 ClusterCodeVersion 值。 在下一部分需使用此值。

升级运行时

Get-ServiceFabricRuntimeUpgradeVersion cmdlet 中使用在上一部分获取的 ClusterCodeVersion 值来发现可升级到的版本。 只能在已连接到 Internet 的计算机上运行此 cmdlet。 例如,如果想要查看可从版本 5.7.198.9494 升级到哪些运行时版本,请使用以下命令:

Get-ServiceFabricRuntimeUpgradeVersion -BaseVersion "5.7.198.9494"

使用版本列表,可以让 Azure Service Fabric 群集升级到更新的运行时。 例如,如果可升级到版本 6.0.219.9494,请使用以下命令升级群集。

Set-AzServiceFabricUpgradeType -ResourceGroupName SFCLUSTERTUTORIALGROUP `
                                    -Name aztestcluster `
                                    -UpgradeMode Manual `
                                    -Version "6.0.219.9494"

重要

群集运行时升级可能需要较长时间才能完成。 运行升级时,PowerShell 将被阻止。 可以使用另一个 PowerShell 会话来检查升级状态。

可以使用 PowerShell 或 Azure Service Fabric CLI (sfctl) 监视升级状态。

首先,请使用在本教程第一部分中创建的 TLS/SSL 证书连接到群集。 使用 Connect-ServiceFabricCluster cmdlet 或 sfctl cluster upgrade-status

$endpoint = "<mycluster>.chinanorth.cloudapp.chinacloudapi.cn:19000"
$thumbprint = "63EB5BA4BC2A3BADC42CA6F93D6F45E5AD98A1E4"

Connect-ServiceFabricCluster -ConnectionEndpoint $endpoint `
                             -KeepAliveIntervalInSec 10 `
                             -X509Credential -ServerCertThumbprint $thumbprint `
                             -FindType FindByThumbprint -FindValue $thumbprint `
                             -StoreLocation CurrentUser -StoreName My
sfctl cluster select --endpoint https://aztestcluster.chinanorth.cloudapp.chinacloudapi.cn:19080 \
--pem ./aztestcluster201709151446.pem --no-verify

接下来,使用 Get-ServiceFabricClusterUpgradesfctl cluster upgrade-status 显示状态。 将显示如下所示的结果。

Get-ServiceFabricClusterUpgrade

TargetCodeVersion                          : 6.0.219.9494
TargetConfigVersion                        : 3
StartTimestampUtc                          : 11/28/2017 3:09:48 AM
UpgradeState                               : RollingForwardPending
UpgradeDuration                            : 00:09:00
CurrentUpgradeDomainDuration               : 00:09:00
NextUpgradeDomain                          : 1
UpgradeDomainsStatus                       : { "0" = "Completed";
                                             "1" = "Pending";
                                             "2" = "Pending";
                                             "3" = "Pending";
                                             "4" = "Pending" }
UpgradeKind                                : Rolling
RollingUpgradeMode                         : Monitored
FailureAction                              : Rollback
ForceRestart                               : False
UpgradeReplicaSetCheckTimeout              : 37201.09:59:01
HealthCheckWaitDuration                    : 00:05:00
HealthCheckStableDuration                  : 00:05:00
HealthCheckRetryTimeout                    : 00:45:00
UpgradeDomainTimeout                       : 02:00:00
UpgradeTimeout                             : 12:00:00
ConsiderWarningAsError                     : False
MaxPercentUnhealthyApplications            : 0
MaxPercentUnhealthyNodes                   : 100
ApplicationTypeHealthPolicyMap             : {}
EnableDeltaHealthEvaluation                : True
MaxPercentDeltaUnhealthyNodes              : 0
MaxPercentUpgradeDomainDeltaUnhealthyNodes : 0
ApplicationHealthPolicyMap                 : {}
sfctl cluster upgrade-status

{
  "codeVersion": "6.0.219.9494",
  "configVersion": "3",

... item cut to save space ...

  },
  "upgradeDomains": [
    {
      "name": "0",
      "state": "Completed"
    },
    {
      "name": "1",
      "state": "Pending"
    },
    {
      "name": "2",
      "state": "Pending"
    },
    {
      "name": "3",
      "state": "Pending"
    },
    {
      "name": "4",
      "state": "Pending"
    }
  ],
  "upgradeDurationInMilliseconds": "PT1H2M4.63889S",
  "upgradeState": "RollingForwardPending"
}

后续步骤

在本教程中,你了解了如何执行以下操作:

  • 获取群集运行时的版本
  • 升级群集运行时
  • 监视升级

转到下一教程: