向在 Windows Server 上运行的独立 Service Fabric 群集添加或删除节点Add or remove nodes to a standalone Service Fabric cluster running on Windows Server

在 Windows Server 计算机上创建独立 Service Fabric 群集之后,(业务)需求可能发生变化,因此需要向群集添加或删除节点。After you have created your standalone Service Fabric cluster on Windows Server machines, your (business) needs may change and you will need to add or remove nodes to your cluster. 本文提供了实现此目标的详细步骤。This article provides detailed steps to achieve this. 请注意,在本地开发群集中不支持添加/删除节点的功能。Please note that add/remove node functionality is not supported in local development clusters.

向群集添加节点Add nodes to your cluster

  1. 按照计划和准备 Service Fabric 群集部署中概述的步骤,使要向其添加群集的VM/计算机准备就绪。Prepare the VM/machine you want to add to your cluster by following the steps outlined in Plan and prepare your Service Fabric cluster deployment

  2. 确定要向哪些容错域和升级域添加此 VM/计算机。Identify which fault domain and upgrade domain you are going to add this VM/machine to

  3. 通过远程桌面 (RDP) 方式进入需要向群集添加的 VM/计算机Remote desktop (RDP) into the VM/machine that you want to add to the cluster

  4. 向此 VM/计算机复制或下载适用于 Windows Server 的 Service Fabric 独立包,并解压该包Copy or download the standalone package for Service Fabric for Windows Server to the VM/machine and unzip the package

  5. 使用提升的权限运行 Powershell,并导航到解压缩包所在的位置。Run Powershell with elevated privileges, and navigate to the location of the unzipped package

  6. 使用描述要添加的新节点的参数运行 AddNode.ps1 脚本。Run the AddNode.ps1 script with the parameters describing the new node to add. 以下示例将名为 VM5、类型为 NodeType0 且 IP 地址为 182.17.34.52 的新节点添加到 UD1 和 fd:/dc1/r0 中。The example below adds a new node called VM5, with type NodeType0 and IP address 182.17.34.52, into UD1 and fd:/dc1/r0. ExistingClusterConnectionEndPoint 是现有群集中已有节点的连接终结点,可以是群集中任意节点的 IP 地址。 The ExistingClusterConnectionEndPoint is a connection endpoint for a node already in the existing cluster, which can be the IP address of any node in the cluster.

    .\AddNode.ps1 -NodeName VM5 -NodeType NodeType0 -NodeIPAddressorFQDN 182.17.34.52 -ExistingClientConnectionEndpoint 182.17.34.50:19000 -UpgradeDomain UD1 -FaultDomain fd:/dc1/r0 -AcceptEULA
    

    运行完脚本后,可以通过运行 Get-ServiceFabricNode cmdlet 来检查是否已添加新节点。Once the script finishes running, you can check if the new node has been added by running the Get-ServiceFabricNode cmdlet.

  7. 若要确保群集中不同节点的一致性,请务必启动配置升级。To ensure consistency across different nodes in the cluster, you must initiate a configuration upgrade. 运行 Get ServiceFabricClusterConfiguration 获取最新配置文件并将新添加的节点添加到“Nodes”节。Run Get-ServiceFabricClusterConfiguration to get the latest configuration file and add the newly added node to "Nodes" section. 如果需要使用相同配置重新部署群集,也建议始终使用最新的群集配置。It is also recommended to always have the latest cluster configuration available in the case that you need to redeploy a cluster with the same configuration.

    {
        "nodeName": "vm5",
        "iPAddress": "182.17.34.52",
        "nodeTypeRef": "NodeType0",
        "faultDomain": "fd:/dc1/r0",
        "upgradeDomain": "UD1"
    }
    
  8. 运行 Start-ServiceFabricClusterConfigurationUpgrade 开始升级。Run Start-ServiceFabricClusterConfigurationUpgrade to begin the upgrade.

    Start-ServiceFabricClusterConfigurationUpgrade -ClusterConfigPath <Path to Configuration File>
    
    

    可在 Service Fabric Explorer 中监视升级进度。You can monitor the progress of the upgrade on Service Fabric Explorer. 或者,也可运行 Get-ServiceFabricClusterUpgradeAlternatively, you can run Get-ServiceFabricClusterUpgrade

将节点添加到使用 gMSA 配置 Windows 安全性的群集中。Add nodes to clusters configured with Windows Security using gMSA

对于使用组托管服务帐户 (gMSA)(https://technet.microsoft.com/library/hh831782.aspx) 配置的群集,可以使用配置升级添加新的节点:For clusters configured with Group Managed Service Account(gMSA)(https://technet.microsoft.com/library/hh831782.aspx), a new node can be added using a configuration upgrade:

  1. 在现有的任意节点上运行 Get ServiceFabricClusterConfiguration,获取最新的配置文件,并在“Nodes”节中添加想要添加的新节点相关详细信息。Run Get-ServiceFabricClusterConfiguration on any of the existing nodes to get the latest configuration file and add details about the new node you want to add in the "Nodes" section. 请确保新节点属于同一组合托管帐户。Make sure the new node is part of the same group managed account. 此帐户应当是所有计算机的管理员。This account should be an Administrator on all machines.

    {
        "nodeName": "vm5",
        "iPAddress": "182.17.34.52",
        "nodeTypeRef": "NodeType0",
        "faultDomain": "fd:/dc1/r0",
        "upgradeDomain": "UD1"
    }
    
  2. 运行 Start-ServiceFabricClusterConfigurationUpgrade 开始升级。Run Start-ServiceFabricClusterConfigurationUpgrade to begin the upgrade.

    Start-ServiceFabricClusterConfigurationUpgrade -ClusterConfigPath <Path to Configuration File>
    

    可在 Service Fabric Explorer 中监视升级进度。You can monitor the progress of the upgrade on Service Fabric Explorer. 或者,也可运行 Get-ServiceFabricClusterUpgradeAlternatively, you can run Get-ServiceFabricClusterUpgrade

向群集添加节点类型Add node types to your cluster

为了添加新的节点类型,请修改配置,将新节点类型包含在“Properties”下的“NodeTypes”节中,并使用 Start-ServiceFabricClusterConfigurationUpgrade 开始配置升级。In order to add a new node type, modify your configuration to include the new node type in "NodeTypes" section under "Properties" and begin a configuration upgrade using Start-ServiceFabricClusterConfigurationUpgrade. 升级完成后,可以使用此节点类型将新节点添加到群集。Once the upgrade completes, you can add new nodes to your cluster with this node type.

从群集中删除节点Remove nodes from your cluster

可以采用以下方式通过配置升级将节点从群集中删除:A node can be removed from a cluster using a configuration upgrade, in the following manner:

  1. 运行 Get ServiceFabricClusterConfiguration 获取最新配置文件,并将节点从“Nodes”节中删除。 Run Get-ServiceFabricClusterConfiguration to get the latest configuration file and remove the node from "Nodes" section. 将“NodesToBeRemoved”参数添加到“FabricSettings”节中的“Setup”节。Add the "NodesToBeRemoved" parameter to "Setup" section inside "FabricSettings" section. “value”应是一个逗号分隔列表,其中包含需要删除的节点的节点名称。The "value" should be a comma separated list of node names of nodes that need to be removed.

    "fabricSettings": [
        {
        "name": "Setup",
        "parameters": [
            {
            "name": "FabricDataRoot",
            "value": "C:\\ProgramData\\SF"
            },
            {
            "name": "FabricLogRoot",
            "value": "C:\\ProgramData\\SF\\Log"
            },
            {
            "name": "NodesToBeRemoved",
            "value": "vm0, vm1"
            }
        ]
        }
    ]
    
  2. 运行 Start-ServiceFabricClusterConfigurationUpgrade 开始升级。Run Start-ServiceFabricClusterConfigurationUpgrade to begin the upgrade.

    Start-ServiceFabricClusterConfigurationUpgrade -ClusterConfigPath <Path to Configuration File>
    
    

    可在 Service Fabric Explorer 中监视升级进度。You can monitor the progress of the upgrade on Service Fabric Explorer. 或者,也可运行 Get-ServiceFabricClusterUpgradeAlternatively, you can run Get-ServiceFabricClusterUpgrade

Note

删除可能启动多个升级的节点。Removal of nodes may initiate multiple upgrades. 某些节点标有 IsSeedNode="true" 标记,可使用 Get-ServiceFabricClusterManifest 通过查询群集清单进行标识。Some nodes are marked with IsSeedNode="true" tag and can be identified by querying the cluster manifest using Get-ServiceFabricClusterManifest. 在此类方案中,因为种子节点需要移动,因此删除此类节点相比其他节点需要较长时间。Removal of such nodes may take longer than others since the seed nodes will have to be moved around in such scenarios. 群集必须至少维护 3 个主节点类型的节点。The cluster must maintain a minimum of 3 primary node type nodes.

从群集中删除节点类型Remove node types from your cluster

删除节点类型前,请仔细检查是否存在任何引用该节点类型的节点。Before removing a node type, please double check if there are any nodes referencing the node type. 请在删除相应节点类型之前删除这些节点。Remove these nodes before removing the corresponding node type. 删除所有相应节点后,可从群集配置中删除 NodeType 并使用 Start-ServiceFabricClusterConfigurationUpgrade 开始配置升级。Once all corresponding nodes are removed, you can remove the NodeType from the cluster configuration and begin a configuration upgrade using Start-ServiceFabricClusterConfigurationUpgrade.

替换群集的主节点Replace primary nodes of your cluster

应顺次执行主节点的替换,而不是成批删除,并成批添加。The replacement of primary nodes should be performed one node after another, instead of removing and then adding in batches.

后续步骤Next steps