准備好要充當節點的計算機
下面是要添加到群集的每台計算機的建議規格:
至少 16 GB RAM
至少 40 GB 可用磁盤空間
4 核或更高規格的 CPU
所有計算機與安全網絡連接
Windows Server 2012 R2 或 Windows Server 2016
.NET Framework 4.5.1 或更高版本的完整安裝版
Windows PowerShell 3.0
應在所有計算機上運行 RemoteRegistry 服務
部署和配置群集的群集管理員必須擁有每台計算機的管理員權限。 不能在域控制器上安裝 Service Fabric。
下載適用於 Windows Server 的 Service Fabric 獨立包
下載鏈接 - Service Fabric 獨立包 - Windows Server,並將包解壓縮到群集外的一台部署計算機中或解壓縮到群集內的其中一台計算機中。
修改群集配置
若要創建一個獨立群集,則必須創建一個獨立群集配置 ClusterConfig.json 文件,並在其中說明該群集的規范。 可根據以下鏈接中的模板創建配置文件。
獨立群集配置
從已下載的程序包中打開某個 ClusterConfig.json 文件,並修改以下設置:
| 配置設置 | 說明 |
|---|---|
| NodeTypes | 節點類型可讓你將群集節點划分到不同的組中。 一個群集必須至少有一個節點類型。組中的所有節點具有以下共同特征:名稱-即節點類型名稱。終結點端口 - 即與此節點類型關聯的各種命名終結點(端口)。 可以使用任何端口號,只要它們不會與此清單中的其他部分發生沖突,並且未被計算機/VM上運行的其他應用程序使用。放置屬性-即此節點類型的相應屬性,可用作系統服務或你的服務的放置約束。這些屬性是用戶定義的鍵/值對,可為指定節點提供額外的元數據。節點屬性的示例包括節點是否有硬盤或圖形卡、其硬盤的軸數、內核數和其他物理屬性。容量-節點容量,定義特定節點提供的特定資源的名稱和數量。例如,節點可以定義名為“MemoryInMb”的指標容量,而且默認有 2048 MB的可用內存。這些容量在運行時使用,以確保將需要特定資源量的服務放在具有所需數量的可用資源的節點上。IsPrimary-如果定義了多個NodeType,請確保只有一個設置為主節點(值為true),系統服務會在該主節點上運行。 應將所有其他節點類型設置為 false 值 |
| Nodes | 這些是群集內的每個節點的詳細信息(節點類型、節點名稱、IP 地址、節點的容錯域和升級域)。 要在其上創建群集的計算機必須與其 IP 地址一起列在此處。如果對所有節點使用相同的 IP 地址,則會創建一個可用於測試的單機群集。 不要將單機群集用於部署生產工作負荷。 |
群集配置將所有設置配置到環境后,可針對群集環境對其進行測試(步驟 7)。
環境設置
群集管理員配置 Service Fabric 獨立群集時,需按照以下准則設置環境:
- 對於群集配置文件中列出的所有計算機,創建群集的用戶應對它們具有管理員級別的安全特權。
- 從中創建群集的計算機和每個群集節點計算機必須:
- 已卸載 Service Fabric SDK
- 已卸載 Service Fabric 運行時
- 已啟用 Windows 防火牆服務 (mpssvc)
- 已啟用遠程注冊表服務 (remoteregistry)
- 已啟用文件共享 (SMB)
- 已基於群集配置端口打開所需的端口
- 已打開 Windows SMB和遠程注冊表服務所需的端口:135、137、138、139 和 445
- 已相互建立網絡連接
- 所有群集節點計算機均不是域控制器。
- 如果要部署的群集是安全群集,需確保存在所需的安全先決條件,且已針對配置進行了正確配置。
- 如果群集計算機無法訪問 Internet,請在群集配置中進行以下設置:
- 禁用遙測:在“屬性”下,設置 “enableTelemetry”: false
- 禁用自動下載Fabric版本和禁用通知當前群集版本支持即將終止:在“屬性”下,設置”fabricClusterAutoupgradeEnabled”: false
- 或者,如果網絡Internet訪問僅限於白名單中的域,則需要自動升級以下域:o.microsoft.com download.microsoft.com
- 設置適當的 Service Fabric 防病毒排除項:
防病毒排除的目錄
Program Files\Microsoft Service Fabric
FabricDataRoot(從群集配置中)
FabricLogRoot(從群集配置中)
防病毒排除的進程
Fabric.exe
FabricHost.exe
FabricInstallerService.exe
FabricSetup.exe
FabricDeployer.exe
ImageBuilder.exe
FabricGateway.exe
FabricDCA.exe
FabricFAS.exe
FabricUOS.exe
FabricRM.exe
FileStoreService.exe
使用 TestConfiguration 腳本驗證環境
TestConfiguration.ps1 腳本位於獨立包中。 該腳本可用作最佳做法分析器,驗證上述部分標准,並應用作健全性檢查,驗證是否可在給定環境中部署群集。 如果出現任何故障,請參閱環境設置下的列表進行故障排除。
可以在對群集配置文件中列為節點的所有計算機具有管理員訪問權限的任何計算機上運行此腳本。 運行此腳本的計算機不一定是群集的一部分。
PS C:\temp\Microsoft.Azure.ServiceFabric.WindowsServer> .\TestConfiguration.ps1 -ClusterConfigFilePath .\ClusterConfig.Unsecure.DevCluster.json
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
目前,此配置測試模塊不會驗證安全配置,因此必須單獨執行驗證。
創建群集
.\CreateServiceFabricCluster.ps1 -ClusterConfigFilePath .\ClusterConfig.Unsecure.DevCluster.json -AcceptEULA
實際操作:
PS C:\Users\Administrator> cd 'C:\Microsoft.Azure.ServiceFabric'
PS C:\Microsoft.Azure.ServiceFabric> .\CreateServiceFabricCluster.ps1 -ClusterConfigFilePath .\ClusterConfig.Unsecure.MultiMachine.json -AcceptEULA
Trace folder already exists. Traces will be written to existing trace folder: C:\Microsoft.Azure.ServiceFabric\DeploymentTraces
Runtime package version 6.0.232.9494 was not found in DeploymentRuntimePackages folder and needed to be downloaded.
Runtime package has been successfully downloaded to C:\Microsoft.Azure.ServiceFabric\DeploymentRuntimePackages\MicrosoftAzureServiceFabric.6.0.232.9494.cab.
Creating Service Fabric Cluster...
If it's taking too long, please check in Task Manager details and see if Fabric.exe for each node is running. If not, please look at: 1. traces in DeploymentTraces directory and 2. traces in FabricLogRoot
configured in ClusterConfig.json.
Trace folder already exists. Traces will be written to existing trace folder: C:\Microsoft.Azure.ServiceFabric\DeploymentTraces
Running Best Practices Analyzer...
Best Practices Analyzer completed successfully.
Creating Service Fabric Cluster...
Processing and validating cluster config.
Configuring nodes.
Default installation directory chosen based on system drive of machine '10.0.0.217'.
Copying installer to all machines.
Configuring machine '10.0.0.217'.
Configuring machine '10.0.0.219'.
Configuring machine '10.0.0.216'.
Machine 10.0.0.219 configured.
Machine 10.0.0.217 configured.
Machine 10.0.0.216 configured.
Running Fabric service installation.
Successfully started FabricInstallerSvc on machine 10.0.0.219
Successfully started FabricInstallerSvc on machine 10.0.0.217
Successfully started FabricInstallerSvc on machine 10.0.0.216
Successfully started FabricHostSvc on machine 10.0.0.216
Successfully started FabricHostSvc on machine 10.0.0.219
Successfully started FabricHostSvc on machine 10.0.0.217
Your cluster is successfully created! You can connect and manage your cluster using Microsoft Azure Service Fabric Explorer or Powershell. To connect through Powershell, run 'Connect-ServiceFabricCluster [
ClusterConnectionEndpoint]'.
Runtime package version 6.0.232.9494 was not found in DeploymentRuntimePackages folder and needed to be downloaded.
Runtime package has been successfully downloaded to C:\Microsoft.Azure.ServiceFabric\DeploymentRuntimePackages\MicrosoftAzureServiceFabric.6.0.232.9494.cab.
PS C:\Microsoft.Azure.ServiceFabric>
- 在創建群集時自動下載和安裝 Service Fabric 運行時包。
- 一台部署安裝部署,會自動部署至其他節點
連接至群集
Connect-ServiceFabricCluster -ConnectionEndpoint localhost:19000
使用 Service Fabric Explorer 可視化群集
Service Fabric Explorer是一項很好的工具,適用於可視化群集和管理應用程序。 Service Fabric Explorer 是一項在群集中運行的服務,使用瀏覽器導航到 http://localhost:19080/Explorer 即可訪問該服務。
