需要有关在2节点集群中启动Ignite缓存的帮助

时间:2016-11-02 11:04:00

标签: distributed-caching ignite

我是Ignite的新手,并尝试利用Ignite来设置内存缓存。我做了一些基本配置,并在单个节点上启动了基于Ignite的可插拔持久性工作。现在,我计划在2节点集群上测试性能,并按照以下方式设置点火配置:

<?xml version="1.0" encoding="UTF-8"?>

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

<bean id="countryCacheStoreFactory" class="javax.cache.configuration.FactoryBuilder" factory-method="factoryOf">
<constructor-arg><value>com.xyz.exploreignite.cache.CustomCacheStore</value></constructor-arg>
</bean>

<bean id="stateCacheStoreFactory" class="javax.cache.configuration.FactoryBuilder" factory-method="factoryOf">
<constructor-arg><value>com.xyz.exploreignite.cache.CustomStateCacheStore</value></constructor-arg>
</bean>

<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
    <property name="peerClassLoadingEnabled" value="false"/>
<property name="clientMode" value="true"/>
<property name="gridName" value="clusterGrid"/>
    <property name="cacheConfiguration">
        <list>
            <!-- Partitioned cache example configuration (Atomic mode). -->
            <bean class="org.apache.ignite.configuration.CacheConfiguration">
                <property name="atomicityMode" value="ATOMIC"/>
                <property name="backups" value="1"/>
                <property name="name" value="customCountryCache"/>
                <property name="readThrough" value="true"/>
                <property name="writeThrough" value="true"/>
                <property name="cacheMode" value="PARTITIONED"/>
                <property name="writeBehindEnabled" value="true"/>
                <property name="copyOnRead" value="true"/>
                <property name="memoryMode" value="OFFHEAP_TIERED"/>
                <property name="atomicWriteOrderMode" value="PRIMARY"/>
                <property name="indexedTypes" >
        <list>
            <value>java.lang.Integer</value>
            <value>com.xyz.exploreignite.pojo.Country</value>
        </list>
        </property>
        <!-- Cache store. -->
        <property name="cacheStoreFactory" ref="countryCacheStoreFactory"/>
            </bean>
    <bean class="org.apache.ignite.configuration.CacheConfiguration">
                <property name="atomicityMode" value="ATOMIC"/>
                <property name="backups" value="1"/>
                <property name="name" value="customStateCache"/>
                <property name="readThrough" value="true"/>
                <property name="writeThrough" value="true"/>
                <property name="cacheMode" value="PARTITIONED"/>
                <property name="writeBehindEnabled" value="true"/>
                <property name="copyOnRead" value="true"/>
                <property name="memoryMode" value="OFFHEAP_TIERED"/>
                <property name="atomicWriteOrderMode" value="PRIMARY"/>
                <property name="indexedTypes" >
        <list>
            <value>java.lang.Integer</value>
            <value>com.xyz.exploreignite.pojo.State</value>
        </list>
        </property>
        <!-- Cache store. -->
        <property name="cacheStoreFactory" ref="stateCacheStoreFactory"/>
            </bean>
        </list>
    </property>


    <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
    <property name="discoverySpi">
        <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
            <property name="ipFinder">
                <!--
                    Ignite provides several options for automatic discovery that can be used
                    instead os static IP based discovery. For information on all options refer
                    to our documentation: http://apacheignite.readme.io/docs/cluster-config
                -->
                <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
                <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">-->
                    <property name="addresses">
                        <list>
                            <value>127.0.0.1:47500..47509</value>
                            <value>172.26.49.1:47500..47509</value>
                            <!-- In distributed environment, replace with actual host IP address. -->
                            <value>172.26.49.2:47500..47509</value>
                        </list>
                    </property>
                </bean>
            </property>
        </bean>
    </property>
</bean>

现在,在两个节点上以“bin / ignite.sh”开始点燃时,它显示无法连接到服务器。虽然与上面的一个并行运行“bin / ignite.sh”,但是单独的点火配置实例在独立模式下启动,只有一个客户端。我需要让他们两个都使用共享实例。请在我的部署/执行中提出可能的问题。

2 个答案:

答案 0 :(得分:2)

尝试从发现配置中删除<value>127.0.0.1:47500..47509</value>行。它对分布式集群没有太大作用。

答案 1 :(得分:1)

该配置位于<property name="clientMode" value="true"/>您需要将至少一个节点设置为<property name="clientMode" value="false"/>,否则您的客户端将无法连接任何服务器节点。