【问题标题】:Apache Ignite zone(rack)-aware parititonsApache Ignite 区域(机架)感知分区
【发布时间】:2020-04-06 15:10:35
【问题描述】:

我正在努力将 Apache Ignite 配置为以区域感知方式分配分区。我在 GKE 1.14 中有 4 个节点作为 StatefulSet pod 运行的 Ignite 2.8.0,分为两个区域。我关注了the guidethe 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


    【解决方案1】:

    我建议将excludeNeighbors 设置为false。在你的情况下是true,它不是必需的,当我将它设置为false 时,我得到了正确的分区映射(当然,我也在本地运行所有四个节点)。

    环境属性就够了,不需要手动添加到用户属性中。

    【讨论】:

    • 我很确定我尝试过使用和不使用excludeNeighbors。我会再次检查,但我不明白它为什么会干扰,除非它是一个错误。
    • 你用了多少个分区?你如何验证正确性?您能否发布用于创建缓存的节点配置 XML 和 REST cmd?
    • 我没有使用 REST,我使用了 SQL。我可以使用 REST 重试。我有 16 个分区,我在视觉上确认了正确性。
    • 最终excludeNeighbors false/true 建立或破坏区域意识。我不确定为什么它以前不适用于excludeNeighbors=false。我制作了一些脚本来自动化我的测试。现在可以确定它是excludeNeighbors 设置。都在这里:github.com/doitintl/ignite-gke。不管怎样,我还用 IGNITE Jira 打开了一个错误:issues.apache.org/jira/browse/IGNITE-12896
    • 是的,但是阅读有关excludeNeighors 的信息,对于非本地开发设置而言,它通常看起来是一个不错的设置。我熟悉其他数据库的类似设置,所以我立即设置它,因为我正在准备类似生产的模板来运行 ignite。不管怎样,我看到你在错误跟踪器中承认了这个问题,所以我想我们可以在这里总结一下。再次感谢您对此提供的帮助。
    猜你喜欢
    • 1970-01-01
    • 2010-10-25
    • 1970-01-01
    • 2013-12-09
    • 1970-01-01
    • 1970-01-01
    • 2021-04-16
    • 2011-12-08
    • 2021-01-11
    相关资源
    最近更新 更多