zoukankan      html  css  js  c++  java
  • flume的sink写入hive表

    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,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键
  • 相关阅读:
    springsecurity-微服务-springsecurity工具类封装
    springsecurity-微服务-认证授权的过程
    springsecurity-CSRF
    springsecurity-自动登录实现
    Vulnhub-靶机-DC: 9
    Xss-labs-level3-6
    靶机-生成自有账户和密码提权
    靶机-敲击相关方式汇总
    Vulnhub-靶机-DIGITALWORLD.LOCAL: BRAVERY
    Xss-labs-level1-2
  • 原文地址:https://www.cnblogs.com/zuizui1204/p/7800226.html
Copyright © 2011-2022 走看看