Ignite支持基于组播,静态IP,Zookeeper,JDBC等方式发现节点,本文主要介绍基于Zookeeper的节点发现。

环境准备,两台笔记本电脑A,B。A笔记本上使用VMware虚拟机安装了Ubuntu系统C。

1、 C安装Zookeeper

由于主要测试Ignite,这里仅仅简单安装一个zookeeper节点,下载zookeeper解压后,直接执行zookeeper目录下的bin/zkServer.sh start命令则成功启动zookeeper。

查看Ubuntu系统C的IP地址为192.168.1.104,zookeeper默认端口为12181。

注意:这里VMware虚拟机的网络适配器一定要选择桥接模式,否则A机器无法访问虚拟机。

2、 A系统运行Ignite节点1;

代码中加粗的部分便是Ignite注册代码,十分简单。

package com.coshaho.learn.ignite.cluster;

import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.zk.TcpDiscoveryZookeeperIpFinder; /**
*
* IgniteCluster01.java Create on 2017年6月3日 下午10:52:38
*
* 类功能说明: 基于zookeeper集群
*
* Copyright: Copyright(c) 2013
* Company: COSHAHO
* @Version 1.0
* @Author coshaho
*/
public class IgniteCluster01
{
public static void main(String[] args)
{
TcpDiscoverySpi spi = new TcpDiscoverySpi();
TcpDiscoveryZookeeperIpFinder ipFinder = new TcpDiscoveryZookeeperIpFinder();
// Specify ZooKeeper connection string.
ipFinder.setZkConnectionString("192.168.1.104:12181");
spi.setIpFinder(ipFinder);
IgniteConfiguration cfg = new IgniteConfiguration();
// Override default discovery SPI.
cfg.setDiscoverySpi(spi);
// Start Ignite node.
Ignite ignite =
Ignition.start(cfg);
System.out.println("IgniteCluster1 start OK.");
CacheConfiguration<Integer, String> cacheCfg = new CacheConfiguration<Integer, String>();
cacheCfg.setBackups(1);
cacheCfg.setCacheMode(CacheMode.PARTITIONED);
cacheCfg.setName("myCache");
IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cacheCfg);
cache.put(1, "ignite1");
System.out.println(cache.get(1));
System.out.println(cache.get(2));
}
}

3、 B系统运行Ignite节点2;

package com.coshaho.learn.ignite.cluster;

import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.zk.TcpDiscoveryZookeeperIpFinder; public class IgniteCluster02
{
public static void main(String[] args)
{
TcpDiscoverySpi spi = new TcpDiscoverySpi();
TcpDiscoveryZookeeperIpFinder ipFinder = new TcpDiscoveryZookeeperIpFinder();
// Specify ZooKeeper connection string.
ipFinder.setZkConnectionString("192.168.1.104:12181");
spi.setIpFinder(ipFinder);
IgniteConfiguration cfg = new IgniteConfiguration();
// Override default discovery SPI.
cfg.setDiscoverySpi(spi);
// Start Ignite node.
Ignite ignite =Ignition.start(cfg);
System.out.println("IgniteCluster2 start OK.");
CacheConfiguration<Integer, String> cacheCfg = new CacheConfiguration<Integer, String>();
cacheCfg.setBackups(1);
cacheCfg.setCacheMode(CacheMode.PARTITIONED);
cacheCfg.setName("myCache");
IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cacheCfg);
cache.put(2, "ignite2");
System.out.println(cache.get(1));
System.out.println(cache.get(2));
}
}

可以看到,Ignite节点2可以成功访问到Ignite节点1存入缓存的数据。

Ignite集群管理——基于Zookeeper的节点发现的更多相关文章

  1. Ignite集群管理——基于静态IP的节点发现

    Ignite作为分布式内存,集群管理必不可少,Ignite支持基于组播,静态IP,Zookeeper,JDBC等方式发现节点,本文主要介绍基于静态IP的节点发现. 两个最重要的TCP通信设置类: 1. ...

  2. Elasticsearch集群问题,导致主master节点发现不了node节点

    个人博客:https://blog.sharedata.info/ 最新需要配置es集群采用5个分片和1个副片,正好是11台机器,而只保留一份备份所以只需要5*2=10台机器方案:1.1台作为mast ...

  3. SolrCloud集群搭建(基于zookeeper)

    1. 环境准备 1.1 三台Linux机器,x64系统 1.2 jdk1.8 1.3 Solr5.5 2. 安装zookeeper集群 2.1 分别在三台机器上创建目录 mkdir /usr/hdp/ ...

  4. 2 weekend110的zookeeper的原理、特性、数据模型、节点、角色、顺序号、读写机制、保证、API接口、ACL、选举、 + 应用场景:统一命名服务、配置管理、集群管理、共享锁、队列管理

    在hadoop生态圈里,很多地方都需zookeeper. 启动的时候,都是普通的server,但在启动过程中,通过一个特定的选举机制,选出一个leader. 只运行在一台服务器上,适合测试环境:Zoo ...

  5. 基于zookeeper+mesos+marathon的docker集群管理平台

    参考文档: mesos:http://mesos.apache.org/ mesosphere社区版:https://github.com/mesosphere/open-docs mesospher ...

  6. zookeeper安装和应用场合(名字,配置,锁,队列,集群管理)

    安装和配置详解 本文介绍的 Zookeeper 是以 3.2.2 这个稳定版本为基础,最新的版本可以通过官网http://hadoop.apache.org/zookeeper/ 来获取,Zookee ...

  7. 一步到位分布式开发Zookeeper实现集群管理

    说到分布式开发Zookeeper是必须了解和掌握的,分布式消息服务kafka .hbase 到hadoop等分布式大数据处理都会用到Zookeeper,所以在此将Zookeeper作为基础来讲解. Z ...

  8. 搞懂分布式技术5:Zookeeper的配置与集群管理实战

    搞懂分布式技术5:Zookeeper的配置与集群管理实战 4.1 配置文件 ZooKeeper安装好之后,在安装目录的conf文件夹下可以找到一个名为“zoo_sample.cfg”的文件,是ZooK ...

  9. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:3.安装Oracle RAC-3.6.集群管理命令

    3.6. 集群管理命令 3.6.1. RAC的启动与关闭 oracle rac默认会开机自启动,如需维护时可使用以下命令: 关闭: crsctl stop cluster 停止本节点集群服务 crsc ...

随机推荐

  1. 【CF884F】Anti-Palindromize 费用流

    [CF884F]Anti-Palindromize 题意:定义一个串是反回文的,当且仅当对于1<=i<=len,$a_i!=a_{len-i+1}$. 现在给出一个长度为n的串S(n是偶数 ...

  2. 转利用python实现电影推荐

    “协同过滤”是推荐系统中的常用技术,按照分析维度的不同可实现“基于用户”和“基于产品”的推荐. 以下是利用python实现电影推荐的具体方法,其中数据集源于<集体编程智慧>一书,后续的编程 ...

  3. POJ-1952 BUY LOW, BUY LOWER(线性DP)

    BUY LOW, BUY LOWER Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 9244 Accepted: 3226 De ...

  4. Pycharm中如何使用科学计算库

    1.简便起见 比起麻烦的安装各种库,我们选择最方便的Anaconda的conda或pip(兼容支持)安装相关库. Pycharm本身缺少numpy和matplotlib这些库,而另一个Python的开 ...

  5. POJ 1986 - Distance Queries - [LCA模板题][Tarjan-LCA算法]

    题目链接:http://poj.org/problem?id=1986 Description Farmer John's cows refused to run in his marathon si ...

  6. web移动端开发经验总结

    整理web移动端开发经验,部分内容借鉴于网上的博文. 1.meta标签 <meta name="viewport" content="width=device-wi ...

  7. Simple Mail Transfer Protocol

    https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol https://zh.wikipedia.org/wiki/简单邮件传输协议 & ...

  8. [python-opencv]模板匹配

    模板匹配最适用于工业场合(在一张图片中识别特定的工件图) 模板匹配是一种最原始.最基本的模式识别方法,研究某一特定对象物的图案位于图像(target)的什么地方,进而识别对象物,这就是一个匹配问题. ...

  9. 流媒体ts/ps流封装/分析

    1.TS 1) 感谢星辰同学,还热乎着,

  10. SQLyog恢复数据库报错解决方法【Error Code: 2006 - MySQL server has gone away】

    https://blog.csdn.net/niqinwen/article/details/8693044 导入数据库的时候 SQLyog 报错了 Error Code: 2006 – MySQL ...