簡體   English   中英

如何使用PowerShell或CLI啟動本地Azure Service Fabric Cluster

[英]How to start local Azure Service Fabric Cluster with PowerShell or CLI

我正在使用Azure Service Fabric進行開發,並且有幾次Service Fabric因某些原因(通常在重新啟動后)未啟動。 系統托盤中的Service Fabric Manager響應時間非常長(如果響應的話)。

是否有PowerShell cmdlet甚至cli命令可用於啟動本地Service Fabric?

您可以只使用Start-Service cmdlet

PS C:\windows\system32> Start-Service FabricHostSvc
WARNING: Waiting for service 'Microsoft Service Fabric Host Service (FabricHostSvc)' to start...

您還可以通過運行Get-Service來檢查主機是否正在運行

PS C:\windows\system32> Get-Service FabrichostSvc

Status   Name               DisplayName
------   ----               -----------
Running  FabrichostSvc      Microsoft Service Fabric Host Service

如果它正在運行,您也可以使用Restart-Service

PS C:\windows\system32> Restart-Service FabrichostSvc
WARNING: Waiting for service 'Microsoft Service Fabric Host Service (FabrichostSvc)' to start...
WARNING: Waiting for service 'Microsoft Service Fabric Host Service     (FabrichostSvc)' to start...

我有一個類似的問題,最后使用SDK提供的實用程序函數,我在這里找到:

C:\\ Program Files \\ Microsoft SDKs \\ Service Fabric \\ Tools \\ Scripts \\ ClusterSetupUtilities.psm1

在我的powershell腳本中,我使用以下命令導入實用程序函數:

# Import the cluster setup utility module
$sdkInstallPath = (Get-ItemProperty 'HKLM:\Software\Microsoft\Service Fabric SDK').FabricSDKScriptsPath
$modulePath = Join-Path -Path $sdkInstallPath -ChildPath "ClusterSetupUtilities.psm1"
Import-Module $modulePath

然后我有以下內容來檢查群集是否正在運行,如果不是,則啟動它:

# Start the local cluster if needed
if (-not (IsLocalClusterRunning))
{
    StartLocalCluster
}

在封面下,它基本上與Kevin在答案中所做的一樣( Start-Service FabricHostSvc )。 因此,如果您要設置PowerShell腳本,這可能會有所幫助,但如果您只是想在PowerShell中運行命令,則導入實用程序可能會很麻煩。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM