您好,登錄后才能下訂單哦!
服務端器配置兩個不同的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端不同
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。