代码之家  ›  专栏  ›  技术社区  ›  Mike Christensen

如何在服务结构群集上查找特定节点

  •  0
  • Mike Christensen  · 技术社区  · 7 年前

    假设我有一个具有5个节点的服务结构集群。在其中一个节点上,我运行一个名为Cache的服务:

    <Service Name="Cache" ServicePackageActivationMode="ExclusiveProcess">
      <StatelessService ServiceTypeName="CacheType" InstanceCount="1">
        <SingletonPartition />
      </StatelessService>
    </Service>
    

    我确实发现 Hostname 属性 <ContainerHostPolicies>

    <ContainerHostPolicies CodePackageRef="Code" Hostname="Cache">

    现在,在码头集装箱里我可以 PING Cache 并连接到运行我的服务的容器。这是伟大的,但是它 只有 如果我恰好在同一个节点上,就可以工作。如果我在节点1上,而我的缓存服务在节点3上运行,这就不起作用了。

    here

    1 回复  |  直到 7 年前
        1
  •  2
  •   Oleg Karasik    7 年前

    您可以为服务设置DNS名称。

    下面是一个来自 docs

    ApplicationManifest.xml .

    <Service Name="Stateless1" ServiceDnsName="service1.application1">
      <StatelessService ServiceTypeName="Stateless1Type" InstanceCount="[Stateless1_InstanceCount]">
        <SingletonPartition />
      </StatelessService>
    </Service>
    

    如果您的服务使用分区模式,那么您应该遵循 this 以确保正确解决这些问题。