【问题标题】:Mapping Azure Service Fabric services to a certain node type将 Azure Service Fabric 服务映射到特定节点类型
【发布时间】:2016-08-12 02:16:26
【问题描述】:

在 Service Fabric 应用程序 VS 模板中创建服务(或在 Reliable Actors 的情况下的 Actor)非常容易。在 Azure 门户中定义节点类型也很容易。但是如何映射服务/参与者以在特定节点类型上运行?

【问题讨论】:

    标签: azure azure-service-fabric


    【解决方案1】:

    您可以使用放置约束来做到这一点。

    更多信息可以在this文章的“放置约束和节点属性”部分找到。

    简而言之,您需要在集群上设置放置属性,然后使用StatefulServiceDescription.PlacementConstraints 在服务上设置放置约束。

    【讨论】:

      【解决方案2】:

      这是在 ApplicationManifest.xml 中的声明方式:

      <ServiceTypes>
        <StatelessServiceType ServiceTypeName="Stateless1">
          <PlacementConstraints>(NodeTypeName==BackEnd)</PlacementConstraints>
        </StatelessServiceType>
      </ServiceTypes>
      

      并且可以通过参数在不同的环境下使用不同的约束:

      <Service Name="Stateless1">
        <StatelessService ServiceTypeName="Stateless1Type" InstanceCount="[Stateless1_InstanceCount]">
          <SingletonPartition />
          <PlacementConstraints>[Stateless1_PlacementConstraints]</PlacementConstraints>
        </StatelessService>
      </Service>
      

      Stateless1_PlacementConstraints 可以在应用程序参数文件(Cloud.xml、Local5Node.xml 等)中重新定义。

      更多详情: https://brentdacodemonkey.wordpress.com/2016/09/11/placement-constraints-with-service-fabric/

      【讨论】:

      • 使用(NodeType==...) 代替(NodeTypeName==...)。否则,这对我很有用。如果使用 PowerShell New-ServiceFabricService commandlet 实例化服务,则有一个 -PlacementConstraint 参数供您使用。
      • 我发现在这种情况下使用 (IsBackendNode==...) 之类的约束更方便,我可以轻松地使用一种节点类型(用于测试等)配置集群,并且仍然满足放置约束,而在 (NodeType==...) 的情况下,您总是需要预先配置的节点类型数量。
      猜你喜欢
      • 1970-01-01
      • 2018-09-18
      • 2016-09-28
      • 2020-04-06
      • 1970-01-01
      • 2017-06-09
      • 2013-01-02
      • 2017-05-14
      • 2020-01-23
      相关资源
      最近更新 更多