使用flume将数据sink到HBase
===========>先创建Hbase表和列族<================
案例1:源数据一行对应Hbase的一列存储(hbase-1.12没有问题)
================================================================================
#说明:案例是flume监听目录/home/hadoop/flume_hbase采集到hbase;必须先在Hbase中创建表和列族
数据目录:
vi /home/hadoop/flume_hbase/word.txt
1001 pan nan
2200 lili nv
create 'tb_words','cf_wd'
vi flume-hbase.conf
#Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
#Describe/configure the source
a1.sources.r1.type = spooldir //当监控文件夹时,不用执行文件,只需在文件夹下有操作,就可监听到信息
a1.sources.r1.spoolDir=/home/hadoop/flume_hbase
# Describe the sink
a1.sinks.k1.type =asynchbase
a1.sinks.k1.table = tb_words
a1.sinks.k1.columnFamily = cf_wd
#目前自己处理到支持一个列名的,多个列名称失败了,多个列名考虑使用下面的案例的正则表达式方式匹配
a1.sinks.k1.serializer.payloadColumn=wd
a1.sinks.k1.serializer.incrementColumn=last
a1.sinks.k1.serializer.rowPrefix=QM
a1.sinks.k1.serializer.suffix=timestamp
a1.sinks.k1.serializer =org.apache.flume.sink.hbase.SimpleAsyncHbaseEventSerializer
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
案例2:使用正则表达式,对行分多个列值
说明:apache-flume-1.7.0-bin.tar.gz 和 Hbase-1.12+
================================================================================
create 'tb_words2','words'
数据目录:
vi /home/hadoop/flume_hbase/data.txt
1001,panzong,nan
2200,lili,nv
flume配置文件:
vi flume_2_hbase.conf
#Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
#Describe/configure the source
a1.sources.r1.type = cn.qm.flume.source.MySource //可更换为spooldir
a1.sources.r1.spoolDir=/home/hadoop/flume_hbase
# Describe the sink
#a1.sinks.k1.type =org.apache.flume.sink.hbase.HBaseSink
a1.sinks.k1.type =hbase
a1.sinks.k1.table = tb_words2
a1.sinks.k1.columnFamily = words
a1.sinks.k1.serializer.enableWal= true
a1.sinks.k1.serializer = org.apache.flume.sink.hbase.RegexHbaseEventSerializer
#查看RegexHbaseEventSerializer类源码,可以快速理解rowKeyIndex/colNames属性
a1.sinks.k1.serializer.regex= ^([0-9]+),([a-z]+),([a-z]+)$
# 指定某一列来当主键,而不是用随机生成的key,#第一列为Hbase的rowkey
#RegexHbaseEventSerializer 源码查看
a1.sinks.k1.serializer.rowKeyIndex =0
#ROW_KEY为系统指定列名
a1.sinks.k1.serializer.colNames= ROW_KEY,name,sex
a1.sinks.k1.zookeeperQuorum =hdp-qm-05:2181,hdp-qm-06:2181,hdp-qm-07:2181
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
#第二列为Hbase的rowkey
#a1.sinks.k1.serializer.rowKeyIndex = 1
#a1.sinks.k1.serializer.regex= ^([0-9]+),([a-z]+),([a-z]+)$
#a1.sinks.k1.serializer.colNames= id,ROW_KEY,sex
使用flume将数据sink到HBase的更多相关文章
- 使用flume将kafka数据sink到HBase【转】
1. hbase sink介绍 1.1 HbaseSink 1.2 AsyncHbaseSink 2. 配置flume 3. 运行测试flume 4. 使用RegexHbaseEventSeriali ...
- flume将数据发送到kafka、hdfs、hive、http、netcat等模式的使用总结
1.source为http模式,sink为logger模式,将数据在控制台打印出来. conf配置文件如下: # Name the components on this agent a1.source ...
- 大数据技术之HBase原理与实战归纳分享-下
@ 目录 整合Phoenix 定义 为何要使用 安装 SHELL操作 表的映射 简易JDBC示例 二级索引 二级索引配置文件 全局索引 包含索引 本地索引(local index) HBase与 Hi ...
- 大数据架构-使用HBase和Solr将存储与索引放在不同的机器上
大数据架构-使用HBase和Solr将存储与索引放在不同的机器上 摘要:HBase可以通过协处理器Coprocessor的方式向Solr发出请求,Solr对于接收到的数据可以做相关的同步:增.删.改索 ...
- HBase(三): Azure HDInsigt HBase表数据导入本地HBase
目录: hdfs 命令操作本地 hbase Azure HDInsight HBase表数据导入本地 hbase hdfs命令操作本地hbase: 参见 HDP2.4安装(五):集群及组件安装 , ...
- 《OD大数据实战》HBase整合MapReduce和Hive
一.HBase整合MapReduce环境搭建 1. 搭建步骤1)在etc/hadoop目录中创建hbase-site.xml的软连接.在真正的集群环境中的时候,hadoop运行mapreduce会通过 ...
- mongodb数据迁移到hbase
mongodb数据迁移到hbase 导入包 # encoding: utf-8 ''' @author: zcc @license: (C) Copyright 2013-2017, Node Sup ...
- hbase使用MapReduce操作4(实现将 HDFS 中的数据写入到 HBase 表中)
实现将 HDFS 中的数据写入到 HBase 表中 Runner类 package com.yjsj.hbase_mr2; import com.yjsj.hbase_mr2.ReadFruitFro ...
- Oracle数据迁移至HBase操作记录
Oracle数据迁移至HBase操作记录 @(HBase) 近期需要把Oracle数据库中的十几张表T级别的数据迁移至HBase中,过程中遇到了许多苦难和疑惑,在此记录一下希望能帮到一些有同样需求的兄 ...
- 分布式爬虫系统设计、实现与实战:爬取京东、苏宁易购全网手机商品数据+MySQL、HBase存储
http://blog.51cto.com/xpleaf/2093952 1 概述 在不用爬虫框架的情况,经过多方学习,尝试实现了一个分布式爬虫系统,并且可以将数据保存到不同地方,类似MySQL.HB ...
随机推荐
- Splashtop 教育行业用户增加700%
由于新冠肺炎大流行继续限制对大学.学院和K-12学校的计算机实验室的物理访问,Splashtop的销售数据表明,越来越多的学校开始使用远程访问软件作为使用计算机实验室资源的替代方法. 在6月到8月 ...
- C 语言编程 — 数据类型的别名
目录 文章目录 目录 前文列表 typedef 关键字 typedef 和预处理器指令 #define 的区别 前文列表 <程序编译流程与 GCC 编译器> <C 语言编程 - 基本 ...
- ASP.NET Core如何禁用模型验证(或者从模型状态中移除某些属性)?
这是一篇4年前的文章:[经验分享]在ASP.NET Core中,如果禁用某个请求的模型验证? 事隔多年,又有网友问到这个问题.我就来重新整理一下,顺便扩展一下之前的解决办法. ===== 这是一个来自 ...
- java学习之旅(day.12)
异常机制(Exception) 异常指程序运行中出现的不期而至的各种状况 异常分类: 检查性异常:用户输入错误引起的异常 运行时异常:写的时候未报错,但一运行就会报错, 错误(error):错误不是异 ...
- Vue 3 组件基础与模板语法详解
title: Vue 3 组件基础与模板语法详解 date: 2024/5/24 16:31:13 updated: 2024/5/24 16:31:13 categories: 前端开发 tags: ...
- swagger 的配置
1,开启swagger : c.IncludeXmlComments(GetXmlCommentsPath()); protected static string GetXmlCommentsPath ...
- vue2前端导出带背景色表格 xlsx xlsx-style
vue2 +elmentui+xlsx10.0.0+xlsx-style 坑有点多. xlsx10.0.0以后的版本 用require导入或者使用什么导入什么,不要import * xlsx全部导入 ...
- 对比使用IConfigurationSectionHandler和ConfigurationSection自定义节点和自定义处理程序
使用自定义处理程序处理节点的好处我认为是,可以在业务代码中,不必再写一些读取配置文件的非业务代码了,只管取值.如果多处使用该配置节点,其优势更能体现出来.然后突然要增删配置,也只管改节点处理程序的代码 ...
- Python OpenCV #1 - OpenCV介绍
一.OpenCV介绍 1.1 OpenCV-Python教程简介 OpenCV由 Gary Bradsky 于1999年在英特尔创立,第一个版本于2000年发布. Vadim Pisarevsky 加 ...
- Vue——Ajax请求的基本使用
1.get方法发送Ajax请求 // 直接在 URL 上添加参数 ID=12345 axios.get('/user?ID=12345') .then(function (response) { co ...