有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java GemFire 8.2.0集群使用缓存中的静态服务器列表。xml

如何仅使用cache.xml配置文件中静态定义的服务器列表创建GemFire 8.2.0 P2P GemFire服务器集群

我不能使用多播。我不想使用单独的定位器进程

服务器节点的Mycache.xml

<!DOCTYPE cache PUBLIC
"-//GemStone Systems, Inc.//GemFire Declarative Caching 8.0//EN"
"http://www.gemstone.com/dtd/cache8_0.dtd">
<cache>
  <cache-server port="40404" />
  <pool name="serverPool">
      <server host="10.0.0.192" port="40404" />
      <server host="10.0.0.193" port="40404" />
  </pool>
</cache>

我在文档中读到,我可以在池中有一个服务器的静态列表,我在客户端看到,这种配置方式很有效。我的客户端连接到服务器列表。 但仅使用静态集群配置的GemFire服务器/对等集群对我来说不起作用

我现在正在使用 serverCache = new CacheFactory().set("cache-xml-file", "server-cache.xml").set("mcast-port", "0") .set("start-locator","localhost[13489]").set("locators", "localhost[13489]").create();

在这个jmv的日志中我看到了

``` [信息2016/02/08 15:47:34.922 UTC tid=0x1]正在本地主机上启动分发定位器的对等位置/127.0.0.1[13489]

[信息2016/02/08 15:47:34.925 UTC tid=0x1]正在本地主机上启动分发定位器/127.0.0.1[13489]

[信息2016/02/08 15:47:48.093 UTC tid=0x1]本地主机上分发定位器的启动服务器位置/127.0.0.1[13489] ```

在我使用的第二个盒子上

serverCache = new CacheFactory().set("cache-xml-file", "server-cache.xml").set("mcast-port", "0").set("locators", "IP-of-1stbox[13489]").create();

com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service. Operation either timed out or Locator does not exist. Configured list of locators is "[ip-of-1stbox(null)<v0>:13489]". at com.gemstone.org.jgroups.protocols.TCPGOSSIP.sendGetMembersRequest(TCPGOSSIP.java:222) at com.gemstone.org.jgroups.protocols.PingSender.run(PingSender.java:85) at java.lang.Thread.run(Thread.java:745) Exception in thread "main" com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service. Operation either timed out or Locator does not exist. Configured list of locators is "[54.173.123.102(null)<v0>:13489]". at com.gemstone.org.jgroups.protocols.TCPGOSSIP.sendGetMembersRequest(TCPGOSSIP.java:222) at com.gemstone.org.jgroups.protocols.PingSender.run(PingSender.java:85) at java.lang.Thread.run(Thread.java:745)

我打开了13489端口

我看得出来 Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN - tcp 0 0 ::ffff:127.0.0.1:13489 :::* LISTEN 5137/java tcp 0 0 :::40404 :::* LISTEN 5137/java tcp 0 0 :::22 :::* LISTEN - tcp 0 0 ::ffff:10.0.0.193:21145 :::* LISTEN 5137/java tcp 0 0 ::ffff:10.0.0.193:65148 :::* LISTEN 5137/java udp 0 0 0.0.0.0:68 0.0.0.0:* - udp 0 0 10.0.0.193:123 0.0.0.0:* - udp 0 0 127.0.0.1:123 0.0.0.0:* - udp 0 0 0.0.0.0:123 0.0.0.0:* - udp 0 0 ::ffff:10.0.0.193:2300 :::* 5137/java

端口13489正在第一个盒子上使用

当我把他们联系起来的时候,我发现了这个

[warn 2016/02/08 16:38:12.688 UTC <locator request thread[1]> tid=0x20] Expected one of these: [class com.gemstone.gemfire.cache.client.internal.locator.LocatorListRequest, class com.gemstone.gemfire.management.internal.JmxManagerLocatorRequest, class com.gemstone.gemfire.cache.client.internal.locator.ClientReplacementRequest, class com.gemstone.gemfire.cache.client.internal.locator.QueueConnectionRequest, class com.gemstone.org.jgroups.stack.GossipData, class com.gemstone.gemfire.cache.client.internal.locator.ClientConnectionRequest, class com.gemstone.gemfire.cache.client.internal.locator.LocatorStatusRequest, class com.gemstone.gemfire.cache.client.internal.locator.GetAllServersRequest] but received ConfigurationRequest for groups : cluster[cluster]


共 (2) 个答案

  1. # 1 楼答案

    您可以使用start-locatorGemFire属性以嵌入式模式(即在GemFire服务器进程内)启动定位器

    一种方法是:

    1. start-locator=address1[port1]放进火里。属性文件
    2. 使用启动服务器

      gfsh>;启动服务器名称=服务器1属性文件=/path/to/gemfire。房产

    3. 通过将第二台服务器指向第一台服务器中的定位器端口来启动第二台服务器:

      gfsh>;启动服务器名称=服务器2定位器=地址1[port1]

  2. # 2 楼答案

    cache.xml中有一个混淆。你需要两组缓存。xml,一个用于服务器,一个用于客户端。在服务器cache.xml上,定义服务器将在其上侦听客户端通信的端口,定义您的区域等。如下所示:

    <?xml version="1.0" encoding="UTF-8"?>
    <cache
        xmlns="http://schema.pivotal.io/gemfire/cache"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://schema.pivotal.io/gemfire/cache http://schema.pivotal.io/gemfire/cache/cache-8.1.xsd"
        version="8.1">
    <cache-server port="40404" />
    <region name="MyRegion" refid="PARTITION" />
    </cache>
    

    要启动嵌入式定位器并将服务器指向系统中其他正在运行的服务器,可以执行以下操作:

    CacheFactory cf = new CacheFactory();
    cf.set("cache-xml-file", "server-cache1.xml");
    cf.set("mcast-port", "0");
    cf.set("start-locator", "12345");
    cf.set("locators","localhost[12345],localhost[6789]");
    

    在第二个进程中,使用完全相同的locators属性,并使用6789作为start-locator端口

    用于客户端缓存。xml中定义一个连接池,并为其提供一个正在运行的服务器列表:

    <?xml version="1.0" encoding="UTF-8"?>
    <client-cache
        xmlns="http://schema.pivotal.io/gemfire/cache"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://schema.pivotal.io/gemfire/cache http://schema.pivotal.io/gemfire/cache/cache-8.1.xsd"
        version="8.1">
    <pool name="serverPool">
      <server host="localhost" port="40404" />
      <server host="localhost" port="40405" />
    </pool>
    <region name="MyRegion" refid="CACHING_PROXY"/>
    </client-cache>
    

    对于客户端应用程序,应该使用上述缓存创建ClientCache。像这样的xml:

    ClientCacheFactory ccf = new ClientCacheFactory();
    ccf.set("cache-xml-file", "client.xml");
    ClientCache clientCache = ccf.create();
    Region r = clientCache.getRegion("MyRegion");
    r.put("1", "one");