[关闭]
@zhangyy 2017-05-04T18:00:05.000000Z 字数 1940 阅读 117

flume 监控hive日志文件

协作框架


  • flume 监控hive 日志文件

一: flume 监控hive的日志

  1. 1. 实时监控某个日志文件,将数据收集到存储hdfs 上面, 此案例使用exec source ,实时监控文件数据,使用Memory Channel 缓存数据,使用HDFS Sink 写入数据
  2. 2. 此案例实时监控hive 日志文件,放到hdfs 目录当中。
  3. hive 的日志目录是
  4. hive.log.dir = /home/hadoop/yangyang/hive/logs
  1. bin/hdfs dfs -mkdir /flume
  1. cd /home/hadoop/yangyang/hadoop/
  2. cp -p share/hadoop/hdfs/hadoop-hdfs-2.5.0-cdh5.3.6.jar /home/hadoop/yangyang/flume/lib/
  3. cp -p share/hadoop/common/hadoop-common-2.5.0-cdh5.3.6.jar
  4. /home/hadoop/yangyang/flume/lib/
  5. cp -p share/hadoop/tools/lib/commons-configuration-1.6.jar
  6. /home/hadoop/yangyang/flume/lib/
  7. cp -p share/hadoop/tools/lib/hadoop-auth-2.5.0-cdh5.3.6.jar /home/hadoop/yangyang/flume/lib/
  1. cp -p test-conf.properties hive-conf.properties

vim hive-conf.properties

  1. # example.conf: A single-node Flume configuration
  2. # Name the components on this agent
  3. a2.sources = r2
  4. a2.sinks = k2
  5. a2.channels = c2
  6. # Describe/configure the source
  7. a2.sources.r2.type = exec
  8. a2.sources.r2.command = tail -f /home/hadoop/yangyang/hive/logs/hive.log
  9. a2.sources.r2.bind = namenode01.hadoop.com
  10. a2.sources.r2.shell = /bin/bash -c
  11. # Describe the sink
  12. a2.sinks.k2.type = hdfs
  13. a2.sinks.k2.hdfs.path = hdfs://namenode01.hadoop.com:8020/flume/%Y%m/%d
  14. a2.sinks.k2.hdfs.fileType = DataStream
  15. a2.sinks.k2.hdfs.writeFormat = Text
  16. a2.sinks.k2.hdfs.batchSize = 10
  17. # 设置二级目录按小时切割
  18. a2.sinks.k2.hdfs.round = true
  19. a2.sinks.k2.hdfs.roundValue = 1
  20. a2.sinks.k2.hdfs.roundUnit = hour
  21. # 设置文件回滚条件
  22. a2.sinks.k2.hdfs.rollInterval = 60
  23. a2.sinks.k2.hdfs.rollsize = 128000000
  24. a2.sinks.k2.hdfs.rollCount = 0
  25. a2.sinks.k2.hdfs.useLocalTimeStamp = true
  26. a2.sinks.k2.hdfs.minBlockReplicas = 1
  27. # Use a channel which buffers events in memory
  28. a2.channels.c2.type = memory
  29. a2.channels.c2.capacity = 1000
  30. a2.channels.c2.transactionCapacity = 100
  31. # Bind the source and sink to the channel
  32. a2.sources.r2.channels = c2
  33. a2.sinks.k2.channel = c2
  1. bin/flume-ng agent --conf conf --conf-file conf/hive-conf.properties --name a2

image_1akbccbf11rja1ds21rf01rpa10bt9.png-38.5kB

  1. cd /home/hadoop/yangyang/hive/logs
  2. echo "111" >> hive.log
  3. 每隔一段时间执行上面的命令测试

image_1akbcgbfjofr1uqklrpdsh17ium.png-44.6kB

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注