【发布时间】:2020-04-06 15:10:35
【问题描述】:
我正在努力将 Apache Ignite 配置为以区域感知方式分配分区。我在 GKE 1.14 中有 4 个节点作为 StatefulSet pod 运行的 Ignite 2.8.0,分为两个区域。我关注了the guide和the example:
- 将区域名称传播到 AVAILABILITY_ZONE 环境变量下的 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
很容易看到,partition 0 pri/bak 位于节点 3943ECC8 和 A94EE82C 上,它们都在同一个区域中。我缺少什么使它起作用?
另一个奇怪的事情是,将分区号指定为低(例如 2 或 4),仅使用 4 个节点中的 3 个)。当使用 1024 个分区时,所有节点都被利用,但问题仍然存在 - 1024 个分区中有 346 个的主/备份位于同一区域。
这是我的节点配置 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。无论如何,我还使用 IGNITE Jira 打开了一个错误:https://issues.apache.org/jira/browse/IGNITE-12896。非常感谢@alamar 的建议。
【问题讨论】:
标签: ignite