Mac安装Flume
一、下载Flume(在SoftWare目录下)
wget http://mirrors.tuna.tsinghua.edu.cn/apache/flume/1.8.0/apache-flume-1.8.0-bin.tar.gz
二、解压
tar -zxf apache-flume-1.8.0-bin.tar.gz
三、修改配置文件
【1】修改flume-env.sh
cd /Users/mac/SoftWare/apache-flume-1.8.0/conf
cp flume-env.sh.template flume-env.sh
vim flume-env.sh
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
export JAVA_OPTS="-Xms100m -Xmx2000m -Dcom.sun.management.jmxremote"
【2】修改flume-conf.properties
cp flume-conf.properties.template flume-conf.properties
【3】修改vim ~/.bash_profile
添加
export FLUME_HOME=/Users/mac/SoftWare/flume-1.8.0
export PATH="${FLUME_HOME}:${PATH}"
source ~/.bash_profile
四、配置文件
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = syslogtcp
a1.sources.r1.port = 8082
a1.sources.r1.host = localhost
a1.sources.r1.channels = c1
# 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
使用方式
启动flume代理
bin/flume-ng agent -c ./conf/ -f ./conf/syslogtcp.conf -n a1 -Dflume.root.logger=INFO,console
【2】监测文件为数据源,发送给kafka
vim kafka.properties
agent.sources = s1
agent.channels = c1
agent.sinks = k1
agent.sources.s1.type=exec
#日志采集位置
agent.sources.s1.command=tail -F /Users/mac/SoftWare/flume-1.8.0/test/test.log
agent.sources.s1.channels=c1
agent.channels.c1.type=memory
agent.channels.c1.capacity=10000
agent.channels.c1.transactionCapacity=100
agent.sinks.k1.type= org.apache.flume.sink.kafka.KafkaSink
#kafka 地址
agent.sinks.k1.brokerList=172.23.75.105:9092
#kafka topic
agent.sinks.k1.topic=robots2
agent.sinks.k1.serializer.class=kafka.serializer.StringEncoder
agent.sinks.k1.channel=c1

浙公网安备 33010602011771号