Spring-Data-Gemfire - 无法联系Locator服务。操作超时或定位器不存在

时间:2017-07-04 16:04:07

标签: spring-boot spring-data gemfire spring-data-gemfire geode

我想连接到一个存在的定位器 现在我没有客户端服务器。

我启动了一个定位器,端口是40001,server1端口是40411。


    gfsh>list members
     Name   | Id
    ------- | ----------------------------------------------
    test1   | 192.168.1.106(test1:1880:locator):1024
    server1 | 192.168.1.106(server1:7532):1025

配置是:


    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:gfe-data="http://www.springframework.org/schema/data/gemfire"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:gfe="http://www.springframework.org/schema/gemfire"
      xmlns:repository="http://www.springframework.org/schema/data/repository"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:util="http://www.springframework.org/schema/util"
      xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
      http://www.springframework.org/schema/data/gemfire http://www.springframework.org/schema/data/gemfire/spring-data-gemfire.xsd
      http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/data/repository/spring-repository.xsd
      http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

        <util:properties id="gemfireProperties">
            <prop key="locators">localhost[40001]
            <prop key="mcast-port">0
        </util:properties>

        <gfe:cache properties-ref="gemfireProperties"/>

        <gfe:cache-server port="40411" />

        <bean id="portGenerator" class="com.demo.server.ServerPortGenerator" />

        <gfe:replicated-region id="Person"/>

    </beans>


错误是:


    [info 2017/07/04 23:48:12.546 CST  tid=0x1] Defaulting license-working-dir to current working directory "C:\Users\IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\demo".

    [info 2017/07/04 23:48:12.547 CST  tid=0x1] Licensing required 2 milliseconds.

    [info 2017/07/04 23:48:12.923 CST  tid=0x1] GemFire P2P Listener started on  tcp:///192.168.1.106:53073

    [info 2017/07/04 23:48:13.094 CST  tid=0x20] unable to connect to locator  localhost(null):40001

    2017-07-04 23:48:16.200  WARN 10904 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireServer': Cannot resolve reference to bean 'gemfireCache' while setting bean property 'cache'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
    2017-07-04 23:48:16.200  WARN 10904 --- [           main] o.s.b.f.support.DisposableBeanAdapter    : Invocation of destroy method failed on bean with name 'gemfireCache': com.gemstone.gemfire.cache.CacheClosedException: A cache has not yet been created.
    2017-07-04 23:48:16.219 ERROR 10904 --- [           main] o.s.boot.SpringApplication               : Application startup failed

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireServer': Cannot resolve reference to bean 'gemfireCache' while setting bean property 'cache'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1531) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:742) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-1.5.4.RELEASE.jar:1.5.4.RELEASE]
        at com.demo.server.ServerApplication.main(ServerApplication.java:32) [classes/:na]
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1634) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]
        ... 16 common frames omitted
    Caused by: com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
        at com.gemstone.org.jgroups.protocols.TCPGOSSIP.sendGetMembersRequest(TCPGOSSIP.java:222) ~[gemfire-8.2.4.jar:na]
        at com.gemstone.org.jgroups.protocols.PingSender.run(PingSender.java:85) ~[gemfire-8.2.4.jar:na]
        at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_111]

天啊,我不知道这个问题。
谁可以帮助我?
我只想构建一个客户端 - 服务器系统。
但现在我甚至无法设置服务器。

2017年7月9日更新

你好约翰,我试过你的例子,但我仍遇到错误。

首先,我使用gfsh启动一个定位器。


    C:\Users\IBM_ADMIN>gfsh
        _________________________     __
       / _____/ ______/ ______/ /____/ /
      / /  __/ /___  /_____  / _____  /
     / /__/ / ____/  _____/ / /    / /
    /______/_/      /______/_/    /_/    9.0.4

    Monitor and Manage Pivotal GemFire
    gfsh>start locator --name=GemFireLocator --log-level=config
    Starting a Geode Locator in C:\Users\IBM_ADMIN\GemFireLocator...
    ......
    Locator in C:\Users\IBM_ADMIN\GemFireLocator on ADMINIB-CI3Q48M[10334] as GemFireLocator is currently online.
    Process ID: 7256
    Uptime: 8 seconds
    GemFire Version: 9.0.4
    Java Version: 1.8.0_101
    Log File: C:\Users\IBM_ADMIN\GemFireLocator\GemFireLocator.log
    JVM Arguments: -Dgemfire.enable-cluster-configuration=true -Dgemfire.load-cluster-configuration-from-dir=false -Dgemfire
    .log-level=config -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterva
    l=9223372036854775806
    Class-Path: C:\Program Files\Java\pivotal-gemfire-9.0.4\lib\geode-core-9.0.4.jar;C:\Program Files\Java\pivotal-gemfire-9
    .0.4\lib\geode-dependencies.jar

    Successfully connected to: JMX Manager [host=ADMINIB-CI3Q48M, port=1099]

    gfsh>list members
         Name      | Id
    -------------- | -------------------------------------------------------
    GemFireLocator | 192.168.1.106(GemFireLocator:7256:locator):1024

    gfsh>describe member --name=GemFireLocator
    Name        : GemFireLocator
    Id          : 192.168.1.106(GemFireLocator:7256:locator):1024
    Host        : ADMINIB-CI3Q48M
    Regions     :
    PID         : 7256
    Groups      :
    Used Heap   : 90M
    Max Heap    : 1755M
    Working Dir : C:\Users\IBM_ADMIN\GemFireLocator
    Log file    : C:\Users\IBM_ADMIN\GemFireLocator\GemFireLocator.log
    Locators    : 192.168.1.106[10334]

然后正如您在spring-boot-gemfire-server-example中提到的,我尝试运行 $ gradlew bootRun

但错误显示: 引起:java.net.BindException:地址已在使用中:JVM_Bind

    [info 2017/07/09 14:57:24.270 CST  tid=0x1] Defaulting license-working-dir to current working directory "C:\Users
    IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\spring-boot-gemfire-server-example".

    [info 2017/07/09 14:57:24.273 CST  tid=0x1] Licensing required 4 milliseconds.

    [info 2017/07/09 14:57:24.324 CST  tid=0x1] Starting peer location for Distribution Locator on localhost/127.0.0.
    [10334]

    [info 2017/07/09 14:57:24.333 CST  tid=0x1] Starting Distribution Locator on localhost/127.0.0.1[10334]

    [info 2017/07/09 14:57:24.347 CST  tid=0x1] Distribution Locator on localhost/127.0.0.1[10334]  is stopped

    [main] WARN org.springframework.context.annotation.AnnotationConfigApplicationContext - Exception encountered during co
    text initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Err
    r creating bean with name 'gemfireCacheServer' defined in org.example.SpringBootGemFireServer: Unsatisfied dependency e
    pressed through method 'gemfireCacheServer' parameter 0; nested exception is org.springframework.beans.factory.BeanCrea
    ionException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exce
    tion is com.gemstone.gemfire.GemFireIOException: Problem starting a locator service
    [main] WARN org.springframework.beans.factory.support.DisposableBeanAdapter - Invocation of destroy method failed on be
    n with name 'gemfireCache': com.gemstone.gemfire.cache.CacheClosedException: A cache has not yet been created.
    [main] INFO org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer -

    Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enable
    .
    [main] ERROR org.springframework.boot.SpringApplication - Application startup failed
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gemfireCacheServer' de
    ined in org.example.SpringBootGemFireServer: Unsatisfied dependency expressed through method 'gemfireCacheServer' param
    ter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemf
    reCache': FactoryBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireIOException:
    roblem starting a locator service
            at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:7
    9)
            at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResol
    er.java:467)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(A
    stractAutowireCapableBeanFactory.java:1128)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAuto
    ireCapableBeanFactory.java:1022)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCa
    ableBeanFactory.java:512)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapa
    leBeanFactory.java:482)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
            at org.springframework.beans.factory.suefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.ja
    a:230)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListabl
    BeanFactory.java:735)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractAppli
    ationContext.java:866)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
            at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
            at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
            at org.example.SpringBootGemFireServer.main(SpringBootGemFireServer.java:52)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': Facto
    yBean threw exception on object creation; nested exception is com.gemstone.gemfire.GemFireIOException: Problem starting
    a locator service
            at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanR
    gistrySupport.java:175)
            at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanReg
    strySupport.java:103)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.j
    va:1606)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:317)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
         rg.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBean
    actory.java:1131)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFa
    tory.java:1059)
            at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.j
    va:835)
            at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:7
    1)
            ... 18 more
    Caused by: com.gemstone.gemfire.GemFireIOException: Problem starting a locator service
            at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.startInitLocator(InternalDistributedSyst
    m.java:847)
            at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.initialize(InternalDistributedSystem.jav
    :606)
            at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.newInstance(InternalDistributedSystem.ja
    a:281)
            at com.gemstone.gemfire.distributed.DistributedSystem.connect(DistributedSystem.java:1651)
            at com.gemstone.gemfire.cache.CacheFactory.create(CacheFactory.java:227)
            at org.springframework.data.gemfire.CacheFactoryBean.createCache(CacheFactoryBean.java:356)
            at org.springframework.data.gemfire.CacheFactoryBean.resolveCache(CacheFactoryBean.java:250)
            at org.springframework.data.gemfire.CacheFactoryBean.init(CacheFactoryBean.java:191)
            at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:178)
            at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:88)
            at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanR
    gistrySupport.java:168)
            ... 27 more
    Caused by: java.net.BindException: Failed to create server socket on  localhost/127.0.0.1[10,334]
            at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:829)
            at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:789)
            at com.gemstone.org.jgroups.stack.tcpserver.TcpServer.startServerThread(TcpServer.java:179)
            at com.gemstone.org.jgroups.stack.tcpserver.TcpServer.start(TcpServer.java:168)
            at com.gemstone.gemfire.distributed.internal.InternalLocator.startTcpServer(InternalLocator.java:629)
            at com.gemstone.gemfire.distributed.internal.InternalLocator.startPeerLocation(InternalLocator.java:698)
            at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.startInitLocator(InternalDistributedSyst
    m.java:832)
            ... 37 more
    Caused by: java.net.BindException: Address already in use: JVM_Bind
            at java.net.DualStackPlainSocketImpl.bind0(Native Method)
            at java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106)
            at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
            at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190)
            at java.net.ServerSocket.bind(ServerSocket.java:375)
            at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:826)
            ... 43 more
    :bootRun FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':bootRun'.
    > Process 'command 'C:\Program Files\Java\jdk1.8.0_101\bin\java.exe'' finished with non-zero exit value 1

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

    Total time: 14.9 secs

然后,我使用gfsh来停止定位器。

我试图直接运行你的例子(不先启动定位器)。

令人难以置信,它成功了。

您的示例似乎是启动新的Gemfire定位器和服务器,而不是连接到存在的定位器。


    [info 2017/07/09 15:19:16.930 CST  tid=0x1] Defaulting license-working-dir to current working directory "C:\Users\
    IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\spring-boot-gemfire-server-example".

    [info 2017/07/09 15:19:16.935 CST  tid=0x1] Licensing required 7 milliseconds.

    [info 2017/07/09 15:19:17.000 CST  tid=0x1] Starting peer location for Distribution Locator on localhost/127.0.0.1
    [10334]

    [info 2017/07/09 15:19:17.016 CST  tid=0x1] Starting Distribution Locator on localhost/127.0.0.1[10334]

    [info 2017/07/09 15:19:18.376 CST  tid=0x1] GemFire P2P Listener started on  tcp:///192.168.1.106:45643

    [info 2017/07/09 15:19:18.624 CST  tid=0x22] locator localhost(null):10334 member address is ADMINIB-CI3
    Q48M(SpringBootGemFireServer):37651

    [info 2017/07/09 15:19:25.674 CST  tid=0x25] locator localhost(null):10334 member address is ADMINIB-CI3
    Q48M(SpringBootGemFireServer):37651

    [info 2017/07/09 15:19:30.686 CST  tid=0x1] Membership: lead member is now ADMINIB-CI3Q48M(SpringBootGemFireServer
    ):37651

    [info 2017/07/09 15:19:30.701 CST  tid=0x1] This member, ADMINIB-CI3Q48M(SpringBootGemFireServer):37651, is becomi
    ng group coordinator.

    [info 2017/07/09 15:19:30.710 CST  tid=0x1] Entered into membership with ID ADMINIB-CI3Q48M(SpringBootGemFireServe
    r):37651.

    [info 2017/07/09 15:19:30.712 CST  tid=0x1] Starting DistributionManager ADMINIB-CI3Q48M(SpringBootGemFireServer):37651.  (took 12629/ ms)

    [info 2017/07/09 15:19:30.715 CST  tid=0x1] Initial (membershipManager) view =  [ADMINIB-CI3Q48M(SpringBootGemFire
    Server):37651{lead}]

    [info 2017/07/09 15:19:30.715 CST  tid=0x1] Admitting member :37651>.
     Now there are 1 non-admin member(s).

    [info 2017/07/09 15:19:30.716 CST  tid=0x1] ADMINIB-CI3Q48M(SpringBootGemFireServer):37651 is the elder and th
    e only member.

    [info 2017/07/09 15:19:31.081 CST  tid=0x1] Did not hear back from any other system. I am the first one.

    [info 2017/07/09 15:19:31.086 CST  tid=0x1] Starting server location for Distribution Locator on localhost/127.0.0
    .1[10334]

    [info 2017/07/09 15:19:31.358 CST  tid=0x1] Initializing region _monitoringRegion_192.168.1.10637651

    [info 2017/07/09 15:19:31.364 CST  tid=0x1] Initialization of region _monitoringRegion_192.168.1.10637651 comp
    leted

    [info 2017/07/09 15:19:32.857 CST  tid=0x1] Initializing region PdxTypes

    [info 2017/07/09 15:19:32.857 CST  tid=0x1] Initialization of region PdxTypes completed

    [main] INFO org.springframework.data.gemfire.CacheFactoryBean - Connected to Distributed System [SpringBootGemFireServer
    ] as Member [ADMINIB-CI3Q48M(SpringBootGemFireServer):37651]in Group(s) [[]] with Role(s) [[]] on Host [ADMINIB-CI3Q
    48M] having PID [0].
    [main] INFO org.springframework.data.gemfire.CacheFactoryBean - Created new GemFire v.8.2.0 Cache [SpringBootGemFireServ
    er].
    [info 2017/07/09 15:19:32.935 CST  tid=0x1] Initializing region __PR

    [info 2017/07/09 15:19:32.935 CST  tid=0x1] Initialization of region __PR completed

    [info 2017/07/09 15:19:32.986 CST  tid=0x1] Partitioned Region /Factorials is born with prId=1 ident:#Factorials

    [main] INFO org.springframework.data.gemfire.PartitionedRegionFactoryBean - Created new Cache Region [Factorials].
    [main] INFO org.springframework.jmx.export.annotation.AnnotationMBeanExporter - Registering beans for JMX exposure on st
    artup
    [main] INFO org.springframework.context.support.DefaultLifecycleProcessor - Starting beans in phase 2147483647
    [info 2017/07/09 15:19:33.379 CST  tid=0x1] Bridge server connection listener bound to address localhost/127.0.0.1
    :40404 with backlog 1,000.

    [info 2017/07/09 15:19:33.396 CST  tid=0x1] ClientHealthMonitorThread maximum allowed time between pings: 15,000

    [info 2017/07/09 15:19:33.425 CST  tid=0x1] CacheServer Configuration:   port=40404 max-connections=800 max-thread
    s=0 notify-by-subscription=true socket-buffer-size=32768 maximum-time-between-pings=15000 maximum-message-count=230000 m
    essage-time-to-live=180 eviction-policy=none capacity=1 overflow directory=. groups=[] loadProbe=ConnectionCountProbe lo
    adPollInterval=5000 tcpNoDelay=true

    [main] INFO org.example.SpringBootGemFireServer - Started SpringBootGemFireServer in 20.399 seconds (JVM running for 20.
    823)
    [info 2017/07/09 15:21:15.585 CST  tid=0x3e] (tid=62 msgId=0) Executing list member
    s

    [info 2017/07/09 15:22:26.546 CST  tid=0x3e] (tid=62 msgId=1) Executing describe me
    mber --name GemFireLocator

    > Building 80% > :bootRun

我可以使用gfsh连接你的示例代码创建的定位器。


    gfsh>
    gfsh>stop locator --name GemFireLocator
    Stopping Locator running in C:\Users\IBM_ADMIN\GemFireLocator on ADMINIB-CI3Q48M[10334] as GemFireLocator...
    Process ID: 7256
    Log File: C:\Users\IBM_ADMIN\GemFireLocator\GemFireLocator.log
    ....

    No longer connected to ADMINIB-CI3Q48M[1099].
    gfsh>gfsh>list members
    "list members" is not available. Reason: Requires connection.
    gfsh>connect to loaclhost[10334]
    Connecting to Locator at [host=localhost, port=10334] ..
    Connecting to Manager at [host=ADMINIB-CI3Q48M, port=1199] ..
    Successfully connected to: [host=ADMINIB-CI3Q48M, port=1199]

    gfsh>list members
    Member Count : 1
    Coordinator  : SpringBootGemFireServer (ADMINIB-CI3Q48M(SpringBootGemFireServer):37651)

             Name           | Id
    ----------------------- | --------------------------------------------------
    SpringBootGemFireServer | ADMINIB-CI3Q48M(SpringBootGemFireServer):37651
    gfsh>describe member --name=SpringBootGemFireServer
    Name        : SpringBootGemFireServer
    Id          : ADMINIB-CI3Q48M(SpringBootGemFireServer):37651
    Host        : ADMINIB-CI3Q48M
    Regions     : Factorials

    PID         : 0
    Groups      :
    Used Heap   : 117M
    Max Heap    : 1755M
    Working Dir : C:\Users\IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\spring-boot-gemfire-server-example
    Log file    : C:\Users\IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\spring-boot-gemfire-server-example
    Locators    : localhost[10334]

    Cache Server Information
    Server Bind              : localhost
    Server Port              : 40404
    Running                  : true
    Client Connections       : 0

    gfsh>list regions
    List of regions
    ---------------
    Factorials

    gfsh>describe region --name=/Factorials
    ..........................................................
    Name            : Factorials
    Data Policy     : partition
    Hosting Members : SpringBootGemFireServer


    Non-Default Attributes Shared By Hosting Members

     Type  | Name | Value
    ------ | ---- | -----
    Region | size | 0

你能帮忙检查一下吗?

2 个答案:

答案 0 :(得分:0)

嗯,在这种情况下, Stack Trace 非常具有启发性。

基本上, Spring 容器无法创建GemFire“peer”cache的实例(它基于 Spring中的<gfe:cache>元素 XML配置)因为GemFire无法找到您从 Gfsh 开始的定位器......

Caused by: com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.  Configured list of locators is "[localhost(null):40001]".
        at com.gemstone.org.jgroups.protocols.TCPGOSSIP.sendGetMembersRequest(TCPGOSSIP.java:222) ~[gemfire-8.2.4.jar:na]
        at com.gemstone.org.jgroups.protocols.PingSender.run(PingSender.java:85) ~[gemfire-8.2.4.jar:na]
        at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_111]

因此......

  

c.g.g.GemFireConfigException:无法联系Locator服务。操作超时或定位器不存在。

接着陈述......

  

已配置的定位器列表为“[localhost(null):40001]”。

locators bean定义中的gemfireProperties属性(定义{{​​3}})是希望加入群集的待定GemFire对等体用于查找GemFire定位器的内容(以及扩展名) ,要加入的集群)。实际上,一个或多个Locator端点(例如host1[port1],host2[port2],...,hostN[portN])定义了挂起的对等成员将加入的集群。

Spring XML配置中gemfireProperties bean定义的格式错误的XML之外,locators属性的值似乎是正确的。你有一个本地运行的“定位器”,在端口40001上监听,至少根据你的陈述。但是,list members命令并不明显。

因此...

  1. 拳头,我认为“test1”是您的定位器?

  2. 并且,您使用... gfsh> start locator --name=tests1 --port=40001 ...启动了定位器(我还建议使用--log-level=config调高日志级别)

  3. 最后,我认为“server1”确实是“GemFire服务器”?

  4. 如果是''test1 " is indeed your Locator, then you can get the runtime information for the Locator using状态定位器`,例如......

    gfsh>status locator --name=test1
    Locator in /Users/jblum/pivdev/lab/test1 on 10.99.199.10[40001] as test1 is currently online.
    Process ID: 89632
    Uptime: 1 minute 15 seconds
    GemFire Version: 9.0.4
    Java Version: 1.8.0_121
    Log File: /Users/jblum/pivdev/lab/test1/test1.log
    JVM Arguments: -Dgemfire.enable-cluster-configuration=true -Dgemfire.load-cluster-configuration-from-dir=false -Dgemfire.log-level=config -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806
    Class-Path: /Users/jblum/Downloads/Pivotal/GemStone/Products/PivotalGemFire/pivotal-gemfire-9.0.4/lib/geode-core-9.0.4.jar:/Users/jblum/Downloads/Pivotal/GemStone/Products/PivotalGemFire/pivotal-gemfire-9.0.4/lib/geode-dependencies.jar
    
    Cluster configuration service is up and running.
    

    现在,我有一个项目,包含文档/说明,您可以使用连接GemFire CacheServer,使用 Spring(Data GemFire)配置的对等缓存应用程序,并使用< em> Spring Boot ,可用"GemFire properties"

    我的“tests1”定位器已在运行,如上所示status locator --name=test1 Gfsh 命令。如果我在启动 Spring Boot GemFire对等缓存,CacheServer应用程序之前列出成员,你会看到这个......

    gfsh>list members
    Name  | Id
    ----- | ----------------------------------------------
    test1 | 10.99.199.10(test1:89632:locator)<ec><v0>:1024
    

    然后,当我启动嵌入式服务器时,你会看到这个......

    gfsh>list members
             Name           | Id
    ----------------------- | --------------------------------------------------------
    test1                   | 10.99.199.10(test1:89632:locator)<ec><v0>:1024
    SpringBootGemFireServer | 10.99.199.10(SpringBootGemFireServer:89790)<ec><v1>:1025
    
      

    注意:我从IDE(IntelliJ IDEA)内部运行服务器。当然,它也可以在命令行中运行。

         

    注意:由于定位器 NOT 在默认端口(即10334)上运行,因此它在 40001 上运行,您需要设置自定义应用程序{{ 1}}运行服务器之前的JVM系统属性为“localhost [40001]”。此属性转换为GemFire的spring.gemfire.locators属性herehere

    由于locators同时显示GemFire进程(Locator + Server),因此您知道服务器已根据定位器加入群集。

    再次,请随意引用我的here

    希望这有帮助!

    -John

答案 1 :(得分:0)

好的,首先,当您启动 GemFire定位器(即&#34; GemFireLocator&#34;使用 Gfsh )时,您使用了以下 Gfsh < / em>命令...

  

gfsh&GT; start locator --name = GemFireLocator --log-level = config

这导致在默认端口 10334 上启动定位器,这不是您之前声明的端口,40001,但这很好;以这种方式运行样本更容易。

describe member命令......

也很明显
  

gfsh&gt;描述成员--name = GemFireLocator

导致......

Name        : GemFireLocator
Id          : 192.168.1.106(GemFireLocator:7256:locator):1024
Host        : ADMINIB-CI3Q48M
Regions     :
PID         : 7256
Groups      :
Used Heap   : 90M
Max Heap    : 1755M
Working Dir : C:\Users\IBM_ADMIN\GemFireLocator
Log file    : C:\Users\IBM_ADMIN\GemFireLocator\GemFireLocator.log
Locators    : 192.168.1.106[10334]

最后一行......

Locators    : 192.168.1.106[10334]

...显示定位器正在侦听绑定到 192.168.1.106 的端口 10334

然后,使用我的sample继续启动 GemFire服务器。我怀疑你不仅从命令行运行了$ gradlew bootRun,而且还按照说明进行了结论,包括&#34; Running with an Embedded GemFire/Geode Locator&#34; ...是吗?

实际上,您发布的 堆栈跟踪显而易见...

...
...
Caused by: java.net.BindException: Failed to create server socket on  localhost/127.0.0.1[10,334]
        at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:829)
        at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:789)
        at com.gemstone.org.jgroups.stack.tcpserver.TcpServer.startServerThread(TcpServer.java:179)
        at com.gemstone.org.jgroups.stack.tcpserver.TcpServer.start(TcpServer.java:168)
        at com.gemstone.gemfire.distributed.internal.InternalLocator.startTcpServer(InternalLocator.java:629)
        at com.gemstone.gemfire.distributed.internal.InternalLocator.startPeerLocation(InternalLocator.java:698)
        at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.startInitLocator(InternalDistributedSyst
m.java:832)
        ... 37 more
Caused by: java.net.BindException: Address already in use: JVM_Bind
        at java.net.DualStackPlainSocketImpl.bind0(Native Method)
        at java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106)
        at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190)
        at java.net.ServerSocket.bind(ServerSocket.java:375)
        at com.gemstone.gemfire.internal.SocketCreator.createServerSocket(SocketCreator.java:826)
        ... 43 more

...因此

Caused by: java.net.BindException: Failed to create server socket on  localhost/127.0.0.1[10,334]

和...

Caused by: java.net.BindException: Address already in use: JVM_Bind

不要混淆&#34;创建服务器套接字&#34;启动GemFire服务器。在Java中(您可能已经知道),无论何时绑定&#34;客户端的地址/端口&#34;要连接的应用程序,请使用java.net.ServerSocket

在这种情况下,定位器是&#34;服务器&#34;并为任何想要连接到GemFire&#34;集群的客户端(例如 Gfsh 或其他对等成员,如GemFire(缓存)服务器)创建java.net.ServerSocket。由定位器定义。

而且,正如您所看到的那样,当您停止第一个定位器(&#34; GemFireLocator&#34;)时,您最初是在 Gfsh 中启动的,然后自行运行示例(并且它已成功启动!),当你​​&#34;描述&#34;会员,使用......

  

gfsh&GT; describe member --name = SpringBootGemFireServer

     Name           | Id
----------------------- | --------------------------------------------------
SpringBootGemFireServer | ADMINIB-CI3Q48M(SpringBootGemFireServer):37651
gfsh>describe member --name=SpringBootGemFireServer
Name        : SpringBootGemFireServer
Id          : ADMINIB-CI3Q48M(SpringBootGemFireServer):37651
Host        : ADMINIB-CI3Q48M
Regions     : Factorials

PID         : 0
Groups      :
Used Heap   : 117M
Max Heap    : 1755M
Working Dir : C:\Users\IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\spring-boot-gemfire-server-example
Log file    : C:\Users\IBM_ADMIN\Documents\Workspace - Shirley\Workspace_SpringBoot\spring-boot-gemfire-server-example
Locators    : localhost[10334]

Cache Server Information
Server Bind              : localhost
Server Port              : 40404
Running                  : true
Client Connections       : 0

您可以从describe member命令中看到几个有趣的信息。

  1. 首先,最重要的是,你看......

    Locators    : localhost[10334]
    
  2. 这是&#34;嵌入式&#34;定位。它正在侦听端口 10334 ,这就是您在&#34; GemFireLocator&#34;时遇到j.n.BindException的原因。第一次跑。

    这意味着已设置spring.gemfire.start-locator应用程序属性,by default, I see that it is。这反过来sets the GemFire propertystart-locatorfrom the application property),然后导致GemFire启动&#34;嵌入&#34;定位器。

    结果,当&#34; GemFireLocator&#34;自从你开始使用&#34; GemFireLocator&#34;在默认端口 10334

    如果您已经启动了&#34; GemFireLocator&#34;或者&#34;嵌入式&#34;在不同的端口上定位器,你不会有这个问题。

    您可以使用 Gfsh 启动其他端口上的定位器...

      

    gfsh&GT; start locator --name = GemFireLocator --port = 11235 --log-level = config

    但是,如果你想连接&#34; SpringBootGemFireServer&#34;现有的&#34;定位器(即&#34; GemFireLocator&#34;在 Gfsh 中启动),然后您必须更改spring.gemfire.locators application property以匹配(例如localhost[11235])。这反过来是captured here并设置here

    或者,您可以将spring.gemfire.start-locator application property的值更改为,例如...... localhost[12480],或者只是将其注释。由于外部定位器(&#34; GemFireLocator&#34;)和&#34;嵌入式&#34;这也可以避免j.n.BindException。然后定位器不会在端口上发生冲突。

    从技术上讲,我的样本中默认情况下应该注释掉spring.gemfire.start-locator。道歉。

    1. 关于&#34; SpringBootGemFireServer&#34的其他有趣的花絮......你有一个CacheSever可用于连接的缓存客户端(即ClientCache)应用程序,因此... < / p>

      Cache Server Information
      Server Bind              : localhost
      Server Port              : 40404
      Running                  : true
      Client Connections       : 0
      
    2. 这来自here

      1. 当然,你会看到&#34; Factorials&#34;区域...

        Regions     : Factorials
        
      2. 所以,关于(现在可能很明显)......

          

        令人难以置信,它成功了。

             

        似乎您的示例是启动新的Gemfire定位器和服务器,而不是连接到存在的定位器。

        SpringBootGemFireServer成功开始,因为你1)停止了你的&#34; GemFireLocator&#34; 2)SpringBootGemFireServer正在运行&#34;嵌入式&#34;定位器,从this显而易见。

        如果SpringBootGemFireServer 运行&#34; embedded&#34;定位器(服务),然后你能够连接(在你停止你的&#34; GemFireLocator&#34;之后),但是你确实...

        gfsh>stop locator --name GemFireLocator
        Stopping Locator running in C:\Users\IBM_ADMIN\GemFireLocator on ADMINIB-CI3Q48M[10334] as GemFireLocator...
        Process ID: 7256
        Log File: C:\Users\IBM_ADMIN\GemFireLocator\GemFireLocator.log
        ....
        
        No longer connected to ADMINIB-CI3Q48M[1099].
        
        gfsh>gfsh>list members
        "list members" is not available. Reason: Requires connection.
        
        gfsh>connect
        Connecting to Locator at [host=localhost, port=10334] ..
        Connecting to Manager at [host=ADMINIB-CI3Q48M, port=1199] ..
        Successfully connected to: [host=ADMINIB-CI3Q48M, port=1199]
        

        &#34; SpringBootGemFireServer&#34;也是&#34;经理&#34;,这实际上是您可以在 Gfsh 中连接的原因。

        如果您在没有选项的情况下使用 Gfsh&#39> <{em> connect,默认情况下,connect会尝试在&#34; localhost&#34;上找到定位器。在端口 10334 上收听,因此......

        Connecting to Locator at [host=localhost, port=10334]
        

        但是,定位器的职责是在群集中找到现有的Manager并告诉客户端(即 Gfsh )在哪里找到它(即IP地址/端口)。这就是你看到后续连接......

        的原因
        Connecting to Manager at [host=ADMINIB-CI3Q48M, port=1199] ..
        

        this使所有这一切成为可能。如果还没有现有的&#34;经理&#34;在群集中,定位器被编程/配置为成为&#34;经理&#34;。 jmx-manager GemFire property使群集中的任何成员都能够成为&#34;经理。但是,这并不意味着默认情况下它将作为Manager启动。要在开始时强制成员成为管理员,您还必须设置jmx-manager-start GemFire property,就像我使用SpringBootGemFireServer一样(当然,我默认将值默认为 false ,因此它不会在创业时担任经理)。总之...

        如果您想连接到外部,&#34;现有的&#34;定位器(例如&#34; GemFireLocator&#34;)以 Gfsh 开头,然后......

        1. 运行...
        2. gfsh&GT; start locator --name = GemFireLocator --log-level = config。

            

          注意:请记住,除非您为start locator命令指定了--port选项,否则GemFireLocator将侦听默认端口(10334)。

          1. 请务必在&#34; SpringBootGemFireServer&#34;中收集的application.properties文件中注释掉line 8。应用。或者,您可以通过将spring.gemfire.start-locator应用程序属性设置为更改嵌入式定位器端口,例如...... localhost[11235]

          2. (可选)如果为&#34;外部&#34;设置端口/&#34;现有&#34;定位器(即&#34; GemFireLocator&#34;从 Gfsh 开始),然后务必将spring.gemfire.locators application property设置为匹配。

          3. 希望这有帮助!

            此致 -John