【问题标题】:Data Replication Between Cluster in Apache IgniteApache Ignite 中集群之间的数据复制
【发布时间】:2018-12-25 04:10:52
【问题描述】:

我有 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 一起使用吗?或者我应该找到另一个解决方案。 (特别是我正在寻找有关 ignite 功能的答案)

两个 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>

【问题讨论】:

    标签: java ignite gridgain


    【解决方案1】:

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

    否则,由您来实施。你基本上有三个选择:

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

    【讨论】:

    • 谢谢,你能用你的话解释一下Continuous query吗?我应该使用哪一个?更容易实现?
    • apacheignite.readme.io/docs/continuous-queries 这取决于您的用例使用哪一个。那么,哪一个更容易实现也取决于你的用例。
    • @MehmetOzanGüven 如果您有任何具体问题,我建议您使用 按钮向他们提问。否则,我建议安装 Apache Ignite 并尝试运行(和调整)示例 ContinuousQueries。
    • @MehmetOzanGüven 如果您需要有关 Apache Ignite 或 GridGain 的帮助,您可以直接联系 GridGain 人员 (gridgain.com/contact) - 他们提供专业支持。
    猜你喜欢
    • 2022-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-18
    • 2018-12-25
    • 2020-02-14
    • 2021-05-23
    相关资源
    最近更新 更多