需求:A B兩臺日志服務(wù)器實時生產(chǎn)日志主要類型為access.log、nginx.log、web.log,現(xiàn)在要求:
把A、B機器中的access.log、nginx.log、web.log 采集匯總到 C 機器上然后統(tǒng)一收集到 hdfs中,但是在hdfs中要求的目錄為:
/source/logs/access/日期/**
/source/logs/nginx/日期/**
/source/logs/web/日期/**
場景分析:
10年積累的成都網(wǎng)站設(shè)計、成都做網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)經(jīng)驗,可以快速應對客戶對網(wǎng)站的新想法和需求。提供各種問題對應的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認識你,你也不認識我。但先網(wǎng)站設(shè)計后付款的網(wǎng)站建設(shè)流程,更有高密免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
規(guī)劃:
hadoop01(web01):
source:access.log 、nginx.log、web.log
channel:memory
sink:avro
hadoop02(web02):
source:access.log 、nginx.log、web.log
channel:memory
sink:avro
hadoop03(數(shù)據(jù)收集):
source;avro
channel:memory
sink:hdfs
配置文件:
#exec_source_avro_sink.properties
#指定各個核心組件
a1.sources = r1 r2 r3
a1.sinks = k1
a1.channels = c1
#r1
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /home/hadoop/flume_data/access.log
a1.sources.r1.interceptors = i1
a1.sources.r1.interceptors.i1.type = static
a1.sources.r1.interceptors.i1.key = type
a1.sources.r1.interceptors.i1.value = access
#r2
a1.sources.r2.type = exec
a1.sources.r2.command = tail -F /home/hadoop/flume_data/nginx.log
a1.sources.r2.interceptors = i2
a1.sources.r2.interceptors.i2.type = static
a1.sources.r2.interceptors.i2.key = type
a1.sources.r2.interceptors.i2.value = nginx
#r3
a1.sources.r3.type = exec
a1.sources.r3.command = tail -F /home/hadoop/flume_data/web.log
a1.sources.r3.interceptors = i3
a1.sources.r3.interceptors.i3.type = static
a1.sources.r3.interceptors.i3.key = type
a1.sources.r3.interceptors.i3.value = web
#Describe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = hadoop03
a1.sinks.k1.port = 41414
#Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 20000
a1.channels.c1.transactionCapacity = 10000
#Bind the source and sink to the channela1.sources.r1.channels = c1
a1.sources.r2.channels = c1
a1.sources.r3.channels = c1
a1.sinks.k1.channel = c1
#avro_source_hdfs_sink.properties
#定義 agent 名, source、channel、sink 的名稱
a1.sources = r1
a1.sinks = k1
a1.channels = c1
#定義 source
a1.sources.r1.type = avro
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port =41414
#添加時間攔截器
a1.sources.r1.interceptors = i1
a1.sources.r1.interceptors.i1.type=org.apache.flume.interceptor.TimestampInterceptor$Builder
#定義 channels
a1.channels.c1.type = memory
a1.channels.c1.capacity = 20000
a1.channels.c1.transactionCapacity = 10000
#定義 sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path=hdfs://myha01/source/logs/%{type}/%Y%m%d
a1.sinks.k1.hdfs.filePrefix =events
a1.sinks.k1.hdfs.fileType = DataStream
a1.sinks.k1.hdfs.writeFormat = Text
#時間類型
a1.sinks.k1.hdfs.useLocalTimeStamp = true
#生成的文件不按條數(shù)生成
a1.sinks.k1.hdfs.rollCount = 0
#生成的文件按時間生成
a1.sinks.k1.hdfs.rollInterval = 30
#生成的文件按大小生成
a1.sinks.k1.hdfs.rollSize = 10485760
#批量寫入 hdfs 的個數(shù)
a1.sinks.k1.hdfs.batchSize = 20
#flume 操作 hdfs 的線程數(shù)(包括新建,寫入等)
a1.sinks.k1.hdfs.threadsPoolSize=10
#操作 hdfs 超時時間
a1.sinks.k1.hdfs.callTimeout=30000
#組裝 source、channel、sink
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
測試:
#在hadoop01和 hadoop02上的/home/hadoop/data 有數(shù)據(jù)文件 access.log、nginx.log、 web.log
#先啟動hadoop03上的flume:(存儲)
flume-ng agent -c conf -f avro_source_hdfs_sink.properties -name a1 -Dflume.root.logger=DEBUG,console
#然后在啟動hadoop01和hadoop02上的命令flume(收集)
flume-ng agent -c conf -f exec_source_avro_sink.properties -name a1 -Dflume.root.logger=DEBUG,console
分享名稱:flume實際生產(chǎn)場景分析
文章URL:http://jinyejixie.com/article0/gcecoo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、網(wǎng)站營銷、搜索引擎優(yōu)化、用戶體驗、定制網(wǎng)站、網(wǎng)站內(nèi)鏈
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)