0

嗨,我想使用 Spring gemfire 8.1 在同一主机上启动多个 gemfire 缓存服务器。请在下面找到 gemfire 配置文件。我想使用 Spring Gemfire 配置在同一主机 ieHOSTNAME 上启动 GFServer1 和 GFServer2。我想避免 gfsh 命令并从 eclipse 启动所有内容并将客户端连接到同一主机上的这些服务器。提前致谢

    <util:properties id="gemfireProperties">
        <prop key="name">Locator_Dev</prop>
        <prop key="mcast-port">0</prop>
        <prop key="locators">HOSTNAME[1099]</prop>
        <prop key="log-level">warning</prop>
        <prop key="http-service-port">8181</prop>
        <prop key="jmx-manager">true</prop>
        <prop key="jmx-manager-port">1199</prop>
        <prop key="jmx-manager-start">true</prop>
        <prop key="start-locator">HOSTNAME[1099]</prop>
    </util:properties>

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


    <gfe:cache-server id="GFServer1" auto-startup="true"
        bind-address="HOSTNAME" port="40411" host-name-for-clients="HOSTNAME"
        load-poll-interval="2000" max-connections="22" max-threads="16"
        max-message-count="1000" max-time-between-pings="30000" >

        <gfe:subscription-config eviction-type="ENTRY"
            capacity="1000" disk-store="diskStore1" />
    </gfe:cache-server>


    <gfe:cache-server id="GFServer2" auto-startup="true"
        bind-address="HOSTNAME" port="40412" host-name-for-clients="HOSTNAME"
        load-poll-interval="2000" max-connections="22" max-threads="16"
        max-message-count="1000" max-time-between-pings="30000" >

        <gfe:subscription-config eviction-type="ENTRY"
            capacity="1000" disk-store="diskStore1" />
    </gfe:cache-server>


   <gfe:disk-store id="diskStore1" queue-size="50"
        auto-compact="true" max-oplog-size="10" time-interval="9999">
        <gfe:disk-dir
            location="D:\NP\WorkSpace\GemfireRegionSolutionNStart\disk-store\store_1"
            max-size="20" />
        <gfe:disk-dir
            location="D:\NP\WorkSpace\GemfireRegionSolutionNStart\disk-store\store_2"
            max-size="20" />
    </gfe:disk-store>


    <gfe:replicated-region id="customer" name="Customer">
    </gfe:replicated-region>

    <gfe:replicated-region id="bookMaster" name="BookMaster">
    </gfe:replicated-region>

</beans> 
4

4 回答 4

1

因此,您可以配置LocatorLauncherFactoryBean,例如,像这样......

<uti:properties id="gemfireProperties">
  <prop key="log-level">config</prop>
  <prop key="http-service-port">8181</prop>
  <prop key="jmx-manager">true</prop>
  <prop key="jmx-manager-port">1199</prop>
  <prop key="jmx-manager-start">true</prop>
  <prop key="locators">host1[10334],host2[11235],...,hostN[20668]</prop>
</util:properties>

<bean id="locator" class="org.spring.data.gemfire.config.LocatorLauncherFactoryBean">
  <property name="gemfireProperties" ref="gemfireProperties"/>
  <property name="memberName" value="SpringDataGemFireLocator"/>
  <property name="bindAddress" value="10.124.12.24"/>
  <property name="port" value="12480"/>
</bean>

您可能已经注意到,此定位器可以加入 GemFire 集群中的其他定位器,这些定位器是在带有“ ”GemFire 系统属性的“ gemfireProperties”bean中指定的。locators

注意:只有在运行此定位器的 localhost 具有多个 NIC 并且您想要绑定到特定 NIC 时,才需要使用" bindAddress" 属性。LocatorLauncherFactoryBean

此外,我设置了 JMX Manager GemFire System 属性,以使定位器成为并实际启动管理器(在端口 1199 上)。gfsh>connect --locator=localhost[12480]这允许您从 Gfsh 使用或使用连接到此定位器gfsh>connect --jmx-manager=localhost[1199]

基本上," gemfireProperties" bean 允许您配置任何有效的 GemFire 系统属性

现在,由于此定位器是在您的 IDE 中运行的,您需要使用$GEMFIRE指向从 Pivotal 网站下载的 GemFire 发行版的环境变量配置“运行配置文件”,以便从该定位器运行 Pulse。GemFire 管理器的 ManagementAgent在决定是否 1. 启动运行 GemFire 的开箱即用 web 应用程序(例如 Pulse)的嵌入式 HTTP 服务 (Jetty) 和 2. 它是否可以找到 Pulse 并启动 web 应用程序时,这是预期的。ManagementAgent在发行版中查找 Pulse

例如,我将我的 $GEMFIRE 环境变量设置为...

/Users/jblum/Downloads/Pivotal/GemStone/Products/GemFire/Pivotal_GemFire_820_b17919_Linux

现在,让您的个人 Spring 配置的 GemFire 服务器连接到集群,这很简单。

同样,您只需要gemfireProperties在每个 Spring GemFire Server XML 配置文件中定义一个“”bean,并定义“定位器”GemFire 系统属性,例如...

<uti:properties id="gemfireProperties">
  <prop key="log-level">config</prop>
  <prop key="locators">localhost[12480]</prop>
</util:properties>

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

此配置将使 GemFire 数据节点能够连接到集群,如果一切设置正确,该集群将从 Pulse 中可见。

再次,希望这会有所帮助。

干杯,约翰

于 2015-10-02T02:03:03.760 回答
1

有没有具体的问题?正如@Swapnil 指出的那样,这将启动 2 个 GemFire“缓存服务器”(侦听缓存客户端的服务器套接字),因为您已在同一 JVM 中的同一主机上进行了适当的配置。无论如何执行(即 IDE、命令行、来自 Gfsh 或来自 Spring Boot),这都将起作用。

如果您有更具体的问题,请告诉我们,谢谢!

于 2015-09-28T16:43:18.927 回答
1

您发布的配置将在同一个 JVM 中创建两个缓存服务器,即它将在同一个进程中打开两个端口。

如果这不是您想要的,即您想要两个不同的进程,在 Eclipse 中您将必须提供两个运行时配置来启动两个服务器。

于 2015-09-28T13:59:57.673 回答
0

好的...所以您可以从 IDE(例如 Eclipse)中获得一些选项。

如果您将上面的 Spring 配置分解为 2 个单独的 Spring (Data GemFire) XML 配置文件,每个包含 1 个<gfe:cache-server>元素,请调用这些文件,例如 spring-gemfire-server1-context.xml 和 spring-gemfire-server2-context .xml,您可以使用以下命令运行基于 Spring/配置的 GemFire“数据节点”和缓存服务器...

简单的SpringApplication

简单的小 Java“主”程序的参数是上面提到的 Spring XML 配置文件 1 的文件系统路径。

更好的是,您可以使用 SpringBoot 应用程序启动这些 Spring (GemFire) 配置,使用类似...

有用的SpringBootGemFireApplication

正如您在此处看到的,@Import如果您使用基于 Java 的配置(例如UsefulSpringBasedGemFireConfiguration)从 Spring 配置 GemFire,则可以使用该注解,或者在您的情况下,使用该 @ImportResoruce("/classpath/to/spring-gemfire-server1-context.xml")注解使用 XML。

可能(不确定)将 System 属性值传递到 @ImportResource 注释中,就像这样......

@SpringBootApplication
@ImportResource("${spring-gemfire-context-xml-location}")
class SpringBootGemFireApplication {
  ...
}

然后,在您的 IDE 中,您可以使用相同的类创建 2 个单独的“运行配置文件” SpringBootGemFireApplication,然后-Dspring-gemfire-context-xml-location=/path/to/spring-gemfire-server1-context.xml为每个配置适当地设置系统属性(例如 )。

请记住,您可以使用 Spring 的ResourceLoader 路径限定符(例如 file:、http: 等)从不同的源位置(CLASSPATH、文件系统等)解析您的 Spring GemFire 配置...参见表(“表 7.1 资源字符串” ) 在Spring Framework Reference Guide的超链接部分。

在最坏的情况下,您需要创建 2 个独立但几乎相同的 SpringBoot 应用程序 Java 主类来为每个 GemFire 数据节点(和 CacheServer)JVM 进程启动您的 2 个配置文件。但是,希望使用 System property 方法可以让您在 2 个单独的运行配置文件中回收相同的类。

所以,这给你留下了 2 个 GemFire 数据节点 JVM 进程。但是,他的定位器呢?

好吧,您可以像以前一样继续将 Locator 嵌入到 GemFire Data Node Server JVM 进程中,但是如果您真的想要一个独立的 Locator JVM 进程,那么您可以使用以下“实验”类...

LocatorLauncherFactoryBean

此类使用 GemFire 的LocatorLauncher类从 Spring 配置中配置和引导GemFire 定位器。我在 2 年前为客户 POC 创建了这个类,作为开发人员如何从 Spring config配置GemFire 定位器的示例。

Spring XML 配置(由SpringBootGemFireApplication @ImportResoruce注释使用,在另一个“运行配置文件”和系统属性组合中)看起来类似于以下内容......

定位器.xml

现在,您已经有效地实现了 3 个独立的 GemFire JVM 进程(2 个服务器和 1 个定位器)。您可以使用我们的 IDE 将其扩展到您想要的任意数量的服务器和定位器,并且 Pulse 将在集群中显示所有这些,前提是集群配置正确(服务器指向定位器等)。

希望这可以帮助。

干杯! 约翰

于 2015-09-30T15:50:05.133 回答