flume将数据导入hbase

匿名 (未验证) 提交于 2019-12-03 00:32:02

1 将hbase的lib目录下jar拷贝到flume的lib目录下;

2 在hbase中创建存储数据的表

hbase(main):002:0> create 'test_idoall_org','uid','name'

3 创建flume配置文件 vi.conf

a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /home/hadoop/data.txt
a1.sources.r1.port = 5555
a1.sources.r1.host = master
a1.sources.r1.channels = c1
# Describe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.type = hbase
a1.sinks.k1.table = test_idoall_org
a1.sinks.k1.columnFamily = name
a1.sinks.k1.column = idoall
a1.sinks.k1.serializer = org.apache.flume.sink.hbase.RegexHbaseEventSerializer
a1.sinks.k1.channel = memoryChannel
# 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

4 执行flume

flume-ng agent -c . -f conf/vi.conf -n a1 -Dflume.root.logger=INFO,console

5 创建导入文件

/home/hadoop/data.txt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!