HBase数据同步到ElasticSearch的方案
ElasticSearch的River机制
ElasticSearch自身提供了一个River机制,用于同步数据。
这里能够找到官方眼下推荐的River:
http://www.elasticsearch.org/guide/en/elasticsearch/rivers/current/
可是官方没有提供HBase的River。
事实上ES的River很easy,就是一个用户打包好的jar包,ES负责找到一个node,并启动这个River。假设node失效了。会自己主动找另外一个node来启动这个River。
public interface RiverComponent {
RiverName riverName();
}
public interface River extends RiverComponent {
/**
* Called whenever the river is registered on a node, which can happen when:
* 1) the river _meta document gets indexed
* 2) an already registered river gets started on a node
*/
void start();
/**
* Called when the river is closed on a node, which can happen when:
* 1) the river is deleted by deleting its type through the delete mapping api
* 2) the node where the river is allocated is shut down or the river gets rerouted to another node
*/
void close();
}
Elasticsearch-HBase-River
github上有两个相关的项目:
https://github.com/mallocator/Elasticsearch-HBase-River
这个项目事实上非常easy。在River里用定时器启动一个HBase的Scanner,去扫描数据,并把数据插到ES里。
和自己手动写代码去扫描差点儿相同。
https://github.com/posix4e/Elasticsearch-HBase-River
这个项目利用了HBase的Replication机制。模拟了一个Hbase Replication的结点,然后同步数据到ES里。
可是这个项目是基于Hbase0.94的,实现的功能有限。
Hbase0.94和HBase0.98 的API变化非常大,基本不可用,并且作者也说了不能用于生产环境。
HBase的Relication机制
能够參考官方文档和cloudera的一些博客文章:
http://hbase.apache.org/book.html#cluster_replication
http://blog.cloudera.com/blog/2012/07/hbase-replication-overview-2/
HBase的Relication机制,事实上和Mysql的同步机制非常像,HBase的每一个Region Server都会有WAL Log,当Put/Delete时。都会先写入到WAL Log里。然后后台有线程会把WAL Log随机发给Slave的Region Server。而Slave的Region Server会在zookeeper上记录自己同步到的位置。
HBase同步数据到Solr的方案:Lily HBase Indexer
Cloudera内置的Cloudera Search实际上就是这个Lily Hbase Indexer:
https://github.com/NGDATA/hbase-indexer
这个项目就是利用了HBase的Replication功能,把HBase数据改动(Put。Delete)都抽像成为一系列Event,然后就能够同步到Solr里了。
这个项目抽象出了一个子项目:HBase Side-Effect Processor。
https://github.com/NGDATA/hbase-indexer/blob/master/hbase-sep/README.md
让用户能够自己写Listener来处理Event。
HBase数据同步到ElasticSearch的终于方案
考虑了上面的东东。所以决定基于HBase Side-Effect Processor。来自己写简单的程序同步数据到ES里。
事实上代码是很easy的。參考下Demo里的LoggingConsumer就好了。
https://github.com/NGDATA/hbase-indexer/blob/master/hbase-sep/hbase-sep-demo/src/main/java/com/ngdata/sep/demo/LoggingConsumer.java
private static class EventLogger implements EventListener {
@Override
public void processEvents(List<SepEvent> sepEvents) {
for (SepEvent sepEvent : sepEvents) {
System.out.println("Received event:");
System.out.println(" table = " + Bytes.toString(sepEvent.getTable()));
System.out.println(" row = " + Bytes.toString(sepEvent.getRow()));
System.out.println(" payload = " + Bytes.toString(sepEvent.getPayload()));
System.out.println(" key values = ");
for (KeyValue kv : sepEvent.getKeyValues()) {
System.out.println(" " + kv.toString());
}
}
}
}
其他的一些东东:
ElasticSearch 和Solr cloud的比較
从网上找到的帖子,讨论比較多的是12年,貌似后面就比較少了。
https://github.com/superkelvint/solr-vs-elasticsearch
http://stackoverflow.com/questions/2271600/elasticsearch-sphinx-lucene-solr-xapian-which-fits-for-which-usage
http://www.quora.com/Why-Cloudera-search-is-built-on-Solr-and-not-Elasticsearch Cloudera-Search为什么选择Solr而不是ElasticSearch
个人倾向于ElasticSearch,由于从流行度来看。ES正在超越solr cloud:
Logstash + ElasticSearch + Kibana的完整日志收集分析工具链,也有非常多公司在用。
HBase数据同步到ElasticSearch的方案的更多相关文章
- HBase数据同步ElasticSearch该程序
ElasticSearch的River机械 ElasticSearch本身就提供了River机械,对于同步数据. 在这里,现在能找到的官方推荐River: http://www.elasticsear ...
- 几篇关于MySQL数据同步到Elasticsearch的文章---第一篇:Debezium实现Mysql到Elasticsearch高效实时同步
文章转载自: https://mp.weixin.qq.com/s?__biz=MzI2NDY1MTA3OQ==&mid=2247484358&idx=1&sn=3a78347 ...
- SQL数据同步到ElasticSearch(三)- 使用Logstash+LastModifyTime同步数据
在系列开篇,我提到了四种将SQL SERVER数据同步到ES中的方案,本文将采用最简单的一种方案,即使用LastModifyTime来追踪DB中在最近一段时间发生了变更的数据. 安装Java 安装部分 ...
- hbase数据备份或者容灾方案
HBase的数据备份或者容灾方案有这几种:Distcp,CopyTable,Export/Import,Snapshot,Replication,以下分别介绍(以下描述的内容均是基于0.94.20版本 ...
- 几篇关于MySQL数据同步到Elasticsearch的文章---第五篇:logstash-input-jdbc实现mysql 与elasticsearch实时同步深入详解
文章转载自: https://blog.csdn.net/laoyang360/article/details/51747266 引言: elasticsearch 的出现使得我们的存储.检索数据更快 ...
- 几篇关于MySQL数据同步到Elasticsearch的文章---第三篇:logstash_output_kafka:Mysql同步Kafka深入详解
文章转载自: https://mp.weixin.qq.com/s?__biz=MzI2NDY1MTA3OQ==&mid=2247484411&idx=1&sn=1f5a371 ...
- kettle数据同步的5中方案
数据同步:当数据源发生改变时,其他相关数据也跟着发展变化.根据需求不同可采取以下方案.1.触发器:在数据库建立增删改的触发器.触发器将变更放到一张临时表里.oracle同步cdc优点:实时同步缺点:影 ...
- mysql数据同步到Elasticsearch
1.版本介绍 Elasticsearch: https://www.elastic.co/products/elasticsearch 版本:2.4.0 Logstash: https://www ...
- 几篇关于MySQL数据同步到Elasticsearch的文章---第四篇:使用go-mysql-elasticsearch同步mysql数据库信息到ElasticSearch
文章转载自: https://www.cnblogs.com/dalaoyang/p/11018541.html 1.go-mysql-elasticsearch简介 go-mysql-elastic ...
随机推荐
- [LeetCode] Binary Tree Inorder Traversal 中序排序
Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tre ...
- (十)stm32 GPIO口复用,重映射 RCC_APB2Periph_AFIO
什么时候需要用到RCC_APB2Periph_AFIO--复用IO时钟的使用 需要用到外设的重映射功能时才需要使能AFIO的时钟 外部中断(EXTI)中与AFIO有关的寄存器是AFIO-EXTICR1 ...
- centos7使用tomcat部署javaweb项目
1.下载二进制安装包 tomcat下载地址 2.下载jdk和配置环境变量 这里就不再多描述不清楚,可以 参考 我的yum安装的jdk 3.在centos7下安装 tomcat #切换到/u ...
- poj 1375(解析几何)
Intervals Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4292 Accepted: 1288 Descrip ...
- 第一章:1-11、在上题的分组交换网中,设报文长度和分组长度分别为x和(p+h)(bit),其中p为分组的数据部分的长度,而h为每个分组所带的控制信息固定长度,与p的大小无关。通信的两端共经过k段链路。链路的数据率为b(bit/s),但传播时延和结点的排队时间均可忽略不计。若打算使总的时延为最小,问分组的数据部分长度p应取为多大?
<计算机网络>谢希仁著第四版课后习题答案答: 分组个x/p, 传输的总比特数:(p+h)x/p 源发送时延:(p+h)x/pb 最后一个分组经过k-1个分组交换机的转发,中间发送时延:(k ...
- win2008通过计划任务定时执行bat文件
前段时间在Windows Server 2008安装了一套基于MySQL数据库的软件,处于数据安全的考虑,希望每天能够自动进行数据库备份.我在别人脚本的基础上自己写了一个数据库备份的bat脚本,双击该 ...
- CodeForces 450B Jzzhu and Sequences 【矩阵快速幂】
Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, ple ...
- 网络爬虫框架Webmagic
1 谈谈网络爬虫 1.1 什么是网络爬虫 在大数据时代,信息的采集是一项重要的工作,而互联网中的数据是海量的,如果单纯靠人力进行信息采集,不仅低效繁琐,搜集的成本也会提高.如何自动高效地获取互联网中我 ...
- Google Kickstart Round E 2018 B. Milk Tea
太蠢了,,,因为初始化大数据没过,丢了10分,纪念一下这个错误 大概思路:先求出让损失值最小的排列,由已生成的这些排列,通过更改某一个位置的值,生成下一个最优解,迭代最多生成m+1个最优解即可,遍历求 ...
- Xamarin XAML语言教程使用使用Progress属性设置当前进度
Xamarin XAML语言教程使用使用Progress属性设置当前进度 开发者除了可以在XAML中使用Progress属性设置进度条的当前进度外,还可以在代码隐藏文件中使用Progress属性来设置 ...