目标
监听hive日志,并上传到hdfs中/flume/[YYMMDDHH]/目录下,文件前缀为logs-,每一个小时新建重新创建一个文件夹,每接收10M数据落地一次,当数据不足10M时15分钟落地一次
导入相关依赖jar包
导入以下jar包到flume路径下的lib里,{}里为相应版本,在hadoop路径下share/hadoop下都能找到,我就添加了一个剩下的在flume/lib下都已经有了,以防万一还是都添加一下试试
commons.configuration-{}.jar
hadoop-auth-{}.jar
hadoop-common-{}.jar
hadoop-hdfs-{}.jar
commons-io-{}.jar
htrace-core-{}-incubating.jar
编写配置文件
在flume路径下的job路径中新建flume-file-hdfs.conf
touch /apps/flume/job/flume-file-hdfs.conf
此文件编写内容如下
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the sources
# exec即execute执行命令
a1.sources.r1.type = exec
# 要执行的命令
a1.sources.r1.command = tail -F /tmp/root/hive.log
# 执行shell脚本的绝对路径
a1.sources.r1.shell = /bin/bash -c
# Describe the sink
a1.sinks.k1.type = hdfs
# 上传到hdfs的路径
a1.sinks.k1.hdfs.path = hdfs://192.168.1.10