代码之家  ›  专栏  ›  技术社区  ›  dmc

GemFire 8.2.0集群使用cache.xml中的静态服务器列表

  •  1
  • dmc  · 技术社区  · 10 年前

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

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

    我的 缓存.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的日志中

    ``` [info 2016/02/08 15:47:34.922 UTC tid=0x1]开始本地主机上分发定位器的对等位置/127.0.0.1[13489]

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

    [info 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 回复  |  直到 10 年前
        1
  •  1
  •   Swapnil    10 年前

    cache.xml 。您需要两组缓存。xml,一个用于服务器,另一个用于客户端。在服务器上 缓存.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");
    
        2
  •  1
  •   Swapnil    10 年前

    您可以在嵌入式模式下启动定位器(即在GemFire Server进程中使用 start-locator gemfire属性。

    一种方法是:

    1. start-locator=address1[port1] 在gemfire中。属性文件。
    2. 使用启动服务器

      gfsh>启动服务器--名称=server1--属性文件=/path/to/gemfire.properties

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

      gfsh>启动服务器--name=server2--locators=address1[port1]