如何使用PowerShell或CLI启动本地Azure服务结构群集

如何使用PowerShell或CLI启动本地Azure服务结构群集,powershell,azure,azure-service-fabric,Powershell,Azure,Azure Service Fabric,我是在Azure Service Fabric中开发的,有好几次由于某种原因(通常是在重新启动之后)Service Fabric没有启动。系统托盘中的Service Fabric Manager具有可怕的响应时间(如果它完全响应的话) 是否有PowerShell cmdlet或cli命令可用于启动本地服务结构?您只需使用启动服务cmdlet即可 PS C:\windows\system32> Start-Service FabricHostSvc WARNING: Waiting for

我是在Azure Service Fabric中开发的,有好几次由于某种原因(通常是在重新启动之后)Service Fabric没有启动。系统托盘中的Service Fabric Manager具有可怕的响应时间(如果它完全响应的话)


是否有PowerShell cmdlet或cli命令可用于启动本地服务结构?

您只需使用
启动服务
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
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...
如果它正在运行,您也可以使用
重新启动服务

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

Status   Name               DisplayName
------   ----               -----------
Running  FabrichostSvc      Microsoft Service Fabric Host 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 SDK\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
}

在封面下,它基本上做了凯文在回答中做的事情(
启动服务FabricHostSvc
)。因此,如果您正在设置PowerShell脚本,这可能会有所帮助,但如果您只是想在PowerShell中运行命令,则导入实用程序可能会很麻烦。

我选择此作为答案,因为即使Grace给出的答案有效,这也是根答案。感谢并抱歉占用您这么长时间。Get-Service可以作为非管理员运行。启动服务必须在具有管理员权限的powershell中运行。