我正在将我的GemFire集群从8.2.7(使用Spring Data GemFire 1.6.0.RELEASE)迁移到Pivotal GemFire 9.3.0(SDG 2.0.7.RELEASE)。我正在使用spring-context.xml
(在initializer
中的cache.xml
标记下声明)初始化区域,同时在每个节点上启动缓存服务器。
当我尝试为Pivotal GemFire 9.3.0重用相同的spring-context.xml
时,gfsh
命令无法识别我的Spring bean标记,并且我遇到以下异常:
Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 107; cvc-elt.1: Cannot find the declaration of element 'beans'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
spring-context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:gfe="http://www.springframework.org/schema/geode"
xmlns:util="http://www.springframework.org/schema/util"
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
http://www.springframework.org/schema/geode http://www.springframework.org/schema/gemfire/spring-geode.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<util:properties id="gemfireProperties">
<prop key="log-level">config</prop>
<prop key="locators">hostA[10334],hostB[10334]</prop>
</util:properties>
<bean id="mappingPdxSerializer" class="org.springframework.data.gemfire.mapping.MappingPdxSerializer"/>
<gfe:cache properties-ref="gemfireProperties" pdx-serializer-ref="mappingPdxSerializer"/>
<gfe:replicated-region id="Product">
</gfe:replicated-region>
<gfe:replicated-region id="ProductCustomer">
</gfe:replicated-region>
</beans>
我根据gemfire
的Spring文档将XML架构路径从“geode
”更新为“spring-data-gemfire:2.0.7.RELEASE
”。
尝试使用GF 9.1.1和SDGF 2.0.7。 (SDGF jar放在lib中)
脚本:
#!/bin/sh
export PATH=$PATH:/var/tmp/user/gemfire/9.1.1:/opt/jdk/1.8.0_71l64/bin/:/var/tmp/user/gemfire/9.1.1/bin/
export GEMFIRE=/var/tmp/user/gemfire/9.1.1/
for i in `ls /var/tmp/user/gemfire/9.1.1/lib/*.jar`
do
CLASSPATH=${CLASSPATH}:${i}
done
CLASSPATH=$CLASSPATH:/var/tmp/user/gemfire/9.1.1/config
#echo $CLASSPATH
if [ -e "/var/tmp/user/gemfire/9.1.1/config/spring-context.xml" ]; then
echo "File exists"
else
echo "File does not exist"
fi
gfsh start server --name=server1 --server-port=40405 --classpath=$CLASSPATH --spring-xml-location=/var/tmp/user/gemfire/9.1.1/config/spring-context.xml --locators=hostA[10334],hostB[10334] --mcast-port=0
更新
FileNotFoundException
抛出:
Caused by: java.io.FileNotFoundException: class path resource [var/tmp/sn17180/gemfire/9.1.1/config/spring-context.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
... 17 more
我已经允许所有文件和-e“/”在我的脚本中也打印“文件存在”。
更新:
cache.xml
<?xml version="1.0" encoding="UTF-8"?>
<cache xmlns="http://geode.apache.org/schema/cache"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd"
version="1.0">
<region name="Parent" refid="REPLICATE">
<region name="Child" refid="REPLICATE"/>
</region>
</cache>
的GemFire-config.xml中
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:gfe="http://www.springframework.org/schema/gemfire"
xmlns:util="http://www.springframework.org/schema/util"
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
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<util:properties id="gemfireProperties">
<prop key="locators">xyz[10334],xyx[10334]</prop>
<prop key="mcast-port">0</prop>
</util:properties>
<bean id="autoSerializer" class="org.apache.geode.pdx.ReflectionBasedAutoSerializer"/>
<gfe:cache properties-ref="gemfireProperties" cache-xml-location="cache.xml" pdx-serializer-ref="autoSerializer" pdx-read-serialized="true"/>
</beans>
答案 0 :(得分:1)
对于9.x版本系列,Pivotal GemFire已停止在$GEMFIRE_HOME/lib
目录中使用 Spring Data GemFire 发布。这有两个主要原因。
1)首先,当SDG依赖于Pivotal GemFire时,Pivotal GemFire依赖于SDG,这完全是gfsh>start server --name=SpringConfiguredServer --spring-xml-location-/path/to/spring/context.xml
的一个难题,这显然形成了循环依赖。
2)当它与版本相关时,Pivotal GemFire显着落后于 Spring 生态系统的当前状态。即使是最新版本9.3.0也附带了过时的 Spring JAR,例如核心 Spring Framework 4.3.13.RELEASE
,当核心 Spring Framework 4.3.17.RELEASE
已经可用以及5.0.6.RELEASE
时,5.1即将推出。
话说回来,当使用start server
命令从{em> Gfsh 启动时,仍然可以使用 Spring 配置和引导Pivotal GemFire服务器,{{ 1}}选项。您只需根据您正在使用的Pivotal GemFire版本下载appropriate version SDG(例如(9.3.0))并在启动服务器时将SDG放在类路径上。
注意:目前, SDG 2.1.0.M3 (SD Lovelace )是唯一基于Pivotal GemFire 9.3及更高版本的版本;目前设定为9.5.0。
注意:也不是,我没有特别回想一下,在从Pivotal GemFire 9.3逐步升级SDG Lovelace到9.4然后到达9.5之间是否遇到任何API突破性更改。如果您在使用
--spring-xml-location
时遇到问题,那么您当时也可以使用spring-data-gemfire:2.1.0.M3
based on Pivotal GemFire 9.3。
所以按照上面的方法,你会做以下......
spring-data-gemfire:2.1.0.M2
这应该有效!
此外,您无需从&#34; gemfire&#34;切换模式。到&#34; geode&#34;。当您使用Spring Data GemFire时,请使用&#34; spring-gemfire&#34;架构。当您使用Spring Data Geode时,请使用&#34; spring-geode&#34;架构。要么可能会奏效,但......
希望这有帮助!
-j