繁体   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