簡體   English   中英

Apache 點燃嵌入式集群模式

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM