實時監(jiān)控hive日志莉钙,并上傳到HDFS中
1易茬、拷貝Hadoop相關(guān)jar到flume的lib目錄下
(要學會根據(jù)自己的版本,查找jar包)
[victor@hadoop102 flume]$ find /opt/module/hadoop-2.8.2/ -name hadoop-auth*.jar
[victor@hadoop102 flume]$ cp hadoop-auth-2.8.2.jar ./lib/
[victor@hadoop102 flume]$ cp hadoop-common-2.8.2.jar ./lib/
[victor@hadoop102 flume]$ cp hadoop-hdfs-2.8.2.jar ./lib/
[victor@hadoop102 flume]$ cp hadoop-hdfs-client-2.8.2.jar ./lib/
[victor@hadoop102 flume]$ cp commons-configuration-1.6.jar ./lib/
[victor@hadoop102 flume]$ cp htrace-core-3.1.0-incubating.jar ./lib/
[victor@hadoop102 flume]$ cp commons-io-2.4.jar ./lib/
2、創(chuàng)建flume-hdfs.conf文件
# 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 /opt/module/apache-hive-1.2.1-bin/logs/hive.log
a2.sources.r2.shell = /bin/bash -c
# Describe the sink
a2.sinks.k2.type = hdfs
a2.sinks.k2.hdfs.path = hdfs://hadoop102:9000/flume/%Y%m%d/%H
#上傳文件的前綴
a2.sinks.k2.hdfs.filePrefix = logs-
#是否按照時間滾動文件夾
a2.sinks.k2.hdfs.round = true
#多少時間單位創(chuàng)建一個新的文件夾
a2.sinks.k2.hdfs.roundValue = 1
#重新定義時間單位
a2.sinks.k2.hdfs.roundUnit = hour
#是否使用本地時間戳
a2.sinks.k2.hdfs.useLocalTimeStamp = true
#積攢多少個Event才flush到HDFS一次
a2.sinks.k2.hdfs.batchSize = 1000
#設(shè)置文件類型结借,可支持壓縮
a2.sinks.k2.hdfs.fileType = DataStream
#多久生成一個新的文件
a2.sinks.k2.hdfs.rollInterval = 600
#設(shè)置每個文件的滾動大小
a2.sinks.k2.hdfs.rollSize = 134217700
#文件的滾動與Event數(shù)量無關(guān)
a2.sinks.k2.hdfs.rollCount = 0
#最小冗余數(shù)身冬, 此參數(shù)如果不設(shè)置成1衅胀,上面標紅失效
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
3、修改hive log日志地址
[victor@hadoop102 conf]$ cp hive-log4j.properties.template hive-log4j.properties
[victor@hadoop102 conf]$ vim hive-log4j.properties
hive.log.dir=/opt/module/apache-hive-1.2.1-bin/logs
4吏恭、執(zhí)行監(jiān)控配置
[victor@hadoop102 flume]$ bin/flume-ng agent --conf conf/ --name a2 --conf-file job/flume-hdfs.conf