如何为其他节点类型配置本地集群

How do I configure local cluster for addtional node types

我有一个集群配置,在 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 文件,我也找到了它,但对其进行更改似乎没有任何效果。我已尝试重置、启动和停止,但重置会覆盖更改。

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

我不知道集群处于 运行 时它是如何工作的,但我可以通过重新安装本地集群来做到这一点。这些是我的步骤:

  • 转到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
  • 重新创建集群