Apache Ignite 区域(机架)感知分区
Apache Ignite zone(rack)-aware parititons
我正在努力配置 Apache Ignite 以区域感知方式分配分区。我在 GKE 1.14 中将 Ignite 2.8.0 与 4 个节点 运行 作为 StatefulSet pods 分成两个区域。我关注了 the guide, and the example:
- 将区域名称传播到 AVAILABILITY_ZONE env var 下的 pod 中。
- 然后使用 Web 控制台我验证了每个节点都正确加载了这个环境变量。
- 我在节点 XML 配置中设置缓存模板,如下所示,并使用
GET /ignite?cmd=getorcreate&cacheName=zone-aware-cache&templateName=zone-aware-cache
从中创建缓存(我在 UI 中看不到 affinityBackupFilter 设置,但其他应用了模板中的参数,所以我认为它有效)
为了简化分区分布的验证,我将分区号设置为 2。创建缓存后,我观察到以下分区分布:
然后我将节点 ID 映射到 AVAILABILITY_ZONE env var 中的值,如节点报告的那样,结果如下:
AA146954 us-central1-a
3943ECC8 us-central1-c
F7B7AB67 us-central1-a
A94EE82C us-central1-c
可以很容易地看到,分区 0 pri/bak 驻留在节点 3943ECC8 和 A94EE82C 上,它们都在同一区域。我缺少什么才能让它发挥作用?
另一件奇怪的事情是,然后将分区号指定为低(例如 2 或 4),仅使用 4 个节点中的 3 个)。当使用 1024 个分区时,所有节点都被利用,但问题仍然存在 - 1024 个分区中的 346 个 primary/backup 位于同一区域。
这是我的节点配置 XML:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<!-- Enabling Apache Ignite Persistent Store. -->
<property name="dataStorageConfiguration">
<bean class="org.apache.ignite.configuration.DataStorageConfiguration">
<property name="defaultDataRegionConfiguration">
<bean class="org.apache.ignite.configuration.DataRegionConfiguration">
<property name="persistenceEnabled" value="true"/>
</bean>
</property>
</bean>
</property>
<!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<!-- Enables Kubernetes IP finder and setting custom namespace and service names. -->
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder">
<property name="namespace" value="ignite"/>
</bean>
</property>
</bean>
</property>
<property name="cacheConfiguration">
<list>
<bean id="zone-aware-cache-template" abstract="true" class="org.apache.ignite.configuration.CacheConfiguration">
<!-- when you create a template via XML configuration, you must add an asterisk to the name of the template -->
<property name="name" value="zone-aware-cache*"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="atomicityMode" value="ATOMIC"/>
<property name="backups" value="1"/>
<property name="readFromBackup" value="true"/>
<property name="partitionLossPolicy" value="READ_WRITE_SAFE"/>
<property name="copyOnRead" value="true"/>
<property name="eagerTtl" value="true"/>
<property name="statisticsEnabled" value="true"/>
<property name="affinity">
<bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
<property name="partitions" value="2"/> <!-- for debugging only! -->
<property name="excludeNeighbors" value="true"/>
<property name="affinityBackupFilter">
<bean class="org.apache.ignite.cache.affinity.rendezvous.ClusterNodeAttributeAffinityBackupFilter">
<constructor-arg>
<array value-type="java.lang.String">
<!-- Backups must go to different AZs -->
<value>AVAILABILITY_ZONE</value>
</array>
</constructor-arg>
</bean>
</property>
</bean>
</property>
</bean>
</list>
</property>
</bean>
</beans>
更新: 最终 excludeNeighbors
false/true 建立或破坏区域意识。我不确定为什么以前对我来说它不能与 excludeNeighbors=false
一起使用。我制作了一些脚本来自动化我的测试。现在可以确定是 excludeNeighbors
设置了。都在这里:https://github.com/doitintl/ignite-gke. Regardless I also opened a bug with IGNITE Jira: https://issues.apache.org/jira/browse/IGNITE-12896。非常感谢@alamar 的建议。
我建议将 excludeNeighbors
设置为 false
。它是 true
在你的情况下,它不是必需的,当我将它设置为 false
时我得到了正确的分区映射(当然,我也在本地 运行 所有四个节点)。
环境属性就够了,不需要手动添加到用户属性。
我正在努力配置 Apache Ignite 以区域感知方式分配分区。我在 GKE 1.14 中将 Ignite 2.8.0 与 4 个节点 运行 作为 StatefulSet pods 分成两个区域。我关注了 the guide, and the example:
- 将区域名称传播到 AVAILABILITY_ZONE env var 下的 pod 中。
- 然后使用 Web 控制台我验证了每个节点都正确加载了这个环境变量。
- 我在节点 XML 配置中设置缓存模板,如下所示,并使用
GET /ignite?cmd=getorcreate&cacheName=zone-aware-cache&templateName=zone-aware-cache
从中创建缓存(我在 UI 中看不到 affinityBackupFilter 设置,但其他应用了模板中的参数,所以我认为它有效)
为了简化分区分布的验证,我将分区号设置为 2。创建缓存后,我观察到以下分区分布:
然后我将节点 ID 映射到 AVAILABILITY_ZONE env var 中的值,如节点报告的那样,结果如下:
AA146954 us-central1-a
3943ECC8 us-central1-c
F7B7AB67 us-central1-a
A94EE82C us-central1-c
可以很容易地看到,分区 0 pri/bak 驻留在节点 3943ECC8 和 A94EE82C 上,它们都在同一区域。我缺少什么才能让它发挥作用?
另一件奇怪的事情是,然后将分区号指定为低(例如 2 或 4),仅使用 4 个节点中的 3 个)。当使用 1024 个分区时,所有节点都被利用,但问题仍然存在 - 1024 个分区中的 346 个 primary/backup 位于同一区域。
这是我的节点配置 XML:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<!-- Enabling Apache Ignite Persistent Store. -->
<property name="dataStorageConfiguration">
<bean class="org.apache.ignite.configuration.DataStorageConfiguration">
<property name="defaultDataRegionConfiguration">
<bean class="org.apache.ignite.configuration.DataRegionConfiguration">
<property name="persistenceEnabled" value="true"/>
</bean>
</property>
</bean>
</property>
<!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<!-- Enables Kubernetes IP finder and setting custom namespace and service names. -->
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.kubernetes.TcpDiscoveryKubernetesIpFinder">
<property name="namespace" value="ignite"/>
</bean>
</property>
</bean>
</property>
<property name="cacheConfiguration">
<list>
<bean id="zone-aware-cache-template" abstract="true" class="org.apache.ignite.configuration.CacheConfiguration">
<!-- when you create a template via XML configuration, you must add an asterisk to the name of the template -->
<property name="name" value="zone-aware-cache*"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="atomicityMode" value="ATOMIC"/>
<property name="backups" value="1"/>
<property name="readFromBackup" value="true"/>
<property name="partitionLossPolicy" value="READ_WRITE_SAFE"/>
<property name="copyOnRead" value="true"/>
<property name="eagerTtl" value="true"/>
<property name="statisticsEnabled" value="true"/>
<property name="affinity">
<bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
<property name="partitions" value="2"/> <!-- for debugging only! -->
<property name="excludeNeighbors" value="true"/>
<property name="affinityBackupFilter">
<bean class="org.apache.ignite.cache.affinity.rendezvous.ClusterNodeAttributeAffinityBackupFilter">
<constructor-arg>
<array value-type="java.lang.String">
<!-- Backups must go to different AZs -->
<value>AVAILABILITY_ZONE</value>
</array>
</constructor-arg>
</bean>
</property>
</bean>
</property>
</bean>
</list>
</property>
</bean>
</beans>
更新: 最终 excludeNeighbors
false/true 建立或破坏区域意识。我不确定为什么以前对我来说它不能与 excludeNeighbors=false
一起使用。我制作了一些脚本来自动化我的测试。现在可以确定是 excludeNeighbors
设置了。都在这里:https://github.com/doitintl/ignite-gke. Regardless I also opened a bug with IGNITE Jira: https://issues.apache.org/jira/browse/IGNITE-12896。非常感谢@alamar 的建议。
我建议将 excludeNeighbors
设置为 false
。它是 true
在你的情况下,它不是必需的,当我将它设置为 false
时我得到了正确的分区映射(当然,我也在本地 运行 所有四个节点)。
环境属性就够了,不需要手动添加到用户属性。