Flume:sink.type=hive
Flume以Kafka为Source,以Hive为Sink进行数据转存。
业务背景:公司要求将某四川城市的卡口数据实时接入大数据平台中,历史数据可以通过Hive进行Load,也就是增量数据的对接问题。现场设备采集卡口的数据量在400万左右,不多。设备数据采集后由数据对接人员塞到Kafak中。
思路:由Flume读取Kafka中的原数据,可以直接存入Hive中,也可以写入HDFS,再由Hive外部表加载。由于第一种不需要开发代码,只需配置,故采用了第一种。
常见问题处理 :
1、缺少jar包,特别是hcatalog,antlr-runtime-3.4等;
2、batchSize,消费能力要合适Channel,不然会一直报错Failed;
3、Hive建表时需要配置事务,表名小写,这一类错误报错明显,可以相应改正 ;
4、Hive表中是否有数据,不能用“show create table”,直接看select
配置代码如下:
PS:
1、分区问题:不能直接使用Event Header中的TimeStamp,因为考虑到会有一定的延时,处于时间分界时段的数据会分区错误。需regex_extractor解析Body,获取PassTime字段,加入Header,以此分区。
2、过滤问题:某些数据车牌未正确识别,需过滤,使用拦截器。正则表达式使用 | 进行拼接。
server.sources = test_source
server.channels = test_channel
server.sinks = test_sink
# the source configuration of test_source
server.sources.test_source.type = org.apache.flume.source.kafka.KafkaSource
server.sources.test_source.kafka.topics = kakoudata
server.sources.test_source.kafka.consumer.group.id = groupj
server.sources.test_source.kafka.security.protocol = PLAINTEXT
server.sources.test_source.kafka.auto.offset.reset = smallest
server.sources.test_source.batchDurationMillis = 1000
server.sources.test_source.batchSize = 1000
server.sources.test_source.channels = test_channel
server.sources.test_source.interceptors = i1 i2
server.sources.test_source.interceptors.i1.type = regex_filter
server.sources.test_source.interceptors.i1.regex = [\u4e00-\u9fa5]{1}[A-Z]{1}[A-Z0-9]{5}|[\u4e00-\u9fa5]{1}[A-Z]{1}[A-Z0-9]{4}[\\u4e00-\\u9fa5]{1}|WJ[\u4e00-\u9fa5]{1}[A-Z0-9]{5}
server.sources.test_source.interceptors.i1.excludeEvents = false
server.sources.test_source.interceptors.i2.type = regex_extractor
server.sources.test_source.interceptors.i2.regex = (\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)
server.sources.test_source.interceptors.i2.serializers = s1 s2 s3
server.sources.test_source.interceptors.i2.serializers.s1.name = year
server.sources.test_source.interceptors.i2.serializers.s2.name = month
server.sources.test_source.interceptors.i2.serializers.s3.name = day
# the channel configuration of test_channel
server.channels.test_channel.type = memory
server.channels.test_channel.capacity = 10000
server.channels.test_channel.transactionCapacity = 1000
server.channels.test_channel.channlefullcount = 10
server.channels.test_channel.keep-alive = 3
server.channels.test_channel.byteCapacityBufferPercentage = 20
# the sink configuration of test_sink
server.sinks.test_sink.type = hive
server.sinks.test_sink.hive.metastore = thrift://192.168.95.42:21088
server.sinks.test_sink.hive.database = default
server.sinks.test_sink.hive.table = base_kkdata_invalid
server.sinks.test_sink.hive.txnsPerBatchAsk = 2
server.sinks.test_sink.hive.partition = %{year},%{month},%{day}
server.sinks.test_sink.useLocalTimeStamp = false
server.sinks.wulei_sink.hive.batchSize = 10
server.sinks.test_sink.serializer = JSON
server.sinks.test_sink.channel = test_channel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~我是L分割线...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hive见表语句:
create table test_wuleiname(id string, name string)
partitioned by (day string)
clustered by (id) into 2 buckets stored as orc
location '/user/hive/warehouse/test_hhh'
TBLPROPERTIES ('transactional'='true');
Flume:sink.type=hive的更多相关文章
- flume的sink写入hive表
flume的配置文件如下: a1.sources=r1 a1.channels=c1 a1.sinks=s1 a1.sources.r1.type=netcat a1.sources.r1.bind= ...
- flume sink两种类型 file_rool 自定义sing com.mycomm.MySink even if there is only one event, the event has to be sent in an array
mkdir /data/UnifiedLog/; cd /data/UnifiedLog/; wget http://mirror.bit.edu.cn/apache/flume/1.8.0/apac ...
- 自定义Flume Sink:ElasticSearch Sink
Flume Sink的目的是从Flume Channel中获取数据然后输出到存储或者其他Flume Source中.Flume Agent启动的时候,它会为每一个Sink都启动一个SinkRunner ...
- Flume启动报错[ERROR - org.apache.flume.sink.hdfs. Hit max consecutive under-replication rotations (30); will not continue rolling files under this path due to under-replication解决办法(图文详解)
前期博客 Flume自定义拦截器(Interceptors)或自带拦截器时的一些经验技巧总结(图文详解) 问题详情 -- ::, (SinkRunner-PollingRunner-Default ...
- Flume Sink Processors官网剖析(博主推荐)
不多说,直接上干货! Flume Sources官网剖析(博主推荐) Flume Channels官网剖析(博主推荐) Flume Channel Selectors官网剖析(博主推荐) Flume ...
- 将nginx搜集到的日志通过flume转到hive
背景介绍: Nginx为app打点数据,打点日志每小时滚动一次.目录结构如下 文件中的数据如下( cat -A 2019072414r.log 后的结果,-A为显示隐形的符号,下方^A为指定的分隔符. ...
- IDEA编译Flume Sink通不过解决方法
Build/Rebuild Project之后
- Flume监控指标项
配置监控 1.修改flume-env.sh export JAVA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmx ...
- flume 测试 hive sink
测试flume,将数据送到hive表中,首先建表. create table order_flume( order_id string, user_id string, eval_set string ...
随机推荐
- kubenets installation--ranchor-mesos
[kube-proxy]http://www.cnblogs.com/xuxinkun/p/5799986.html [flannel] 安装Flannel [root@master ~]# cd ~ ...
- Page10:Lyapunov稳定概念及判定定理[Linear System Theory]
内容包含连续和离散系统的Lyapunov稳定概念及其各种判别定理
- iOS中Block的用法,举例,解析与底层原理(这可能是最详细的Block解析)
1. 前言 Block:带有自动变量(局部变量)的匿名函数.它是C语言的扩充功能.之所以是拓展,是因为C语言不允许存在这样匿名函数. 1.1 匿名函数 匿名函数是指不带函数名称函数.C语言中,函数是怎 ...
- Lua 变量名词
UpValue Lua中的函数是一阶类型值(first-class value),定义函数就象创建普通类型值一样(只不过函数类型值的数据主要是一条条指令而已),所以在函数体中仍然可以定义函数.假设函数 ...
- DBGridEh使用指南改变边框颜色
DBGridEh使用指南 鹅倌0人评论422人阅读2012-08-06 15:17:59 1.设置表头,是否允许多表头,设置是否只读. dbgrdh1.TitleFont.Color:=clBlu ...
- LeetCode 557 Reverse Words in a String III 解题报告
题目要求 Given a string, you need to reverse the order of characters in each word within a sentence whil ...
- 《HTTP - 理解 Content-Type》
一:引言 在此之前先看一个小例子:(html 上传文件,服务端为PHP) <?php var_dump($_FILES);?> <!DOCTYPE html> <html ...
- 写出简洁的Python代码: 使用Exceptions(转)
add by zhj: 非常好的文章,异常在Python的核心代码中使用的非常广泛,超出一般人的想象,比如迭代器中,当我们用for遍历一个可迭代对象时, Python是如何判断遍历结束的呢?是使用的S ...
- php 数值类型
一.整形 1. 常见的整形 echo 1234; // 十进制数 echo -123; // 负数 echo 0123; // 八进制数 (等于十进制 83) echo 0x1A; // 十六进制数 ...
- vue-router利用url传递参数
app.vue <template> <div id="app"> <router-link to="/">home< ...