Ignite集群管理-基于Zookeeper的节点发现
Ignite支持基于Multicast、StaticIP、Zookeeper、JDBC等的节点发现,本文主要介绍基于Zookeeper的节点发现。
准备环境,两台笔记本A、B,A笔记本上使用VMware虚拟机安装UbuntuC系统。
1.在C上安装Zookeeper。
由于Ignite主要是测试,这里我们只安装Zookeeper节点。下载Zookeeper并解压后,直接运行bin/。Zookeeper目录下的启动命令运行成功。
确保UbuntuC系统IP地址为192.168.1.104,默认Zookeeper端口为12181。
注意:VMware虚拟机的网络适配器必须是桥接模式,否则机器A将无法访问虚拟机。
2.系统A使用Ignite节点1;
代码中粗体部分是Ignite注册代码,非常简单。
r;;Cache;on;ode;导入onfiguration;导入Configuration;导入coverySpi;导入。coveryZookeeperIpFinder;/**
*
*eateonJun3,201710:52:38PM
*
*类函数说明:基于Zookeeper集群
*
*版权所有:Copyright(c)2013
*公司:COSHAHO
*@Version1.0
*@Authorcoshaho*/publicclassIgniteCluster01
{publicstaticvoidmain(String[]args)
{TcpDiscoverySpispi=newTcpDiscoverySpi();
TcpDiscoveryZookeeperIpFinderipFinder=newTcpDiscoveryZookeeperIpFinder();//指定ZooKeeperconnectionstring。
onnectionString("192.168.1.104:12181");
inder(ipFinder);
IgniteConfigurationcfg=newIgniteConfiguration();//覆盖默认的discoverySPI。coverySpi(spi);;
n("IgniteCluster1startOK.");
CacheConfiguration
kups(1);
heMode(IONED);
e("myCache");
IgniteCache
/>(1,"ignite1");
n((1));
n((2));
3.系统B运行Ignite2节点
r;。;导入Cache;导入on;导入ode;导入onfiguration;Configuration;coverySpi;coveryZookeeperIpFinder;publicclassIgniteCluster02
{publicstaticvoidmain(String[]args)
{
TcpDiscoverySpispi=newTcpDiscoverySpi();
TcpDiscoveryZookeeperIpFinderipFinder=newTcpDiscoveryZookeeperIpFinder();//指定ZooKeeper连接字符串。
onnectionString("192.168.1.104:12181");
inder(ipFinder);
IgniteConfigurationcfg=newIgniteConfiguration();//覆盖默认的discoverySPI。coverySpi(spi);
n("IgniteCluster2startOK.");
CacheConfiguration
kups(1);
/>heMode(IONED);
e("myCache");
IgniteCache
(2,"ignite2");
n((1));
n((2));
}
}
可以看到IgniteNode2可以成功访问Ignite1Node的缓存数据
上一篇:vmware虚拟机无法启动
下一篇:虚拟机启动