使用与 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 缓存的更多信息:
- 在启动我的应用程序时,我是否必须遵循特定的顺序,以便集群相应地发生?我尝试了一些模式,但无法解决错误。
- 我应该使用这台服务器作为客户端,而其他服务器应该作为服务器吗?
- 如何列出集群下的服务器?
- 使用缓存指标,我如何识别集群信息?