【问题标题】:Service Fabric Explorer Health State UnknownService Fabric Explorer 运行状况未知
【发布时间】:2019-09-23 19:13:04
【问题描述】:

我分区中的节点不断在 Health State = OK 和 Health State = unknown 之间切换。 有时节点会消失。

我尝试删除服务、应用程序并取消配置类型,然后重新部署,但我遇到了同样的问题。

这是一个 Service Fabric 有状态服务,它在本地运行良好,我遇到的问题只是在我的开发环境中。

我正在使用 5 个节点。

ServiceManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="Integration.Optical.ServicePkg"
                 Version="1.0.0"
                 xmlns="http://schemas.microsoft.com/2011/01/fabric"
                 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ServiceTypes>
    <!-- This is the name of your ServiceType. 
         This name must match the string used in the RegisterServiceAsync call in Program.cs. -->
    <StatefulServiceType ServiceTypeName="Integration.Optical.ServiceType" />
  </ServiceTypes>

  <!-- Code package is your service executable. -->
  <CodePackage Name="Code" Version="1.0.0">
    <EntryPoint>
      <ExeHost>
        <Program>Integration.Optical.Service.exe</Program>
        <WorkingFolder>CodePackage</WorkingFolder>
      </ExeHost>
    </EntryPoint>
    <EnvironmentVariables>
      <EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value=""/>
      <EnvironmentVariable Name="KEYVAULT_ENDPOINT" Value=""/>
    </EnvironmentVariables>
  </CodePackage>

  <!-- Config package is the contents of the Config directoy under PackageRoot that contains an 
       independently-updateable and versioned set of custom configuration settings for your service. -->
  <ConfigPackage Name="Config" Version="1.0.0" />

  <Resources>
    <Endpoints>
      <!-- This endpoint is used by the communication listener to obtain the port on which to 
           listen. Please note that if your service is partitioned, this port is shared with 
           replicas of different partitions that are placed in your code. -->
      <Endpoint Name="ServiceEndpoint" />

      <!-- This endpoint is used by the replicator for replicating the state of your service.
           This endpoint is configured through a ReplicatorSettings config section in the Settings.xml
           file under the ConfigPackage. -->
      <Endpoint Name="ReplicatorEndpoint" />
    </Endpoints>
  </Resources>
</ServiceManifest>

ApplicationManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="Integration.OpticalType" ApplicationTypeVersion="1.0.0" xmlns="http://schemas.microsoft.com/2011/01/fabric">
  <Parameters>
    <Parameter Name="Integration.Optical.Service_ASPNETCORE_ENVIRONMENT" DefaultValue="" />
    <Parameter Name="Integration.Optical.Service_KEYVAULT_ENDPOINT" DefaultValue="" />
    <Parameter Name="Integration.Optical.Service_MinReplicaSetSize" DefaultValue="3" />
    <Parameter Name="Integration.Optical.Service_PartitionCount" DefaultValue="1" />
    <Parameter Name="Integration.Optical.Service_TargetReplicaSetSize" DefaultValue="3" />
  </Parameters>
  <!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion 
       should match the Name and Version attributes of the ServiceManifest element defined in the 
       ServiceManifest.xml file. -->
  <ServiceManifestImport>
    <ServiceManifestRef ServiceManifestName="Integration.Optical.ServicePkg" ServiceManifestVersion="1.0.0" />
    <ConfigOverrides />
    <EnvironmentOverrides CodePackageRef="code">
      <EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="[Integration.Optical.Service_ASPNETCORE_ENVIRONMENT]" />
      <EnvironmentVariable Name="KEYVAULT_ENDPOINT" Value="[Integration.Optical.Service_KEYVAULT_ENDPOINT]" />
    </EnvironmentOverrides>
  </ServiceManifestImport>
  <DefaultServices>
    <!-- The section below creates instances of service types, when an instance of this 
         application type is created. You can also create one or more instances of service type using the 
         ServiceFabric PowerShell module.

         The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. -->
    <Service Name="Integration.Optical.Service" ServicePackageActivationMode="ExclusiveProcess">
      <StatefulService ServiceTypeName="Integration.Optical.ServiceType" TargetReplicaSetSize="[Integration.Optical.Service_TargetReplicaSetSize]" MinReplicaSetSize="[Integration.Optical.Service_MinReplicaSetSize]">
        <UniformInt64Partition PartitionCount="[Integration.Optical.Service_PartitionCount]" LowKey="-9223372036854775808" HighKey="9223372036854775807" />
      </StatefulService>
    </Service>
  </DefaultServices>
</ApplicationManifest>

ApplicationParameters/Cloud.xml:

<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="fabric:/Integration.Optical" xmlns="http://schemas.microsoft.com/2011/01/fabric">
  <Parameters>
    <Parameter Name="Integration.Optical.Service_ASPNETCORE_ENVIRONMENT" Value="" />
    <Parameter Name="Integration.Optical.Service_KEYVAULT_ENDPOINT" Value="" />
    <Parameter Name="Integration.Optical.Service_PartitionCount" Value="1" />
    <Parameter Name="Integration.Optical.Service_MinReplicaSetSize" Value="1" />
    <Parameter Name="Integration.Optical.Service_TargetReplicaSetSize" Value="1" />
  </Parameters>
</Application>

【问题讨论】:

  • 我希望该端口不会被任何其他进程使用。请确保。
  • 可以分享一下应用于测试环境的参数吗?测试环境的一般描述(即多少个节点)?来自ServiceManifest.xml的服务配置?
  • @OlegKarasik 我已经更新了我的问题。
  • 嗯。您可以检查节点和服务上的 Event 选项卡吗?问题可能是由于以下原因无法启动您的服务可执行文件:缺少程序集/依赖项或框架版本错误。

标签: azure-service-fabric .net-core-2.2


【解决方案1】:

不确定这部分修复了它。但这就是我所做的,现在它正在工作:

在 ServiceManifest.xml 我添加了HasPersistedState = true:

<StatefulServiceType ServiceTypeName="Integration.Optical.ServiceType" HasPersistedState="true" />

我移动了应用配置代码

ServiceRuntime.RegisterServiceAsync...

Service.RunAsync()Program.Main()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-24
    • 2020-04-29
    • 2019-07-06
    • 2016-09-28
    • 2018-03-07
    • 2019-04-17
    • 2016-11-16
    • 2021-02-01
    相关资源
    最近更新 更多