![](/img/trans.png)
[英]How Apache Ignite in embedded mode with Off Heap Storage works?
[英]Apache Ignite embedded cluster mode
我已经运行了两个具有以下配置的嵌入式模式应用程序:
public IgniteConfigurer config() {
return cfg -> {
// The node will be started as a client node.
cfg.setClientMode(false);
// Classes of custom Java logic will be transferred over the wire from this app.
cfg.setPeerClassLoadingEnabled(false);
// Setting up an IP Finder to ensure the client can locate the servers.
final TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
ipFinder.setAddresses(Collections.singletonList(cacheServerIp));
cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
// Cache Metrics log frequency. If 0 then log print disable.
cfg.setMetricsLogFrequency(Integer.parseInt(cacheMetricsLogFrequency));
// setting up storage configuration
final DataStorageConfiguration storageCfg = new DataStorageConfiguration();
storageCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(true);
storageCfg.setStoragePath(cacheStorage);
// setting up data region for storage
final DataRegionConfiguration defaultRegion = new DataRegionConfiguration();
defaultRegion.setName(cacheDefaultRegionName);
// Sets initial memory region size. When the used memory size exceeds this value, new chunks of memory will be allocated
defaultRegion.setInitialSize(Long.parseLong(cacheRegionInitSize));
storageCfg.setDefaultDataRegionConfiguration(defaultRegion);
cfg.setDataStorageConfiguration(storageCfg);
cfg.setWorkDirectory(cacheStorage);
final TcpCommunicationSpi communicationSpi = new TcpCommunicationSpi();
// Sets message queue limit for incoming and outgoing messages
communicationSpi.setMessageQueueLimit(Integer.parseInt(cacheTcpCommunicationSpiMessageQueueLimit));
cfg.setCommunicationSpi(communicationSpi);
final CacheCheckpointSpi cpSpi = new CacheCheckpointSpi();
cfg.setCheckpointSpi(cpSpi);
final FifoQueueCollisionSpi colSpi = new FifoQueueCollisionSpi();
// Execute all jobs sequentially by setting parallel job number to 1.
colSpi.setParallelJobsNumber(Integer.parseInt(cacheParallelJobs));
cfg.setCollisionSpi(colSpi);
// set failure handler for auto connection if ignite server stop/starts.
cfg.setFailureHandler(new StopNodeFailureHandler());
};
}
App1将数据放入缓存中,而App2从缓存中读取数据。 我已经设置了本地 IP 即ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));
因此,本地两个应用程序(即 app1 和 app2)都连接在集群上。 当我在服务器上使用 IP 更改相同的配置时,即ipFinder.setAddresses(Collections.singletonList("server1.com:47500..47509"));
两个服务器,即 app1 和 app2 都没有连接到集群中。
只有当所有应用程序(即 app1 和 app2)都在同一台机器上时,它才嵌入工作吗?
尝试使用static TcpDiscoveryVmIpFinder来定位问题。 默认情况下,TcpDiscoveryMulticastIpFinder 会尝试扫描所有可用的主机以发现 Ignite 节点,并且根据超时,这可能需要一段时间。
假设您的两个节点仍在同一台机器上运行,您可能会保留 localhost 配置:“127.0.0.1:47500..47509”。 "server1.com:47500..47509" should also work if DNS name "server1.com" resolves to the correct IP address, the best way to check that - just to run a ping command to check how localhost and server1.com are正在解决。
If you are running on different machines, then you need to have a list of addresses rather than a singleton: "server1.com:47500..47509", "server2.com:47500.47509" etc.
还建议检查端口是否打开,如果有许多不同的接口可用,则可能显式配置localHost 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.