1. 程式人生 > >flume的sink寫入hive表

flume的sink寫入hive表

ket support ted ets conf netca cti ren mem

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

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

a1.sinks.s1.type = hive
a1.sinks.s1.type.hive.metastore=thrift://master:9083
a1.sinks.s1.type.hive.datebase=bd14
a1.sinks.s1.type.hive.table=flume_user
a1.sinks.s1.serializer=DELIMITED
a1.sinks.s1.serializer.delimiter="\t"
a1.sinks.s1.serializer.serdeSeparator=‘\t‘
a1.sinks.s1.serializer.fieldnames=user_id,user_name,age

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

a1.sources.r1.channels = c1
a1.sink.s1.channel = c1
保存
運行flume-ng agent -c conf -f netcat_to_hive_user.conf --name a1
hive目錄-->hcatalog技術分享技術分享atalog/下面的架包拷貝到flume的lib裏面

在hive中
創建一張hive表 表名是flume_user,字段是user_id,user_name,age
create table flume_user(
user_id int
,user_name string
,age int
)
clustered by (user_id) into 2 buckets
stored as orc
tableproperties("transactional"=‘true‘)

set hive.support.concurrency=true
set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
select * from flume_user

打開一個連接 到服務器然後輸入 :
telnet localhost 44444
然後輸入 對應字符
1 tab鍵 王五 tab鍵 15 tab鍵

flume的sink寫入hive表