" org.apache.ignite.cache.CacheServerNotFoundException错误"尝试从Ignite缓存中获取值时

时间:2018-06-06 09:39:36

标签: java caching ignite

使用与Apache Ignite集成的Spring Boot,我尝试集群四台服务器(IP)。

我没有给出配置<property name="clientMode" value="true"/>,这意味着所有四个IP都充当服务器。

Metrics for local node (to disable set 'metricsLogFrequency' to 0)
    ^-- Node [id=ca01c73e, uptime=17:40:06.266]
    ^-- H/N/C [hosts=1, nodes=2, CPUs=12]
    ^-- CPU [cur=0.03%, avg=0.02%, GC=0%]
    ^-- PageMemory [pages=25]
    ^-- Heap [used=66MB, free=70.66%, comm=217MB]
    ^-- Non heap [used=91MB, free=-1%, comm=93MB]
    ^-- Outbound messages queue [size=0]
    ^-- Public thread pool [active=0, idle=0, qSize=0]
    ^-- System thread pool [active=0, idle=6, qSize=0]

&#34; Host&#34;和&#34;节点&#34;在这里表示?即使我的缓存启动并运行,我也会收到错误

  

&#34; org.apache.ignite.cache.CacheServerNotFoundException&#34;,&#34; message&#34;:&#34;无法映射缓存键(所有分区节点都离开了网格)[topVer = AffinityTopologyVersion [topVer = 2,minorTopVer = 0],cache = hcache]&#34;

我的配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<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 abstract="true" id="ignite.cfg"
        class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="peerClassLoadingEnabled" value="true" />
        <property name="cacheConfiguration">
            <list>
                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="name" value="hcache" />
                    <property name="expiryPolicyFactory">
                        <bean id="expiryPolicy" class="javax.cache.expiry.CreatedExpiryPolicy"
                            factory-method="factoryOf">
                            <constructor-arg>
                                <bean class="javax.cache.expiry.Duration">
                                    <constructor-arg value="HOURS" />
                                    <constructor-arg value="1" />

                                </bean>
                            </constructor-arg>
                        </bean>
                    </property>
                </bean>
                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="name" value="dcache" />
                    <property name="expiryPolicyFactory">
                        <bean id="expiryPolicy" class="javax.cache.expiry.CreatedExpiryPolicy"
                            factory-method="factoryOf">
                            <constructor-arg>
                                <bean class="javax.cache.expiry.Duration">
                                    <constructor-arg value="HOURS" />
                                    <constructor-arg value="24" />
                                </bean>
                            </constructor-arg>
                        </bean>
                    </property>
                </bean>
                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="name" value="wcache" />
                    <property name="expiryPolicyFactory">
                        <bean id="expiryPolicy" class="javax.cache.expiry.CreatedExpiryPolicy"
                            factory-method="factoryOf">
                            <constructor-arg>
                                <bean class="javax.cache.expiry.Duration">
                                    <constructor-arg value="DAYS" />
                                    <constructor-arg value="7" />
                                </bean>
                            </constructor-arg>
                        </bean>
                    </property>
                </bean>
            </list>
        </property>
        <property name="includeEventTypes">
            <list>
                <!--Task execution events -->
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED" />
                <util:constant
                    static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED" />

                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED" />

                <util:constant
                    static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT" />
                <util:constant
                    static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET" />
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED" />

                <!--Cache events -->
                <util:constant
                    static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT" />
                <util:constant
                    static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ" />
                <util:constant
                    static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED" />
            </list>
        </property>
        <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">
                <property name="ipFinder">
                    <bean
                        class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
                        <property name="addresses">
                            <list>
                                <value>IP1:1093</value>
                                <value>IP2:1093</value>
                                <value>IP3:1093</value>
                                <value>IP4:1093</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>
</beans>

这是我通过代码启动Ignite缓存的方法:

@Component
public class IgniteCacheManager {
    private static final Logger LOGGER = LoggerFactory.getLogger(IgniteCacheManager.class);

    private  Ignite ignite;
    public Ignite getIgnite() {
        return ignite;
    }
    @Autowired
    private IgniteCacheManager(AppSpecificIgniteProperties igniteProperties) {
        try {

            // Ignite cache will start
            /*Iginite cache is started with the help of the environment specific configuration file
             * 
             * */
            ignite=Ignition.start(igniteProperties.getConfigFile());        
            ignite.cluster().active(true);
            LOGGER.info("IGNITE CACHE STARTED");
        } catch (IgniteException e) {
            LOGGER.error(e.getMessage(), e);
            throw e;
        }   
    }
    public IgniteCache<String, Integer> getOrCreateCache(String name){

        return  ignite.getOrCreateCache(name);

    }
}

使用配置文件启动Ignite缓存。

ignite.cluster().active(true);用于创建群集并激活。

我是否必须在代码或配置中包含更多配置?

在Unix中启动我的应用程序作为jar时,应用程序和Ignite缓存已启动并运行,但是当我尝试命中将从缓存中获取密钥值的端点时,我收到错误

  

所有节点都留下了分区

注意:我没有使用control.sh / ignite.sh文件来启动/停止。

以下是一些其他问题,可以了解有关Ignite缓存的更多信息:

  1. 启动应用程序时是否必须遵循某个顺序才能使群集相应发生?我尝试了一些模式,但无法解决错误。
  2. 我应该使用这个服务器充当客户端,其他服务器应该充当服务器吗?
  3. 如何列出群集下的服务器?
  4. 使用缓存指标,如何识别群集信息?

2 个答案:

答案 0 :(得分:0)

评论仅限于85个字符,所以我就把它留在那里......

  • 你有多少个节点?您确定在所有节点已加入并且您在&#34; toplogy snapshot&#34;中看到了正确的数字时激活了群集日志中的消息?
  • 首次激活后./control.sh显示的基线是什么?
  • 您可以在基线的所有节点加入网格之前激活群集并发出第一个请求。因此,那时您可以请求数据到位于即将启动的节点上的分区。
  • 此外,当您从基线启动一个节点而第二个不属于任何基线拓扑时,您可能面临导致数据丢失的错误。 请在重新启动之前检查所有节点是否都处于基线状态,基线节点启动时没有没有基线的节点启动。并在重新启动后检查ignite是否不从非工作目录中删除分区文件。

回答你的问题:

  1. 首先尝试启动基线节点,然后启动其他节点。通常,在网格重启时无需重新启动客户端节点(如果有的话)。

  2. 客户端节点不是为存储任何数据而设计的。如果您希望在不同的服务器上使用app并点亮网格,它们非常有用。并允许您在没有临时数据节点中断的情况下重新启动应用程序。

  3. 您可以在&#34;拓扑快照&#34;中看到节点数量。和日志中的NODE_JOIN \ NODE_LEFT \ NODE_FAILED事件。 ./control.sh可以显示基线节点及其状态。 Ignite.cluster()组件允许您以编程方式获取节点信息。此外,JMX bean非常有用。

  4. CacheMetrics是缓存的指标,他们没有集群信息。尝试使用JMX。

答案 1 :(得分:0)

即使问题非常清楚,而且您还没有提供任何其他细节,我猜测会发生什么,但这更像是一种猜测。

指标meeans中的H/N/C [hosts=1, nodes=2, CPUs=12]您在同一台计算机上有2个正在运行的节点。这些是群集中的所有节点。您没有连接4个节点。

发现配置对我来说不正确。 您在地址列表中指定了非默认端口1093,但不要重新定义您的本地端口 - 默认情况下为47500。您似乎需要将localPort属性(TcpDiscoverySpi::setLocalPort)设置为1093,以便节点互相发现。

两个节点仍然可以连接 - 可能是因为多播。我假设您在同一个多播组(子网络)中启动了两个节点。我建议您将TcpDiscoveryMulticastIpFinder更改为TcpDiscoveryVmIpFinder以确保节点使用配置中提供的地址和端口。