假设我有一个具有5个节点的服务结构集群。在其中一个节点上,我运行一个名为Cache的服务:
<Service Name="Cache" ServicePackageActivationMode="ExclusiveProcess"> <StatelessService ServiceTypeName="CacheType" InstanceCount="1"> <SingletonPartition /> </StatelessService> </Service>
我确实发现 Hostname 属性 <ContainerHostPolicies>
Hostname
<ContainerHostPolicies>
<ContainerHostPolicies CodePackageRef="Code" Hostname="Cache">
现在,在码头集装箱里我可以 PING Cache 并连接到运行我的服务的容器。这是伟大的,但是它 只有 如果我恰好在同一个节点上,就可以工作。如果我在节点1上,而我的缓存服务在节点3上运行,这就不起作用了。
PING Cache
here
您可以为服务设置DNS名称。
下面是一个来自 docs
在 ApplicationManifest.xml .
ApplicationManifest.xml
<Service Name="Stateless1" ServiceDnsName="service1.application1"> <StatelessService ServiceTypeName="Stateless1Type" InstanceCount="[Stateless1_InstanceCount]"> <SingletonPartition /> </StatelessService> </Service>
如果您的服务使用分区模式,那么您应该遵循 this 以确保正确解决这些问题。