1. 下载apache-flume-1.8.0-bin.tar.gz
2. 上传到liunx中
3. 解压apache-flume-1.8.0-bin.tar.gz
tar -zxvf apache-flume-1.8.0-bin.tar.gz
4. 将apache-flume-1.8.0-bin名称改成 flume-1.8.0(可以不改)
mv apache-flume-1.8.0-bin flume-1.8.0
ls
4. 来到root用户下,添加环境变量
export FLUME_HOME=/home/hadoop/flume-1.8.0
export FLUME_CONF_DIR=$FLUME_HOME/conf
修改PATH,在后面增加:$FLUME_HOME/bin
5. 回到hadoop用户下,并来到conf目录
su hadoop
cd flume-1.8.0/
ls
cd conf
6. 复制flume-env.sh.template成flume-env.sh
复制flume-conf.properties.template成flume-conf.properties
ls
cp flume-env.sh.template flume-env.sh
cp flume-conf.properties.template flume-conf.properties
7. 修改flume-env.sh
export JAVA_HOME=/usr/java/jdk1.8.0_144
去掉export JAVA_OPTS的注释
8.修改flume-conf.properties(简单配置)
a1.sources = r1
a1.sinks = k1
a1.channels = c1
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444
a1.sources.r1.channels = c1
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
9.启动名为a1的agent
./bin/flume-ng agent --conf ./conf/ --conf-file ./conf/flume-conf.properties --name a1 -Dflume.root.logger=INFO,console
10. 测试能否正常监听使用,打开一个新的终端
telnet localhost 44444
hello world
注:使用以下的配置文件时,需要将主机名,用户进行修改,(如:grid修改为hadoop,Master修改为namenode)