【问题标题】:How to start local Azure Service Fabric Cluster with PowerShell or CLI如何使用 PowerShell 或 CLI 启动本地 Azure Service Fabric 集群
【发布时间】:2017-07-19 12:29:47
【问题描述】:

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

是否有可用于启动本地 Service Fabric 的 PowerShell cmdlet 甚至 cli 命令?

【问题讨论】:

    标签: powershell azure azure-service-fabric


    【解决方案1】:

    您可以只使用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...
    

    【讨论】:

    • 我选择这个作为答案,因为即使答案 bygrace 给出了有效的,这是根本答案。感谢和抱歉花了这么长时间。
    • Get-Service 可以以非管理员身份运行。 Start-Service 必须在具有管理员权限的 powershell 中运行。
    【解决方案2】:

    我遇到了类似的问题,最终使用了我在此处找到的 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 中运行命令,则导入实用程序可能会很麻烦。

    【讨论】:

      猜你喜欢
      • 2016-10-23
      • 2016-09-28
      • 2018-12-31
      • 2020-01-11
      • 2019-12-02
      • 2018-10-08
      • 2020-11-26
      • 2017-07-04
      • 2019-03-21
      相关资源
      最近更新 更多