微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Apache Ignite 嵌入式集群模式

如何解决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)都在同一台机器上时,它才嵌入工作吗?

解决方法

尝试使用 a static TcpDiscoveryVmIpFinder 来定位问题。默认情况下,TcpDiscoveryMulticastIpFinder 会尝试扫描所有可用主机以发现 Ignite 节点,这可能需要一段时间,具体取决于超时时间。

假设您的两个节点仍在同一台机器上运行,您可能会保留 localhost 配置:“127.0.0.1:47500..47509”。如果 DNS 名称“server1.com”解析为正确的 IP 地址,“server1.com:47500..47509”也应该工作,这是检查它的最佳方法 - 只需运行 ping 命令来检查 localhost 和 server1.com 的情况正在解决。

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

如果有许多不同的接口可用,还建议检查端口是否打开,并且可能明确配置 localHost

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。