flume将日志到hive实现

科普:flume是apache下的一个日志收集系统,主要由source+channel+ sink组成:source可以看做是源,也就是日志的来源,本例子是用exec source;channel可以看做是中转的路,可以是文件也可以是内存;sink是输出,一般有hive sink,hbase sink,hdfs sink,avro sink。当然一个机器可以有多个source+channel+ sink。

资源: 172.16.6.152 node1 安装有flume+datanode

     172.16.6.151 master  安装有flume +hive+ namenode

思路:1.node1机器中使用exec source 执行tail -F /*/*.log获取日志的source,然后使用memory channel,然后使用avro传输至master

2.master中的flume 的souce是avro,接收node1机器所发送过来的数据,经过memory channel,最后使用hdfs sink写入hdfs中

3.由于本人水平有限,本来想直接在master中使用hive sink,无奈一直报hive class找不着的错误。所以就使用了另外一个损招,hive导入数据,是可以直接复制文件进入到hive表所对应的location中,所以就有了解决办法。

附上详细的设置:

1.flume安装,解压,然后修改配置文件conf/flume-env.sh 设置环境变量

2.node1节点,在conf目录下生成example4.conf文件,example4.conf文件内容如下


# Define a memory channel called ch1 on agent1
agent1.channels.ch1.type = memory
agent1.channels.ch1.capacity = 100000
agent1.channels.ch1.transactionCapacity = 100000
agent1.channels.ch1.keep-alive = 30
 
# Define an Avro source called avro-source1 on agent1 and tell it
# to bind to 0.0.0.0:41414. Connect it to channel ch1.
#agent1.sources.avro-source1.channels = ch1
#agent1.sources.avro-source1.type = avro
#agent1.sources.avro-source1.bind = 0.0.0.0
#agent1.sources.avro-source1.port = 41414
#agent1.sources.avro-source1.threads = 5
 
#define source monitor a file
agent1.sources.avro-source1.type = exec
agent1.sources.avro-source1.shell = /bin/bash -c
agent1.sources.avro-source1.command =  tail -F /opt/cdh5.3.0/hadoop/logs/hadoop-hadoop-namenode-node1.lo

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值