服務端器配置兩個不一樣的XML
example1.xml:
<bean abstract="true" id="ignite1.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="peerClassLoadingEnabled" value="true"/>
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="localPort" value="48500"/>
<property name="localPortRange" value="20"/>
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.zk.TcpDiscoveryZookeeperIpFinder">
<property name="zkConnectionString" value="192.168.33.12:2181"/>
<property name="basePath" value="/ignitecluster/cluster2"/>
</bean>
</property>
</bean>
</property>
<property name="communicationSpi">
<bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
<property name="localPort" value="48100"/>
</bean>
</property>
</bean>
example2.xml:
<bean abstract="true" id="ignite2.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="peerClassLoadingEnabled" value="true"/>
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="localPort" value="49500"/>
<property name="localPortRange" value="20"/>
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.zk.TcpDiscoveryZookeeperIpFinder">
<property name="zkConnectionString" value="192.168.33.12:2181"/>
<property name="basePath" value="/ignitecluster/cluster2"/>
</bean>
</property>
</bean>
</property>
<property name="communicationSpi">
<bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
<property name="localPort" value="49100"/>
</bean>
</property>
</bean>
使用TcpDiscoveryZookeeperIpFinder 能夠用同一個ZOOKEEPER實例,用不一樣的路徑區分集羣
ignite-zookeeper 是一個可選模塊,須要從libs/optional 下複製出來才能被IGNITE加入CLASSPATH
而後分別啓動
bin\ignite.bat examples\config\example1.xml
bin\ignite.bat examples\config\example2.xml
客戶端配置
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="persistentStoreConfiguration">
<bean class="org.apache.ignite.configuration.PersistentStoreConfiguration"/>
</property>
<property name="peerClassLoadingEnabled" value="true"/>
<property name="gridName" value="IgniteCache"/>
<property name="cacheConfiguration">
....
</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.zk.TcpDiscoveryZookeeperIpFinder">
<property name="zkConnectionString" value="192.168.33.12:2181"/>
<property name="basePath" value="/ignitecluster/cluster1"/>
</bean>
</property>
</bean>
</property>
<property name="communicationSpi">
<bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
<property name="localPort" value="48200"/>
</bean>
</property>
</bean>
<bean id="ignite.cfg1" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="persistentStoreConfiguration">
<bean class="org.apache.ignite.configuration.PersistentStoreConfiguration"/>
</property>
<property name="peerClassLoadingEnabled" value="true"/>
<property name="gridName" value="IgniteCache1"/>
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.zk.TcpDiscoveryZookeeperIpFinder">
<property name="zkConnectionString" value="192.168.33.12:2181"/>
<property name="basePath" value="/ignitecluster/cluster2"/>
</bean>
</property>
</bean>
</property>
<property name="communicationSpi">
<bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
<property name="localPort" value="49200"/>
</bean>
</property>
</bean>
Ignition.setClientMode(true);
Ignition.start("applicationContext-ignite.xml");
Ignite ignite1 = Ignition.ignite("IgniteCache");
Ignite ignite2 = Ignition.ignite("IgniteCache1");
本地配置須要有多個IgniteConfiguration, 每一個對應一個IGNITE集羣
每一個IgniteConfiguration 中的gridName不一樣, 對應不一樣的集羣名稱
客戶端ZookeeperIpFinder的鏈接字串和路徑和對應SERVER匹配
程序中有一個單例IGNITION 可是能夠有多個IGNITE實例,每一個的名字匹配IgniteConfiguration 中的gridName
注意:若是是本地啓動多臺SERVER,服務端須要爲每臺的discoverySpi 和 communicationSpi 配置LOCAL PORT
客戶端須要配置communicationSpi的LOCAL PORT,並且和SERVER端不一樣apache