Apache Ignite中群集之间的数据复制

时间:2018-07-17 12:42:52

标签: java apache ignite gridgain

我有2个集群,集群1中有一个名为“ cache1”的缓存,其中有一些数据

我想要的是,当客户端连接群集2时,当它说igniteCache.getOrCreateCache(“ cache1”)时,它应该返回我在群集1中创建的缓存,并且客户端也应该能够在群集2中进行CRUD操作这将同时更新群集1和群集2中的缓存。

(根据我的研究,我可以使用Apache Ignite Native Persistence,这里是链接http://frommyworkshop.blogspot.com/2017/09/the-apache-ignite-native-persistence.html

我可以将Postgresql与Ignite Persistence一起使用吗?或者我应该找到另一个解决方案。 (特别是我正在寻找有关点火功能的答案)

两个xml文件中都没有缓存配置,但假定它将是

这是我的集群1配置

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:util="http://www.springframework.org/schema/util"
   xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/util
    http://www.springframework.org/schema/util/spring-util.xsd">


    <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
        <!--set the cluster name-->
        <property name="igniteInstanceName" value="FirstCluster"/>
        <property name="discoverySpi">
            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <!--Initial local port to listen-->
                <property name="localPort" value="48500"/>
                <!--determine local port range-->
                <property name="localPortRange" value="20"/>

                <!--Set the ip finder-->
                <property name="ipFinder">
                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                        <property name="addresses">
                            <list>
                                <value>127.0.0.1:48500..48520</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>
        <property name="communicationSpi">

            <bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">

                <property name="localPort" value="48100"/>

            </bean>

        </property>
    </bean>

这是我的集群2配置

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:util="http://www.springframework.org/schema/util"
   xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/util
    http://www.springframework.org/schema/util/spring-util.xsd">



<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
    <!--set the cluster name-->
    <property name="igniteInstanceName" value="SecondCluster"/>

    <!-- Enabling Apache Ignite Persistent Store. -->
    <!--<property name="dataStorageConfiguration">-->
        <!--<bean class="org.apache.ignite.configuration.DataStorageConfiguration">-->
            <!--<property name="defaultDataRegionConfiguration">-->
                <!--<bean class="org.apache.ignite.configuration.DataRegionConfiguration">-->
                    <!--<property name="persistenceEnabled" value="true"/>-->
                <!--</bean>-->
            <!--</property>-->
        <!--</bean>-->
    <!--</property>-->
    <property name="discoverySpi">
        <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
            <!-- Initial local port to listen to. -->
            <property name="localPort" value="49500"/>
            <!-- Changing local port range. This is an optional action. -->
            <property name="localPortRange" value="20"/>
            <!-- Setting up IP finder for this cluster -->
            <property name="ipFinder">
                <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                    <property name="addresses">
                        <list>
                            <!--
                                Addresses and port range of the nodes from the second
                                cluster.
                                127.0.0.1 can be replaced with actual IP addresses or
                                host names. Port range is optional.
                            -->
                            <value>127.0.0.1:49500..49520</value>
                        </list>
                    </property>
                </bean>
            </property>
        </bean>
    </property>
    <property name="communicationSpi">
        <bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
            <property name="localPort" value="49100"/>
        </bean>
    </property>
</bean>

1 个答案:

答案 0 :(得分:0)

基于Apache Ignite构建的GridGain具有Datacenter Replication功能。

否则,这取决于您。您基本上有三个选择:

  • 集群2使用自定义CacheStore从集群1中提取数据。
  • 集群1使用ContinuousQuery将更新推送到集群2。
  • 集群1和集群2都使用JDBC CacheStore从同一源(例如PostgreSQL)中提取数据。
相关问题