您好,登录后才能下订单哦!
服务端器配置两个不同的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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。