1. 程式人生 > >flume將資料匯入hbase

flume將資料匯入hbase

1 將hbase的lib目錄下jar拷貝到flume的lib目錄下;

2 在hbase中建立儲存資料的表

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

3 建立flume配置檔案 vi.conf

a1.sources = r1a1.sinks = k1a1.channels = c1# Describe/configure the sourcea1.sources.r1.type = execa1.sources.r1.command = tail -F /home/hadoop/data.txta1.sources.r1.port = 5555
a1.sources.r1.host = mastera1.sources.r1.channels = c1# Describe the sinka1.sinks.k1.type = loggera1.sinks.k1.type = hbasea1.sinks.k1.table = test_idoall_orga1.sinks.k1.columnFamily = namea1.sinks.k1.column = idoalla1.sinks.k1.serializer = org.apache.flume.sink.hbase.RegexHbaseEventSerializera1.sinks.k1.channel = memoryChannel
# Use a channel which buffers events in memorya1.channels.c1.type = memorya1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 100# Bind the source and sink to the channela1.sources.r1.channels = c1a1.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