flume的配置文件如下:
a1.sources=r1 a1.channels=c1 a1.sinks=s1 a1.sources.r1.type=netcat a1.sources.r1.bind=master a1.sources.r1.port=44444 a1.sinks.s1.type=hive a1.sinks.s1.hive.metastore=thrift://master:9083 a1.sinks.s1.hive.database=bd14 a1.sinks.s1.hive.table=flume_user a1.sinks.s1.serializer=DELIMITED a1.sinks.s1.serializer.delimiter=" " a1.sinks.s1.serializer.serdeSeparator=' ' 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.sinks.s1.channel=c1
保存
运行flume-ng agent -c conf -f netcat_to_hive_user.conf --name a1
hive根目录下的/hcatalog/share/hcatalog文件夹中的如下三个文件夹添加到flume的lib目录下
-rw-r--r--. 1 root root 260425 Jun 17 2016 hive-hcatalog-core-2.1.0.jar -rw-r--r--. 1 root root 52709 Jun 17 2016 hive-hcatalog-pig-adapter-2.1.0.jar -rw-r--r--. 1 root root 55274 Jun 17 2016 hive-hcatalog-server-extensions-2.1.0.jar -rw-r--r--. 1 root root 121591 Jun 17 2016 hive-hcatalog-streaming-2.1.0.jar
在hive中
创建一张hive表 表名是flume_user,字段是user_id,user_name,agecreate 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键