Flume将数据导入Hbase

时间:2024-03-16 19:25:54

Flume 将数据导入Hbase

1:创建.conf文件

#cd   /usr/tmp

#mkdir  flumesrc

#vim  netcat_to_hbase_user.conf

a1.sources=r1
a1.sinks=s1
a1.channels=c1

a1.sources.r1.type=netcat
a1.sources.r1.bind=master
a1.sources.r1.port=44444

a1.sinks.s1.type = hbase
a1.sinks.s1.table = user
a1.sinks.s1.columnFamily = i
a1.sinks.s1.serializer = org.apache.flume.sink.hbase.RegexHbaseEventSerializer

a1.channels.c1.type=memory
a1.channels.c1.capacity=1000
a1.channels.c1.transactionCapacity=100

a1.sources.r1.channels=c1
a1.sinks.s1.channel=c1


2:将hbase的8个jar包复制到flume安装目录的lib文件夹下

Flume将数据导入Hbase

3:运行.conf文件

#flume-ng agent -c conf -f  netcat_to_hbase_user.conf  --name a1 -Dflume.root.logger=INFO,console


4:进入hbase,创建表

hbase(main):022:0> create 'user','i'


5:操作flume,向hive输入数据

[[email protected] ~]# telnet master 44444
Trying 192.168.2.100...
Connected to master.
Escape character is '^]'.
guanyaqi
OK


6:查询Hbase的user表数据

#scan 'user'

Flume将数据导入Hbase