升级群集上运行的 Service Fabric 版本Upgrade the Service Fabric version that runs on your cluster

对于任何新式系统而言,升级能力是实现产品长期成功的关键所在。For any modern system, the ability to upgrade is key to the long-term success of your product. Azure Service Fabric 群集是你拥有的资源。An Azure Service Fabric cluster is a resource that you own. 本文介绍如何升级独立群集上运行的 Service Fabric 版本。This article describes how to upgrade the version of Service Fabric running on your standalone cluster.

备注

确保群集始终运行受支持的 Service Fabric 版本。Make sure that your cluster always runs a supported Service Fabric version. 当 Azure 宣布发布新版 Service Fabric 时,即标志着自宣布日期起至少 60 天后,将结束对旧版的支持。When Azure announces the release of a new version of Service Fabric, the previous version is marked for end of support after a minimum of 60 days from the date of the announcement. 新版本将在 Service Fabric 团队博客中宣布。New releases are announced on the Service Fabric team blog. 从该时间开始,便可以选择使用新版本。The new release is available to choose at that point.

仅当使用的是生产形式的节点配置(每个 Service Fabric 节点在独立的物理机或虚拟机上分配)时,才可以将群集升级到最新版本。You can upgrade your cluster to the new version only if you're using a production-style node configuration, where each Service Fabric node is allocated on a separate physical or virtual machine. 如果使用的是开发群集(单个物理机或虚拟机上有多个 Service Fabric 节点),必须使用新版本重新创建该群集。If you have a development cluster, where more than one Service Fabric node is on a single physical or virtual machine, you must re-create the cluster with the new version.

可以使用两个不同的工作流将群集升级至最新版本或受支持的 Service Fabric 版本。Two distinct workflows can upgrade your cluster to the latest version or a supported Service Fabric version. 其中一个工作流适用于已建立网络连接,可自动下载最新版本的群集。One workflow is for clusters that have connectivity to download the latest version automatically. 另一个工作流适用于未建立网络连接,无法下载最新 Service Fabric 版本的群集。The other workflow is for clusters that don't have connectivity to download the latest Service Fabric version.

支持自动升级群集的 Service Fabric 版本Enable auto-upgrade of the Service Fabric version of your cluster

要将群集设置为在 Azure 发布新版本时下载 Service Fabric 的更新,可将 fabricClusterAutoupgradeEnabled 群集配置设置为 true 。To set your cluster to download updates of Service Fabric when Azure releases a new version, set the fabricClusterAutoupgradeEnabled cluster configuration to true. 若要手动选择希望群集一直使用的某个受支持的 Service Fabric 版本,可将 fabricClusterAutoupgradeEnabled 群集配置设置为 false 。To manually select a supported version of Service Fabric that you want your cluster to be on, set the fabricClusterAutoupgradeEnabled cluster configuration to false.

升级已建立网络连接,可下载最新代码和配置的群集Upgrade clusters that have connectivity to download the latest code and configuration

如果群集节点已与下载中心建立 Internet 连接,请使用以下步骤将群集升级到支持的版本。Use these steps to upgrade your cluster to a supported version if your cluster nodes have internet connectivity to the Download Center.

对于已连接到下载中心的群集,Azure 会定期检查是否有新的 Service Fabric 版本可用。For clusters that have connectivity to the Download Center, Azure periodically checks for the availability of new Service Fabric versions.

推出新的 Service Fabric 版本时,相应的包将下载到群集本地,并为升级完成预配。When a new Service Fabric version is available, the package is downloaded locally to the cluster and provisioned for upgrade. 此外,为了通知客户已推出新版本,系统会明确显示类似于下面的群集运行状况警告:Additionally, to inform the customer of this new version, the system shows an explicit cluster health warning that's similar to the following:

“当前的群集版本 [版本号] 支持在 [日期] 结束。”"The current cluster version [version #] support ends [date]."

群集运行最新版本后,警告将会消失。After the cluster is running the latest version, the warning goes away.

看到群集运行状况警告时,请更新群集:When you see the cluster health warning, upgrade the cluster:

  1. 从对群集配置文件中列为节点的所有计算机拥有管理员访问权限的任何计算机连接到该群集。Connect to the cluster from any machine that has administrator access to all the machines that are listed as nodes in the cluster. 运行此脚本的计算机不一定是群集的一部分。The machine that this script is run on doesn't have to be part of the cluster.

    ###### connect to the secure cluster using certs
    $ClusterName= "mysecurecluster.something.com:19000"
    $CertThumbprint= "70EF5E22ADB649799DA3C8B6A6BF7FG2D630F8F3"
    Connect-serviceFabricCluster -ConnectionEndpoint $ClusterName -KeepAliveIntervalInSec 10 `
        -X509Credential `
        -ServerCertThumbprint $CertThumbprint  `
        -FindType FindByThumbprint `
        -FindValue $CertThumbprint `
        -StoreLocation CurrentUser `
        -StoreName My
    
  2. 获取可以升级到的 Service Fabric 版本的列表。Get the list of Service Fabric versions that you can upgrade to.

    ###### Get the list of available Service Fabric versions
    Get-ServiceFabricRegisteredClusterCodeVersion
    

    应会看到类似于下面的输出:You should get an output similar to this:

    获取 Service Fabric 版本

  3. 使用 Start-ServiceFabricClusterUpgrade Windows PowerShell 命令,开始将群集升级到可用的版本。Start a cluster upgrade to an available version by using the Start-ServiceFabricClusterUpgrade Windows PowerShell command.

    Start-ServiceFabricClusterUpgrade -Code -CodePackageVersion <codeversion#> -Monitored -FailureAction Rollback
    
    ###### Here is a filled-out example
    
    Start-ServiceFabricClusterUpgrade -Code -CodePackageVersion 5.3.301.9590 -Monitored -FailureAction Rollback
    

    若要监视升级进度,可以使用 Service Fabric Explorer,也可以运行以下 PowerShell 命令:To monitor the progress of the upgrade, you can use Service Fabric Explorer or run the following PowerShell command:

    Get-ServiceFabricClusterUpgrade
    

    如果不符合现行的群集运行状况策略,则回滚升级。If the cluster health policies aren't met, the upgrade is rolled back. 若要为 Start-ServiceFabricClusterUpgrade 命令指定自定义运行状况策略,请参阅 Start-ServiceFabricClusterUpgrade 的文档。To specify custom health policies for the Start-ServiceFabricClusterUpgrade command, see the documentation for Start-ServiceFabricClusterUpgrade.

    解决造成回滚的问题后,请遵循前面所述的相同步骤再次启动升级。After you fix the issues that resulted in the rollback, initiate the upgrade again by following the same steps as previously described.

升级 未建立网络连接,无法下载最新代码和配置的群集Upgrade clusters that have no connectivity to download the latest code and configuration

如果群集节点未与下载中心建立 Internet 连接,请使用以下步骤将群集升级到支持的版本。Use these steps to upgrade your cluster to a supported version if your cluster nodes don't have internet connectivity to the Download Center.

备注

如果运行的群集未连接到 Internet,则必须关注 Service Fabric 团队博客来了解新版本的信息。If you're running a cluster that isn't connected to the internet, you have to monitor the Service Fabric team blog to learn about new releases. 系统不会显示任何群集运行状况警告来提醒有新版本可用。The system doesn't show a cluster health warning to alert you of new releases.

自动预配与手动预配Auto provisioning vs. manual provisioning

若要为最新代码版本启用自动下载和注册,请设置 Service Fabric 更新服务。To enable automatic downloading and registration for the latest code version, set up the Service Fabric Update Service. 有关说明,请参阅独立包中的 Tools\ServiceFabricUpdateService.zip\Readme_InstructionsAndHowTos.txt 。For instructions, see Tools\ServiceFabricUpdateService.zip\Readme_InstructionsAndHowTos.txt in the standalone package.

对于手动步骤,请根据以下说明操作。For the manual process, follow these instructions.

在启动配置升级之前,请修改群集配置,将以下属性设置为 falseModify your cluster configuration to set the following property to false before you start a configuration upgrade:

"fabricClusterAutoupgradeEnabled": false,

有关用法详细信息,请参阅 Start-ServiceFabricClusterConfigurationUpgrade PowerShell 命令。For usage details, see the Start-ServiceFabricClusterConfigurationUpgrade PowerShell command. 在启动配置升级之前,请务必在 JSON 中更新“clusterConfigurationVersion”。Make sure to update 'clusterConfigurationVersion' in your JSON before you start the configuration upgrade.

    Start-ServiceFabricClusterConfigurationUpgrade -ClusterConfigPath <Path to Configuration File>

群集升级工作流Cluster upgrade workflow

  1. 从群集中的一个节点运行 Get-ServiceFabricClusterUpgrade 并记下 TargetCodeVersionRun Get-ServiceFabricClusterUpgrade from one of the nodes in the cluster and note the TargetCodeVersion.

  2. 从连接到 Internet 的计算机运行以下命令,以列出与当前版本兼容的所有升级版本,并从关联的下载链接下载相应的程序包:Run the following from an internet-connected machine to list all upgrade-compatible versions with the current version and download the corresponding package from the associated download links:

    ###### Get list of all upgrade compatible packages  
    Get-ServiceFabricRuntimeUpgradeVersion -BaseVersion <TargetCodeVersion as noted in Step 1> 
    
  3. 从对群集配置文件中列为节点的所有计算机拥有管理员访问权限的任何计算机连接到该群集。Connect to the cluster from any machine that has administrator access to all the machines that are listed as nodes in the cluster. 运行此脚本的计算机不一定是群集的一部分。The machine that this script is run on doesn't have to be part of the cluster.

    ###### Get the list of available Service Fabric versions
    Copy-ServiceFabricClusterPackage -Code -CodePackagePath <name of the .cab file including the path to it> -ImageStoreConnectionString "fabric:ImageStore"
    
    ###### Here is a filled-out example
    Copy-ServiceFabricClusterPackage -Code -CodePackagePath .\MicrosoftAzureServiceFabric.5.3.301.9590.cab -ImageStoreConnectionString "fabric:ImageStore"
    
  4. 将下载的包复制到群集映像存储区中。Copy the downloaded package into the cluster image store.

  5. 注册复制的程序包。Register the copied package.

    ###### Get the list of available Service Fabric versions
    Register-ServiceFabricClusterPackage -Code -CodePackagePath <name of the .cab file>
    
    ###### Here is a filled-out example
    Register-ServiceFabricClusterPackage -Code -CodePackagePath .\MicrosoftAzureServiceFabric.5.3.301.9590.cab
    
  6. 开始将群集升级到可用版本。Start a cluster upgrade to an available version.

    Start-ServiceFabricClusterUpgrade -Code -CodePackageVersion <codeversion#> -Monitored -FailureAction Rollback
    
    ###### Here is a filled-out example
    Start-ServiceFabricClusterUpgrade -Code -CodePackageVersion 5.3.301.9590 -Monitored -FailureAction Rollback
    

    可以在 Service Fabric Explorer 中或通过运行以下 PowerShell 命令来监视升级进度:You can monitor the progress of the upgrade on Service Fabric Explorer, or you can run the following PowerShell command:

    Get-ServiceFabricClusterUpgrade
    

    如果不符合现行的群集运行状况策略,则回滚升级。If the cluster health policies aren't met, the upgrade is rolled back. 若要为 Start-ServiceFabricClusterUpgrade 命令指定自定义运行状况策略,请参阅 Start-ServiceFabricClusterUpgrade 的文档。To specify custom health policies for the Start-ServiceFabricClusterUpgrade command, see the documentation for Start-ServiceFabricClusterUpgrade.

    解决造成回滚的问题后,请遵循前面所述的相同步骤再次启动升级。After you fix the issues that resulted in the rollback, initiate the upgrade again by following the same steps as previously described.

后续步骤Next steps