-1

使用与 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]

这里的“主机”和“节点”是什么意思?即使我的缓存已启动并正在运行,我也会收到错误消息

"org.apache.ignite.cache.CacheServerNotFoundException","message":"映射缓存键失败(所有分区节点离开网格)[topVer=AffinityTopologyVersion [topVer=2, minorTopVer=0], cache=hcache]"

我的配置文件:

<?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. 使用缓存指标,我如何识别集群信息?
4

2 回答 2

0

评论限制为 85 个字符,所以我把它留在那里......

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

回答您的问题:

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

  2. 客户端节点并非旨在存储任何数据。如果您想在不同的服务器上安装应用程序并点燃网格,它们会很有用。并允许您在没有临时数据节点中断的情况下重新启动应用程序。

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

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

于 2018-06-07T09:04:49.393 回答
0

尽管这个问题很不清楚,而且你没有提供任何额外的细节,但我对正在发生的事情有一个猜测,但这更像是一种猜测。

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

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

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

于 2018-06-14T15:59:36.693 回答