Apache Ignite嵌入式集群模式



我已经运行了两个嵌入式模式的应用程序,具有以下配置:

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(都在同一台机器上时,它才能嵌入工作吗?

尝试使用静态TcpDiscoveryVmIpFinder来查找问题。默认情况下,TcpDiscoveryMulticastIpFinder会尝试扫描所有可用主机以发现Ignite节点,根据超时情况,这可能需要一段时间。

假设您的两个节点仍在同一台机器上运行,您可能会保留localhost配置:";127.0.0.1:47500..47509"server1.com.47500.47509";如果DNS名称";server1.com";解析为正确的IP地址,这是检查的最佳方法——只需运行ping命令来检查localhost和server1.com是如何解析的。

如果你在不同的机器上运行,那么你需要有一个地址列表,而不是一个单例:;server1.com.47500.47509"server2.com.47500.47509";等

还建议检查端口是否打开,如果有许多不同的接口可用,则可能显式配置localHost。

最新更新