如何为附加节点类型配置本地群集

时间:2016-06-17 12:19:17

标签: azure-service-fabric

我有一个群集配置,其中包含ServiceManifest.xml中指定的两种节点类型

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="MKopa.M2M.ConfigurationPkg"
                 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 RegisterServiceType call in Program.cs. -->
    <StatelessServiceType ServiceTypeName="ConfigurationType">
      <PlacementConstraints>(NodeType == Internal)</PlacementConstraints>
    </StatelessServiceType> 
  </ServiceTypes>

  <!-- Code package is your service executable. -->
  <CodePackage Name="Code" Version="1.0.0">
    <EntryPoint>
      <ExeHost>
        <Program>MKopa.M2M.Configuration.Service.exe</Program>
      </ExeHost>
    </EntryPoint>
  </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" />
      <Endpoint Name="HttpEndpoint" Protocol="http" Port="8081"/>
    </Endpoints>
  </Resources>
</ServiceManifest>

我的问题是,这导致部署到本地群集失败,因为此NodeType不存在于本地群集中。

我已经看到了cluster.xml文件的提及,我发现了它,但对其进行更改似乎没有任何效果。我已尝试重置,启动和停止,但重置会覆盖更改。

这里希望答案不是动态启动服务: - )

1 个答案:

答案 0 :(得分:7)

我不知道群集运行时它是如何工作的,但我能够通过重新安装本地群集来实现。这些是我的步骤:

  • 转到C:\Program Files\Microsoft SDKs\Service Fabric\ClusterSetup\
  • 通过调用.\CleanCluster.ps1
  • 卸载现有群集
  • 创建文件C:\Program Files\Microsoft SDKs\Service Fabric\ClusterSetup\NonSecure\ClusterManifestTemplate.xml
  • 的备份
  • 现在,您可以调整此文件并向每个节点添加展示位置属性:
<NodeType ...>
  <Endpoints>...</Endpoints>
  <PlacementProperties>
    <Property Name="NodeType" Value="Internal" />
  </PlacementProperties>
</NodeType>
  • 通过调用.\DevClusterSetup.ps1
  • 重新创建群集