首页 > 解决方案 > 不支持 geode 客户端服务器版本 - 不支持序数为 100 的对等或客户端版本

问题描述

我有一个托管在 PCF 上的 springboot 应用程序,试图连接到 PCC(关键云缓存)。我已经启动了一个 PCC 实例并将其绑定到我的应用程序并将应用程序推送到云代工厂。我已将所有必需的 gemfire 启动器依赖项添加到 springboot,它似乎能够从 VCAP_SERVICES 读取定位器和服务器信息。但是,我在 spring boot 应用程序启动时看到以下错误。

org.apache.geode.cache.client.internal.ConnectionFactoryImpl.createClientToServerConnection(ConnectionFactoryImpl.java:120) - Could not create a new connection to server: XXX.XXX.XX.XXX(cacheserver-c3a291d1-9664-40d5-b20c-ad8dca8cd19e:1)<v3>:56152(version:GEODE 1.7.0) refused connection: 
Peer or client version with ordinal 100 not supported. Highest known version is 1.7.0 Client: /XXX.XXX.XX.XXX:39192.

at org.apache.geode.internal.cache.tier.sockets.Handshake.readMessage(Handshake.java:330) ~[geode-core-1.9.2.jar!/:?]

我不确定序数在这里意味着什么以及需要更新哪些依赖项。

这是我的Maven依赖项..

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-gemfire</artifactId>
            <version>2.2.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.geode</groupId>
            <artifactId>spring-geode</artifactId>
            <version>1.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>io.pivotal.gemfire</groupId>
            <artifactId>geode-core</artifactId>
            <version>9.8.4</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-geode</artifactId>
            <version>2.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.geode</groupId>
            <artifactId>spring-geode-starter</artifactId>
            <version>1.2.6.RELEASE</version>
        </dependency>

这是我的配置文件..

@Configuration
@ClientCacheApplication(name = "Test", logLevel = "info")
@EnableCachingDefinedRegions(
    clientRegionShortcut = ClientRegionShortcut.PROXY,
    serverRegionShortcut = RegionShortcut.REPLICATE_HEAP_LRU)
@EnableClusterAware
@EnablePdx
public class CloudConfiguration {}

有什么帮助吗?

标签: javagemfiregeodespring-data-gemfirespring-boot-data-geode

解决方案


尽管您自己解决了问题并了解了问题的要点,但我想在这里提供更多细节(对于感兴趣的读者),并提供一些指导。

让我们从头开始:

首先,您的应用程序依赖项,如上面的 Maven POM 所示,非常混乱!

您正在声明对Spring Data GemFire(即org.springframework.data:spring-data-gemfire:2.2.1.RELEASE)以及Spring Data Geode(即org.springframework.data:spring-data-geode:2.2.6.RELEASE,不匹配;SD GemFire 2.2.1 != SD Geode 2.2.6)以及Spring Boot for Apache Geode的直接“版本化”依赖Pivotal GemFire (SBDG) ( org.springframework.geode:spring-geode-starter:1.2.6.RELEASE),然后不必要地拉入 SBDG 的spring-geode(核心)模块,无论如何它都会被传递地拉入spring-geode-starter,以及声明该org.apache.geode:geode-core模块,唷!:)

在这种情况下,您需要声明的唯一依赖项是 SBDG 的 1 个启动器,无论是org.springframework.geode:spring-geode-starter在使用 Apache Geode 或org.springframework.geode:spring-gemfire-starter使用 Pivotal GemFire 时,还是在使用 PCC 将Spring Boot应用程序部署到 PCF 时(在这种情况下,spring-gemfire-starter建议使用该依赖项,不过不是绝对必要的,因为可以混合 GemFire/Geode 对等体并使 Geode 客户端与 GemFire 服务对话,反之亦然)。

启动器拉入Spring Data Geode(或Spring Data GemFire,取决于启动器),它为您拉入 Geode(或 GemFire)位。这首先是 Maven/Gradle 依赖管理的重点,最好尽可能减少应用程序依赖声明,让框架/启动器为你决定传递依赖的版本,特别是如果你不这样做'不在乎。

Spring Boot项目通常会竭尽全力为您管理和协调所有依赖项版本(包括Spring和 3rd 方库/传递依赖项)。您只需要根据您需要的应​​用程序依赖项(例如 Apache Geode 或 Pivotal GemFire)的版本来选择Spring Boot的版本。

我们尝试在这里为您总结:

https://github.com/spring-projects/spring-boot-data-geode/wiki/Spring-Boot-for-Apache-Geode-and-Pivotal-GemFire-Version-Compatibility-Matrix

具体见:

https://github.com/spring-projects/spring-boot-data-geode/wiki/Spring-Boot-for-Apache-Geode-and-Pivotal-GemFire-Version-Compatibility-Matrix#version-compatibility-matrix

为了非常透明,这个版本的兼容性矩阵/表,大致翻译为:

  1. 作为开发人员,我正在使用或选择使用 SBDG 1.2.6.RELEASE
  2. SBDG1.2.6.RELEASE基于Spring Boot 2.2.6.RELEASE
  3. Spring Boot 2.2.6.RELEASE 引入 Spring Data Moore-SR6
  4. Spring Data Moore-SR6 ( this )包括 Spring Data GemFire/Geode 2.2.6.RELEASE
  5. Spring Data Geode (SDG)Moore-SR6/2.2.6.RELEASE基于Apache Geode 1.9.x
  6. Spring Data GemFire (SDG)Moore-SR6/2.2.6.RELEASE基于Pivotal GemFire 9.8.x
  7. Spring Data Geode 包括所需的(由 SDG)和正确的 Apache Geode 位(依赖项)。
  8. Spring Data GemFire 包括所需的(由 SDG 提供)和正确的 Pivotal GemFire 位(依赖项)。

因此,spring-[geode|gemfire]-starter您需要在 PCF 中与 PCC 一起使用哪个版本的 SBDG(即哪个版本)成为问题?

为此,您必须大致了解 GemFire/Geode 客户端只能连接到与客户端相同或更高版本的 GemFire/Geode 服务器并与之通信。较新的客户端无法与较旧的 GemFire/Geode 服务器通信。这不是 Spring 限制,而是 GemFire/Geode 限制本身。造成这种情况的原因有很多,我不会在这里解释(但它大致归结为协议、分布式算法等)。

例如,您可以将 GemFire 9.8 客户端连接到 GemFire 9.8.x 服务器,一切都会好起来的。同样的 GemFire 9.8 客户端也可以连接到 GeFire 9.9.x 和 9.10.x 服务器并与之对话。但是,GemFire 9.8 客户端无法连接或与 GemFire 9.7、9.6、9.5 或更早版本的服务器通信。major.minor补丁或维护版本无关紧要,例如,只要版本匹配,GemFire 9.8.7 客户端应该能够连接并与 GemFire 9.8.4 服务器通信。

所以现在,它基本上归结为,哪个版本的 Pivotal GemFire 是 PCF 中的 PCC 版本,您正在基于哪个版本部署Spring BootData Geode)应用程序?

为此,您需要查看 PCF/PCC 文档。

例如,PCC for PCF(现在称为 VMware Tanzue GemFire for VMs)1.11 版基于 Pivotal GemFire 9.9.1。见这里

1.2.6.RELEASE这意味着您可以使用基于Spring Boot 的SBDG 2.2.6.RELEASE,它引入Spring Data Moore-SR6,其中包括2.2.6.RELEASE基于 Apache Geode 1.9.2/Pivotal GemFire的 SDG 9.8.7。这种组合很好,因为旧客户端(即 GemFire 9.8.7)可以连接到 GemFire 并与之对话9.9.1,这是 PCC/VMware Tanzu GemFire for VMS 的基准1.11

说得通?

如果我们看一下 PCC 1.10,它还是基于Pivotal GemFire 9.9.1。

如果我们查看 PCC 1.9,它基于Pivotal GemFire 9.8.6。同样,我们在这里很好。

如果我们回到 PCC 1.7,我们会看到 PCC 1.7基于Pivotal GemFire 9.7.2。

现在,SBDG1.2.6.RELEASE将无法与 PCC 1.7 一起使用,因为 SBDG1.2.6.RELEASE基于 GemFire 9.8(更新)而 PCC 1.7 基于 GemFire 9.7(旧)。9.8 客户端无法连接到 9.7 服务器并与之对话,因此,我们必须将 SBDGmajor.minor版本返回到 SBDG 1.1.x,其中 SBDG1.1.x基于Spring Boot 2.1,它引入Spring Data ,其中包括基于 Apache Geode 的Lovelace/2.1SDG和分别是关键的 GemFire 。2.1.x1.69.5

注意:虽然 SDG 与较新的、非“基线”版本的 GemFire/Geode“兼容”,但我们不“支持”这种组合。例如,SDG Lovelace/2.1 仅“基于”GemFire 9.5/Geode 1.6,但“兼容”GemFire 9.6/9.7 和 Geode 1.7/1.8。如果您从 GemFire 9.7 迁移到,例如 9.8 和 Geode 1.8 到 1.9,那么当然,您应该迁移到 SDG Moore/2.2,因为它“基于”GemFire 9.8/Geode 1.9。兼容性!=支持。无论如何,这就是说,您可以升级您的客户端驱动程序版本(即 GemFire/Geode 客户端版本,如果需要)。有关更多详细信息,请参见此处。此 Wiki 页面是 WIP。

云缓存开发者网站还包含帮助您入门的详细信息。

最后,我还在 SBDG 项目本身中构建了这个入门示例(带有指南源代码),它可以让您从start.spring.io开始快速启动和运行。

现在,关于您的配置...

@Configuration
@ClientCacheApplication(name = "Test", logLevel = "info")
@EnableCachingDefinedRegions(
    clientRegionShortcut = ClientRegionShortcut.PROXY,
    serverRegionShortcut = RegionShortcut.REPLICATE_HEAP_LRU)
@EnableClusterAware
@EnablePdx
public class CloudConfiguration {}

这可以简化为:

@Configuration
@EnableCachingDefinedRegions(
  serverRegionShortcut = RegionShortcut.REPLICATE_HEAP_LRU
)
@EnableClusterAware
public class CloudConfiguration {}

SBDG 默认为您“自动配置”一个ClientCache实例。见这里

实际上,在显式声明注释时应该小心,因为那时您正在覆盖自动配置(即,您通过应用显式“配置”来覆盖“约定” ,它告诉引导您知道自己在做什么;使确实是这样!)请参见此处此处以及此处此处

许多注释属性(例如ClientCacheApplication.nameClientCacheApplication.logLevel)可以在Spring Boot applications.properties文件中表示为 SDG 属性,从而使配置更加“可配置”。

例如:

# Spring Boot application.properties.
spring.data.gemfire.name=Test
spring.data.gmefire.cache.log-level=INFO

有关更多详细信息,请参见此处此处

您也不需要显式启用 PDX,因为 SBDG 会再次为您自动配置PDX。见这里

默认ClientRegionShortcut值为 PROXY,但我也不介意“明确”地提及它。您只需要在具有自动配置的Spring Boot上下文中小心,因为您可能会“覆盖”自动配置并将正确管理配置的责任放在自己身上。因此,有意地声明配置,而不是盲目地声明。

希望这可以帮助!


推荐阅读