使用版本
flume1.9.0
http://www.apache.org/dyn/closer.lua/flume/1.9.0/apache-flume-1.9.0-bin.tar.gz
flume安裝
flume環(huán)境準(zhǔn)備
jdk 1.7+
jdk環(huán)境配置
解壓flume到D盤根目錄,添加系統(tǒng)環(huán)境變量 FLUME_HOME = D:\apache-flume-1.9.0-bin(flume所在目錄)
Path添加 %FLUME_HOME%\conf;%FLUME_HOME%\bin;
進(jìn)入flume中的conf文件夾镜撩,復(fù)制一份flume-env.sh.template文件约巷,命名為flume-env.sh,修改java路徑
export JAVA_HOME=C:\Program Files\Java\jdk1.8.0_162
在conf目錄下新增example.conf文件,將配置寫入其中(也可以使用官方配置文件比被,官方配置文件flume讀取數(shù)據(jù)源類型為netcat芯丧,數(shù)據(jù)源為 loaclhost:4444,這里我是指定文件夾讀取日志數(shù)據(jù))
# example.conf: A single-node Flume configuration
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = spooldir
a1.sources.r1.spoolDir = /test/flumeSpool
a1.sources.r1.fileHeader = true
# Describe the sink
a1.sinks.k1.type = logger
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
a1.sources.r1.type = spooldir,flume 讀取的數(shù)據(jù)文件類型: spooldir = 指定文件褐望,
a1.sources.r1.spoolDir = /test/flumeSpool 指定讀取文件夾的路徑
并在該路徑下創(chuàng)建相應(yīng)的文件夾。
修改log4j日志輸出方式串前,修改confi目錄下的flume.root.logger為
-flume.root.logger=INFO,console
在flume/conf目錄下 shift + 右鍵 打開命令面板,輸入命令啟動(dòng)flume
flume-ng agent --conf ../conf --conf-file example.conf --name a1
flume-ng agnet --conf "配置文件文件目錄相對(duì)路徑或絕對(duì)路徑" --conf-file "配置文件" --name "配置文件里agent的名字"
往/test/flumeSpool文件夾中添加日志文件瘫里,注意,添加荡碾,不是新建
查看D:\apache-flume-1.9.0-bin\conf\logs文件夾內(nèi)的日志
flume安裝測(cè)試完成