创建在 Windows Server 上运行的独立群集Create a standalone cluster running on Windows Server

可以使用 Azure Service Fabric 在运行 Windows Server 的任何虚拟机或计算机上创建 Service Fabric 群集。You can use Azure Service Fabric to create Service Fabric clusters on any virtual machines or computers running Windows Server. 这意味着,可以在包含一组相互连接的 Windows Server 计算机的任何环境(无论是本地环境还是任何云提供商所提供的环境)中部署和运行 Service Fabric 应用程序。This means you can deploy and run Service Fabric applications in any environment that contains a set of interconnected Windows Server computers, be it on premises or with any cloud provider. Service Fabric 提供了一个安装程序包,用于创建名为“Windows Server 独立包”的 Service Fabric 群集。Service Fabric provides a setup package to create Service Fabric clusters called the standalone Windows Server package. Azure 上的传统 Service Fabric 群集作为托管服务提供,而独立的 Service Fabric 群集是自助服务。Traditional Service Fabric clusters on Azure are available as a managed service, while standalone Service Fabric clusters are self-service. 有关差异的详细信息,请参阅比较 Azure 和独立 Service Fabric 群集For more on the differences, see Comparing Azure and standalone Service Fabric clusters.

本文逐步讲解如何创建 Service Fabric 独立群集。This article walks you through the steps for creating a Service Fabric standalone cluster.


此独立的 Windows Server 包可供免费商用,并且可用于生产部署。This standalone Windows Server package is commercially available at no cost and may be used for production deployments. 此包可能包含“预览”形式的新 Service Fabric 功能。This package may contain new Service Fabric features that are in "Preview". 向下滚动到 此包中包括的预览功能Scroll down to "Preview features included in this package." 预览功能列表部分。section for the list of the preview features. 可以立即 下载一份 EULAYou can download a copy of the EULA now.

获取用于 Windows Server 的 Service Fabric 包的支持Get support for the Service Fabric for Windows Server package

下载用于 Windows Server 的 Service Fabric 包Download the Service Fabric for Windows Server package

若要创建群集,请使用可在此处找到的用于 Windows Server 的 Service Fabric 包(Windows Server 2012 R2 和更高版本):To create the cluster, use the Service Fabric for Windows Server package (Windows Server 2012 R2 and newer) found here:
下载链接 - Service Fabric 独立包 - Windows ServerDownload Link - Service Fabric Standalone Package - Windows Server

此处查找有关包内容的详细信息。Find details on contents of the package here.

创建群集时,会自动下载 Service Fabric 运行时包。The Service Fabric runtime package is automatically downloaded at time of cluster creation. 如果通过未连接到 Internet 的计算机部署,请从此处下载带外的运行时包:If deploying from a machine not connected to the internet, please download the runtime package out of band from here:
下载链接 - Service Fabric 运行时 - Windows ServerDownload Link - Service Fabric Runtime - Windows Server

在此处查找独立群集配置示例:Find Standalone Cluster Configuration samples at:
独特群集配置示例Standalone Cluster Configuration Samples

创建群集Create the cluster

可以通过安装包安装多个示例性的群集配置文件。Several sample cluster configuration files are installed with the setup package. ClusterConfig.Unsecure.DevCluster.json 是最简单的群集配置:在单台计算机上运行一个不受保护的三节点群集。ClusterConfig.Unsecure.DevCluster.json is the simplest cluster configuration: an unsecure, three-node cluster running on a single computer. 其他配置文件描述的是受 X.509 证书或 Windows 安全措施保护的单机或多机群集。Other config files describe single or multi-machine clusters secured with X.509 certificates or Windows security. 就本教程来说,无需修改任何默认的配置设置,但仍请查看配置文件,熟悉一下这些设置。You don't need to modify any of the default config settings for this tutorial, but look through the config file and get familiar with the settings. nodes 节描述了群集中的三个节点:名称、IP 地址、 节点类型、容错域和升级域The nodes section describes the three nodes in the cluster: name, IP address, node type, fault domain, and upgrade domain. properties 节定义群集的 安全性、可靠级别、诊断集合和节点类型The properties section defines the security, reliability level, diagnostics collection, and types of nodes for the cluster.

本文中创建的群集是不安全的。The cluster created in this article is unsecure. 任何人都可以进行匿名连接并执行管理操作,因此生产型群集应始终使用 X.509 证书或 Windows 安全措施来确保安全性。Anyone can connect anonymously and perform management operations, so production clusters should always be secured using X.509 certificates or Windows security. 安全性只能在群集创建时配置,不能在创建群集以后启用安全性。Security is only configured at cluster creation time and it is not possible to enable security after the cluster is created. 更新配置文件以启用证书安全性Windows 安全性Update the config file enable certificate security or Windows security. 请阅读保护群集,详细了解 Service Fabric 群集安全性。Read Secure a cluster to learn more about Service Fabric cluster security.

步骤 1:创建群集Step 1: Create the cluster

方案 A:创建不受保护的本地开发群集Scenario A: Create an unsecured local development cluster

可以使用 示例 中包含的 ClusterConfig.Unsecure.DevCluster.json 文件将 Service Fabric 部署到单机开发群集。Service Fabric can be deployed to a one-machine development cluster by using the ClusterConfig.Unsecure.DevCluster.json file included in Samples.

将独立包解压缩到计算机,将示例配置文件复制到本地计算机,然后通过管理员 PowerShell 会话从独立包文件夹中运行 CreateServiceFabricCluster.ps1 脚本。Unpack the standalone package to your machine, copy the sample config file to the local machine, then run the CreateServiceFabricCluster.ps1 script through an administrator PowerShell session, from the standalone package folder.

.\CreateServiceFabricCluster.ps1 -ClusterConfigFilePath .\ClusterConfig.Unsecure.DevCluster.json -AcceptEULA

有关故障排除的详细信息,请参阅计划和准备群集部署中的环境设置部分。See the Environment Setup section at Plan and prepare your cluster deployment for troubleshooting details.

如果已完成运行开发方案,则可以引用“删除群集”部分的步骤,从计算机中删除 Service Fabric 群集。If you're finished running development scenarios, you can remove the Service Fabric cluster from the machine by referring to steps in section "Remove a cluster".

方案 B:创建多机群集Scenario B: Create a multi-machine cluster

在完成计划和准备群集部署中详述的计划和准备步骤后,就可以使用群集配置文件创建生产群集。After you have gone through the planning and preparation steps detailed at Plan and prepare your cluster deployment, you are ready to create your production cluster using your cluster configuration file.

部署和配置群集的群集管理员必须拥有计算机的管理员权限。The cluster administrator deploying and configuring the cluster must have administrator privileges on the computer. 不能在域控制器上安装 Service Fabric。You cannot install Service Fabric on a domain controller.

  1. 独立包中的 TestConfiguration.ps1 脚本可以用作最佳做法分析器,验证群集能否在给定环境中部署。The TestConfiguration.ps1 script in the standalone package is used as a best practices analyzer to validate whether a cluster can be deployed on a given environment. 部署准备列出了先决条件和环境要求。Deployment preparation lists the pre-requisites and environment requirements. 请运行以下脚本,验证你能否创建开发群集:Run the script to verify if you can create the development cluster:

    .\TestConfiguration.ps1 -ClusterConfigFilePath .\ClusterConfig.json

    输出与以下类似。You should see output similar to the following. 如果底部字段“Passed”的返回值为“True”,那么已通过完整性检查,并且根据输入配置群集看似可以部署。If the bottom field "Passed" is returned as "True", sanity checks have passed and the cluster looks to be deployable based on the input configuration.

    Trace folder already exists. Traces will be written to existing trace folder: C:\temp\Microsoft.Azure.ServiceFabric.WindowsServer\DeploymentTraces
    Running Best Practices Analyzer...
    Best Practices Analyzer completed successfully.
    LocalAdminPrivilege        : True
    IsJsonValid                : True
    IsCabValid                 : True
    RequiredPortsOpen          : True
    RemoteRegistryAvailable    : True
    FirewallAvailable          : True
    RpcCheckPassed             : True
    NoConflictingInstallations : True
    FabricInstallable          : True
    Passed                     : True
  2. 创建群集:运行 CreateServiceFabricCluster.ps1 脚本,以便在配置中的每台计算机上部署 Service Fabric 群集。Create the cluster: Run the CreateServiceFabricCluster.ps1 script to deploy the Service Fabric cluster across each machine in the configuration.

    .\CreateServiceFabricCluster.ps1 -ClusterConfigFilePath .\ClusterConfig.json -AcceptEULA


部署跟踪已写入运行 CreateServiceFabricCluster.ps1 PowerShell 脚本的 VM/计算机。Deployment traces are written to the VM/machine on which you ran the CreateServiceFabricCluster.ps1 PowerShell script. 可在运行脚本的目录中的子文件夹 DeploymentTraces 中找到这些信息。These can be found in the subfolder DeploymentTraces, based in the directory from which the script was run. 要确定是否已将 Service Fabric 正确部署到计算机,请根据群集配置文件 FabricSettings 部分中的详述找到 FabricDataRoot 目录(默认为 c:\ProgramData\SF)中安装的文件。To see if Service Fabric was deployed correctly to a machine, find the installed files in the FabricDataRoot directory, as detailed in the cluster configuration file FabricSettings section (by default c:\ProgramData\SF). 在任务管理器中也可以看到 FabricHost.exe 和 Fabric.exe 进程正在运行。As well, FabricHost.exe and Fabric.exe processes can be seen running in Task Manager.

方案 C:创建脱机(Internet 断开)群集Scenario C: Create an offline (internet-disconnected) cluster

创建群集时自动下载 Service Fabric 运行时包。The Service Fabric runtime package is automatically downloaded at cluster creation. 将群集部署到未连接 Internet 的计算机时,需要单独下载 Service Fabric 运行时包,并在创建群集时提供指向它的路径。When deploying a cluster to machines not connected to the internet, you will need to download the Service Fabric runtime package separately, and provide the path to it at cluster creation. 运行时包可从另一台连接到 Internet 的计算机单独下载:下载链接 - Service Fabric 运行时 - Windows ServerThe runtime package can be downloaded separately, from another machine connected to the internet, at Download Link - Service Fabric Runtime - Windows Server. 将运行时包复制到从中部署脱机群集的位置,并通过运行包含 -FabricRuntimePackagePath 参数的 CreateServiceFabricCluster.ps1 创建群集,如此示例所示:Copy the runtime package to where you are deploying the offline cluster from, and create the cluster by running CreateServiceFabricCluster.ps1 with the -FabricRuntimePackagePath parameter included, as shown in this example:

.\CreateServiceFabricCluster.ps1 -ClusterConfigFilePath .\ClusterConfig.json -FabricRuntimePackagePath .\MicrosoftAzureServiceFabric.cab

.\ClusterConfig.json.\MicrosoftAzureServiceFabric.cab 分别是群集配置和运行时 .cab 文件的路径。.\ClusterConfig.json and .\MicrosoftAzureServiceFabric.cab are the paths to the cluster configuration and the runtime .cab file respectively.

步骤 2:连接至群集Step 2: Connect to the cluster

连接到群集以验证群集是否正在运行且可用。Connect to the cluster to verify the cluster is running and available. ServiceFabric PowerShell 模块与运行时一起安装。The ServiceFabric PowerShell module is installed with the runtime. 可以从其中一个群集节点或使用 Service Fabric 运行时从远程计算机连接到群集。You can connect to the cluster from one of the cluster nodes or from a remote computer with the Service Fabric runtime. Connect-ServiceFabricCluster cmdlet 可建立到群集的连接。The Connect-ServiceFabricCluster cmdlet establishes a connection to the cluster.

若要连接到非安全群集,请运行以下 PowerShell 命令:To connect to an unsecure cluster, run the following PowerShell command:

Connect-ServiceFabricCluster -ConnectionEndpoint <*IPAddressofaMachine*>:<Client connection end point port>

例如:For example:

Connect-ServiceFabricCluster -ConnectionEndpoint

有关如何连接到群集的其他示例,请参阅连接到安全群集See Connect to a secure cluster for other examples of connecting to a cluster. 连接到群集以后,请使用 Get-ServiceFabricNode cmdlet 显示群集中节点的列表,以及每个节点的状态信息。After connecting to the cluster, use the Get-ServiceFabricNode cmdlet to display a list of nodes in the cluster and status information for each node. 每个节点的 HealthState 应该为“正常”。HealthState should be OK for each node.

PS C:\temp\Microsoft.Azure.ServiceFabric.WindowsServer> Get-ServiceFabricNode |Format-Table

NodeDeactivationInfo NodeName IpAddressOrFQDN NodeType  CodeVersion  ConfigVersion NodeStatus NodeUpTime NodeDownTime HealthState
-------------------- -------- --------------- --------  ----------- ------------- ---------- ---------- ------------ -----------
                     vm2      localhost       NodeType2 0                     Up 00:03:38   00:00:00              OK
                     vm1      localhost       NodeType1 0                     Up 00:03:38   00:00:00              OK
                     vm0      localhost       NodeType0 0                     Up 00:02:43   00:00:00              OK

步骤 3:使用 Service Fabric Explorer 可视化群集Step 3: Visualize the cluster using Service Fabric explorer

Service Fabric Explorer 是一项很好的工具,适用于可视化群集和管理应用程序。Service Fabric Explorer is a good tool for visualizing your cluster and managing applications. Service Fabric Explorer 是一项在群集中运行的服务,使用浏览器导航到 http://localhost:19080/Explorer 即可访问该服务。Service Fabric Explorer is a service that runs in the cluster, which you access using a browser by navigating to http://localhost:19080/Explorer.

群集仪表板提供了群集的概览,包括应用程序和节点运行状况的摘要。The cluster dashboard provides an overview of your cluster, including a summary of application and node health. 节点视图显示群集的物理布局。The node view shows the physical layout of the cluster. 对于给定的节点,可以检查已在该节点上部署代码的应用程序。For a given node, you can inspect which applications have code deployed on that node.

Service Fabric Explorer

添加和删除节点Add and remove nodes

当业务需要改变时,可以向独立 Service Fabric 群集添加或删除节点。You can add or remove nodes to your standalone Service Fabric cluster as your business needs change. 参阅向 Service Fabric 独立群集添加或删节点以了解详细步骤。See Add or Remove nodes to a Service Fabric standalone cluster for detailed steps.

删除群集Remove a cluster

若要删除群集,请运行包文件夹中的 RemoveServiceFabricCluster.ps1 Powershell 脚本,并传入 JSON 配置文件的路径。To remove a cluster, run the RemoveServiceFabricCluster.ps1 PowerShell script from the package folder and pass in the path to the JSON configuration file. 可以选择性地指定删除日志的位置。You can optionally specify a location for the log of the deletion.

可以在对群集配置文件中列为节点的所有计算机具有管理员访问权限的任何计算机上运行此脚本。This script can be run on any machine that has administrator access to all the machines that are listed as nodes in the cluster configuration file. 运行此脚本的计算机不必要是群集的一部分。The machine that this script is run on does not have to be part of the cluster.

# Removes Service Fabric from each machine in the configuration
.\RemoveServiceFabricCluster.ps1 -ClusterConfigFilePath .\ClusterConfig.json -Force
# Removes Service Fabric from the current machine

收集的遥测数据以及如何选择禁用遥测Telemetry data collected and how to opt out of it

默认情况下,本产品会收集有关 Service Fabric 使用情况的遥测数据来改善自身。As a default, the product collects telemetry on the Service Fabric usage to improve the product. 在安装过程中运行的最佳做法分析器将检查能否连接到 https://vortex.data.microsoft.com/collect/v1The Best Practice Analyzer that runs as a part of the setup checks for connectivity to https://vortex.data.microsoft.com/collect/v1. 如果无法连接,安装会失败,除非选择禁用遥测。If it is not reachable, the setup fails unless you opt out of telemetry.

  1. 遥测管道每天都会尝试一次将以下数据上传到 https://vortex.data.microsoft.com/collect/v1The telemetry pipeline tries to upload the following data to https://vortex.data.microsoft.com/collect/v1 once every day. 这是一种尽力而为的上传操作,不会影响群集功能。It is a best-effort upload and has no impact on the cluster functionality. 遥测数据只会从运行主要故障转移管理器的节点发送。The telemetry is only sent from the node that runs the failover manager primary. 其他节点都不会发送遥测数据。No other nodes send out telemetry.
  2. 遥测数据由以下内容组成:The telemetry consists of the following:
  • 服务数目Number of services
  • ServiceTypes 数目Number of ServiceTypes
  • Applications 数目Number of Applications
  • ApplicationUpgrades 数目Number of ApplicationUpgrades
  • FailoverUnits 数目Number of FailoverUnits
  • InBuildFailoverUnits 数目Number of InBuildFailoverUnits
  • UnhealthyFailoverUnits 数目Number of UnhealthyFailoverUnits
  • Replicas 数目Number of Replicas
  • InBuildReplicas 数目Number of InBuildReplicas
  • StandByReplicas 数目Number of StandByReplicas
  • OfflineReplicas 数目Number of OfflineReplicas
  • CommonQueueLengthCommonQueueLength
  • QueryQueueLengthQueryQueueLength
  • FailoverUnitQueueLengthFailoverUnitQueueLength
  • CommitQueueLengthCommitQueueLength
  • Nodes 数目Number of Nodes
  • IsContextComplete:True/FalseIsContextComplete: True/False
  • ClusterId:这是为每个群集随机生成的 GUIDClusterId: This is a GUID randomly generated for each cluster
  • ServiceFabricVersionServiceFabricVersion
  • 从其上传遥测数据的虚拟机或计算机的 IP 地址IP address of the virtual machine or machine from which the telemetry is uploaded

若要禁用遥测,请将以下内容添加到群集配置中的 属性enableTelemetry: falseTo disable telemetry, add the following to properties in your cluster config: enableTelemetry: false.

此包中包括的预览功能Preview features included in this package



适用于 Windows Server 的独立群集的新 GA 版本(版本 5.3.204.x)开始,可以将群集手动或自动升级到未来版本。Starting with the new GA version of the standalone cluster for Windows Server (version 5.3.204.x), you can upgrade your cluster to future releases, manually or automatically. 请参阅升级独立 Service Fabric 群集版本文档以获取详细信息。Refer to Upgrade a standalone Service Fabric cluster version document for details.

后续步骤Next steps