问题描述
我在PCF上托管了一个springboot应用,试图连接到PCC(关键云缓存).我启动了一个PCC实例,并将其绑定到我的应用程序,并将该应用程序推送到了Cloud Foundry.我已经将所有必需的gemfire启动器依赖项添加到springboot中,似乎能够从VCAP_SERVICES读取定位器和服务器信息.但是,我在春季启动应用启动时看到以下错误.
I've a springboot app hosted on PCF trying to connect to PCC(pivotal cloud cache). I've spinned up a PCC instance and binded it to my app and pushed the app to cloud foundry. I've added all the required gemfire starter dependencies to springboot and it appears like it was able to read the locator and server information from VCAP_SERVICES. But, I see the following error on spring boot app startup.
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!/:?]
我不确定序号在这里是什么意思,还有哪些依赖项需要更新.
I'm not sure what ordinals means here and also what dependencies need to be updated.
这是我的Maven依赖项.
Here are my maven dependencies..
<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 {}
有帮助吗?
推荐答案
尽管您自己解决了问题,并且已经掌握了要点,但我想在此提供更多详细信息(供感兴趣的读者使用),并提供一些指导.
Though you solved your issue yourself and sort of got to the gist of the problem, I wanted to provide a bit more detail here (for interested readers), as well as provide some guidance.
让我们从头开始:
首先,您的应用程序依赖性(如上面的Maven POM所示)非常混乱!
First, your application dependencies, as shown in the Maven POM above, are very confused!
您要声明对 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
)的直接版本化"依赖,而不会match; 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
模块,! :)
You are declaring direct, "versioned" dependencies on Spring Data GemFire (i.e. org.springframework.data:spring-data-gemfire:2.2.1.RELEASE
) along with Spring Data Geode (i.e. org.springframework.data:spring-data-geode:2.2.6.RELEASE
, which do not match; SD GemFire 2.2.1 != SD Geode 2.2.6) along with Spring Boot for Apache Geode & Pivotal GemFire (SBDG) (org.springframework.geode:spring-geode-starter:1.2.6.RELEASE
), and then unnecessarily pull in SBDG's spring-geode
(core) module, which would be transitively pulled in by the spring-geode-starter
anyway, as well as declaring the org.apache.geode:geode-core
module, phew! :)
在这种情况下,您需要声明的唯一依赖项是SBDG的启动器之一,使用Apache Geode时为org.springframework.geode:spring-geode-starter
,使用Pivotal GemFire时为org.springframework.geode:spring-gemfire-starter
,或者在部署 Spring Boot 时,也可以声明为使用PCC应用于PCF(在这种情况下,建议使用spring-gemfire-starter
依赖项,尽管不是绝对必要的,因为可以混合GemFire/Geode对等体,并让Geode客户与GemFire服务对话,反之亦然).
The only dependency you need to declare in this case is 1 of SBDG's starters, either org.springframework.geode:spring-geode-starter
when using Apache Geode or org.springframework.geode:spring-gemfire-starter
when using Pivotal GemFire, or alternatively when deploying your Spring Boot application to PCF using PCC (in which case, the spring-gemfire-starter
dependency is recommended, though not absolutely necessary since it is possible to mix GemFire/Geode peers and have Geode clients talk to GemFire serves or vice versa).
启动器插入 Spring Data Geode (或 Spring Data GemFire ,具体取决于 starter ),从而插入Geode(或GemFire) )给您.首先,这就是Maven/Gradle依赖关系管理的重点,最好尽可能减少应用程序依赖关系的声明,并让框架/启动程序为您确定传递依赖关系的版本,尤其是在您不这样做的情况下.没关系.
The starter pulls in Spring Data Geode (or Spring Data GemFire, depending on the starter) which pulls in the Geode (or GemFire) bits for you. That is the point of Maven/Gradle dependency management in the first place and it is better to minimize your application dependency declarations as much as possible and just let the framework/starter decide the versions of the transitive dependencies for you, especially if you don't care.
Spring Boot 项目通常对整理并统一所有依赖项版本( Spring 和第3包含方库/传递依赖项).您只需根据所需的应用程序依赖版本(例如Apache Geode或Pivotal GemFire)选择 Spring Boot 的版本.
The Spring Boot project in general goes to great lengths to curate and harmonize all the dependency versions (both Spring and 3rd party libs/transitive dependencies included) for you. You only need to choose the version of the Spring Boot based on the versions of the application dependencies (e.g. Apache Geode or Pivotal GemFire) that you require.
我们在这里尝试为您总结这些内容:
We try to summarize those for you here:
具体请参见:
为透明起见,此版本兼容性表/表格大致翻译为:
To be very transparent, this version compatibility matrix/table, roughly translates into:
- 作为开发人员,我正在使用或选择使用SBDG
1.2.6.RELEASE
. - SBDG
1.2.6.RELEASE
是基于 Spring Boot2.2.6.RELEASE
. - Spring Boot
2.2.6.RELEASE
拉入 Spring DataMoore-SR6
. - Spring数据
Moore-SR6
(此)包括 Spring Data GemFire/Geode2.2.6.RELEASE
. - Spring Data Geode (SDG)
Moore-SR6/2.2.6.RELEASE
是基于 Apache Geode1.9.x
. - Spring Data GemFire (SDG)
Moore-SR6/2.2.6.RELEASE
是基于 关键GemFire9.8.x
. - Spring Data Geode 包括必需的(由SDG提供)和正确的Apache Geode位(相关性).
- Spring Data GemFire 包括必需的(由SDG提供)和正确的Pivotal GemFire位(相关性).
- As a developer, I am using or choosing to use SBDG
1.2.6.RELEASE
. - SBDG
1.2.6.RELEASE
is based on Spring Boot2.2.6.RELEASE
. - Spring Boot
2.2.6.RELEASE
pulls in Spring DataMoore-SR6
. - Spring Data
Moore-SR6
(this) includes Spring Data GemFire/Geode2.2.6.RELEASE
. - Spring Data Geode (SDG)
Moore-SR6/2.2.6.RELEASE
is based on Apache Geode1.9.x
. - Spring Data GemFire (SDG)
Moore-SR6/2.2.6.RELEASE
is based on Pivotal GemFire9.8.x
. - Spring Data Geode includes the required (by SDG) and correct Apache Geode bits (dependencies).
- Spring Data GemFire includes the required (by SDG) and correct Pivotal GemFire bits (dependencies).
因此,您需要在PCF中将哪个版本的SBDG(即哪个spring-[geode|gemfire]-starter
版本)与PCC一起使用?
Therefore it becomes a matter of what version of SBDG (i.e. which spring-[geode|gemfire]-starter
version) do you need to use with PCC in PCF?
为此,您必须大致了解GemFire/Geode客户端只能连接到与该客户端或更高版本的GemFire/Geode服务器并与之通信.新的客户端无法与旧的GemFire/Geode服务器通信.这不是Spring限制,而是GemFire/Geode限制本身.造成这种情况的原因有很多,我在这里不作解释(但大致可以归结为协议,分布式算法和其他内容).
For that, you must have a general understanding that GemFire/Geode clients can only connect to and communicate with GemFire/Geode servers at the same version as the client or later. A newer client CANNOT talk to an older GemFire/Geode server. This is not a Spring restriction, but a GemFire/Geode restriction itself. There are many factors to why this is the case and I won't explain that here (but it roughly boils down to protocols, distributed algorithms and the rest).
通过示例,您可以将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或更早版本的服务器或与之交谈.补丁程序或维护版本与AFAIR无关紧要,例如,只要major.minor
版本匹配,则GemFire 9.8.7客户端应该能够连接并与GemFire 9.8.4服务器通信.
By way of example, you can connect a GemFire 9.8 client to a GemFire 9.8.x server and all will be fine. That same GemFire 9.8 client can also connect to and talk with GeFire 9.9.x and 9.10.x servers. However, a GemFire 9.8 client cannot connect to or talk with a GemFire 9.7, 9.6, 9.5 or earlier server. Patch, or maintenance versions do not matter AFAIR, meaning a GemFire 9.8.7 client should be able to connect and talk to a GemFire 9.8.4 server, for example, so long as the major.minor
versions match.
现在,从本质上讲,可以归结为,您正在部署 Spring Boot ( Data Geode )应用程序的PCF中的哪个版本的Pivotal GemFire是PCC的版本.到,基于?
So now, it essentially boils down to, which version of Pivotal GemFire is the version of PCC in PCF that you are deploying your Spring Boot (Data Geode) application to, based on?
为此,您需要查看PCF/PCC文档.
For that you need to look in the PCF/PCC documentation.
例如,PCF的PCC(现称为VM的VMware Tanzue GemFire)版本1.11基于Pivotal GemFire 9.9.1.请参见此处.
For example, PCC for PCF (now known as VMware Tanzue GemFire for VMs) version 1.11 is based on Pivotal GemFire 9.9.1. See here.
这意味着您可以使用基于 Spring Boot 2.2.6.RELEASE
的SBDG 1.2.6.RELEASE
,它可以导入 Spring Data Moore-SR6
,其中包括SDG 2.2.6.RELEASE
,其基于Apache Geode 1.9.2
/Pivotal GemFire 9.8.7
.这种组合很好,因为较旧的客户端(即GemFire 9.8.7
)可以连接到GemFire 9.9.1
并与之对话,这是PCC/VMware Tanzu GemFire for VMS 1.11
的基准.
This means you could use SBDG 1.2.6.RELEASE
, which is based on Spring Boot 2.2.6.RELEASE
, which pulls in Spring Data Moore-SR6
, which includes SDG 2.2.6.RELEASE
, which is based on Apache Geode 1.9.2
/Pivotal GemFire 9.8.7
. This combination is fine because the older client (i.e. GemFire 9.8.7
) can connect to and talk with GemFire 9.9.1
, which is the baseline for PCC/VMware Tanzu GemFire for VMS 1.11
.
有道理吗?
如果我们查看PCC 1.10,则再次为基于 Pivotal GemFire 9.9.1.
If we look at PCC 1.10, again that is based on Pivotal GemFire 9.9.1.
如果我们看一下PCC 1.9,它是基于 Pivotal GemFire 9.8.6.同样,我们在这里还可以.
If we look at PCC 1.9, it is based on Pivotal GemFire 9.8.6. Again, we are ok here.
如果回到PCC 1.7,我们会看到PCC 1.7是基于 Pivotal GemFire 9.7.2.
If we go back to PCC 1.7, we see that PCC 1.7 was based on Pivotal GemFire 9.7.2.
现在,SBDG 1.2.6.RELEASE
不适用于PCC 1.7,因为SBDG 1.2.6.RELEASE
基于GemFire 9.8(较新),而PCC 1.7基于GemFire 9.7(较旧). 9.8客户端无法连接到9.7服务器并与之通信,因此,我们必须将SBDG major.minor
版本返回到SBDG 1.1.x
,其中SBDG 1.1.x
基于 Spring Boot ,其中提取了 Spring Data Lovelace/2.1
,其中包括SDG 2.1.x
,后者分别基于Apache Geode 1.6
和Pivotal GemFire 9.5
.
Now, SBDG 1.2.6.RELEASE
will NOT work with PCC 1.7 since SBDG 1.2.6.RELEASE
is based on GemFire 9.8 (newer) and PCC 1.7 is based on GemFire 9.7 (older). A 9.8 client cannot connect to and talk with a 9.7 server, therefore, we must go back a SBDG major.minor
version to SBDG 1.1.x
, where SBDG 1.1.x
is based on Spring Boot 2.1
, which pulls in Spring Data Lovelace/2.1
, which includes SDG 2.1.x
, which is based on Apache Geode 1.6
and Pivotal GemFire 9.5
, respectively.
注意:虽然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.
NOTE: While SDG is "compatible" with newer, none "baseline" versions of GemFire/Geode, we do not "support" the combination. For example, SDG Lovelace/2.1 is "based on" GemFire 9.5/Geode 1.6 only, but is "compatible with" GemFire 9.6/9.7 and Geode 1.7/1.8. If you move beyond GemFire 9.7 to, e.g. 9.8 and Geode 1.8 to 1.9, then of course, you should move to SDG Moore/2.2, since it is "based on" GemFire 9.8/Geode 1.9. Compatibility != Support.Anyway, this is to say, you can upgrade your client driver version (i.e. GemFire/Geode client version, if necessary). See here for more details. This Wiki page is a WIP.
云缓存开发人员网站还包含详细信息,可帮助您入门.
The Cloud Cache Developer Website also contains details to help get you started.
最后,我还使用指南和源代码),您可以从 start.spring.io 开始并快速运行.
Finally, I also built this Getting Started Sample (with Guide and Source Code) in the SBDG project itself, that gets you up and running quickly by starting at start.spring.io.
现在,关于您的配置...
Now, regarding your configuration...
@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
实例自动配置 .请参见此处.
SBDG "auto-configures" a ClientCache
instance for you, by default. See here.
实际上,在显式声明注释时应该小心,因为那样的话,您将覆盖自动配置(即通过应用以下方法来覆盖"惯例"明确的"配置",它告诉启动您知道自己在做什么;请确保确实如此!)请参见此处和此处和此处和此处和此处.
In fact, you should be careful when declaring annotations, explicitly, since then you are overriding the auto-configuration (i.e. you are overriding the "convention" by applying explicit "configuration", which tells Boot that you know what you are doing; Make sure that is actually the case!) See here and here and here and here and here.
许多注释属性(例如ClientCacheApplication.name
或ClientCacheApplication.logLevel
)可以在 Spring Boot applications.properties
文件中表示为SDG属性,从而使配置更可配置".
Many of the annotation attributes (e.g. ClientCacheApplication.name
or ClientCacheApplication.logLevel
) can be expressed as SDG properties in a Spring Boot applications.properties
file, making the configuration more "configurable".
例如:
# Spring Boot application.properties.
spring.data.gemfire.name=Test
spring.data.gmefire.cache.log-level=INFO
您也不需要显式启用PDX,因为SBDG再次为您自动配置 PDX.请参见此处.
You also do not need to enable PDX explicitly since again SBDG auto-configures PDX for you. See here.
默认的ClientRegionShortcut
是PROXY,尽管我也不介意对此显式".您只需在带有 auto-configuration 的 Spring Boot 上下文中小心,因为您可能会覆盖" auto-config 并将负责正确管理自己的配置.因此,请故意而不是盲目地声明配置.
The default ClientRegionShortcut
is PROXY, though I don't mind being "explicit" about it either. You simply just have to be careful in a Spring Boot context with auto-configuration since you might "override" the auto-config and put the responsibility of managing the configuration correctly on yourself. So declare configuration with intent, not blindly.
希望这会有所帮助!
这篇关于不支持geode客户端服务器版本-不支持序数为100的对等或客户端版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!