Apache Ignite区域(机架)意识型态

问题描述 投票:0回答:1

我正在努力配置Apache Ignite以区域感知方式分配分区。我有Ignite 2.8.0,其中4个节点作为GKE 1.14中的StatefulSet容器运行,分为两个区域。我关注了the guidethe example

  • 将区域名称传播到AVAILABILITY_ZONE env var下的pod中。
  • 然后使用Web控制台,我验证了是否为每个节点正确加载了该环境变量。
  • 我按如下所示在节点XML配置中设置了缓存模板,并使用GET /ignite?cmd=getorcreate&cacheName=zone-aware-cache&templateName=zone-aware-cache从中创建了一个缓存(我在UI中看不到finityBackupFilter设置,但是应用了模板中的其他参数,因此我认为它可以正常工作)

为了简化分区分布的验证,我将分区号设置为2。创建缓存后,观察到以下分区分布:

enter image description here

然后,我将节点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个的主/备份位于同一区域中。

这是我的节点配置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>
ignite
1个回答
0
投票

我认为您需要传播AVAILABILITY_ZONE作为群集节点属性,例如:

<property name="userAttributes">
    <map>
        <entry key="AVAILABILITY_ZONE" value="#{systemProperties['AVAILABILITY_ZONE']}"/>
    </map>
</property>
© www.soinside.com 2019 - 2024. All rights reserved.