@zhangyy
2017-05-04T18:00:05.000000Z
字数 1940
阅读 117
协作框架
- flume 监控hive 日志文件
1. 实时监控某个日志文件,将数据收集到存储hdfs 上面, 此案例使用exec source ,实时监控文件数据,使用Memory Channel 缓存数据,使用HDFS Sink 写入数据
2. 此案例实时监控hive 日志文件,放到hdfs 目录当中。
hive 的日志目录是
hive.log.dir = /home/hadoop/yangyang/hive/logs
bin/hdfs dfs -mkdir /flume
cd /home/hadoop/yangyang/hadoop/
cp -p share/hadoop/hdfs/hadoop-hdfs-2.5.0-cdh5.3.6.jar /home/hadoop/yangyang/flume/lib/
cp -p share/hadoop/common/hadoop-common-2.5.0-cdh5.3.6.jar
/home/hadoop/yangyang/flume/lib/
cp -p share/hadoop/tools/lib/commons-configuration-1.6.jar
/home/hadoop/yangyang/flume/lib/
cp -p share/hadoop/tools/lib/hadoop-auth-2.5.0-cdh5.3.6.jar /home/hadoop/yangyang/flume/lib/
cp -p test-conf.properties hive-conf.properties
vim hive-conf.properties
# example.conf: A single-node Flume configuration
# Name the components on this agent
a2.sources = r2
a2.sinks = k2
a2.channels = c2
# Describe/configure the source
a2.sources.r2.type = exec
a2.sources.r2.command = tail -f /home/hadoop/yangyang/hive/logs/hive.log
a2.sources.r2.bind = namenode01.hadoop.com
a2.sources.r2.shell = /bin/bash -c
# Describe the sink
a2.sinks.k2.type = hdfs
a2.sinks.k2.hdfs.path = hdfs://namenode01.hadoop.com:8020/flume/%Y%m/%d
a2.sinks.k2.hdfs.fileType = DataStream
a2.sinks.k2.hdfs.writeFormat = Text
a2.sinks.k2.hdfs.batchSize = 10
# 设置二级目录按小时切割
a2.sinks.k2.hdfs.round = true
a2.sinks.k2.hdfs.roundValue = 1
a2.sinks.k2.hdfs.roundUnit = hour
# 设置文件回滚条件
a2.sinks.k2.hdfs.rollInterval = 60
a2.sinks.k2.hdfs.rollsize = 128000000
a2.sinks.k2.hdfs.rollCount = 0
a2.sinks.k2.hdfs.useLocalTimeStamp = true
a2.sinks.k2.hdfs.minBlockReplicas = 1
# Use a channel which buffers events in memory
a2.channels.c2.type = memory
a2.channels.c2.capacity = 1000
a2.channels.c2.transactionCapacity = 100
# Bind the source and sink to the channel
a2.sources.r2.channels = c2
a2.sinks.k2.channel = c2
bin/flume-ng agent --conf conf --conf-file conf/hive-conf.properties --name a2
cd /home/hadoop/yangyang/hive/logs
echo "111" >> hive.log
每隔一段时间执行上面的命令测试