flume的安装
1.找到flume的安装包并复制到/usr目录下
-
sudo cp flume-ng-1.6.0-cdh5.6.0.tar.gz /usr
2.解压缩
-
sudo tar -zxvf flume-ng-1.6.0-cdh5.6.0.tar.gz
3.更名成flume
-
sudo mv apache-flume-1.6.0-cdh5.6.0-bin flume
4.修改权限为hadoop
-
sudo chown -R hadoop:hadoop flume
5.回到根目录下
- cd
6.更改bashrc文件
- vi .bashrc
添加以下内容:
export FLUME_HOME=/usr/flume
export FLUME_CONF=PATH:$FLUME_HOME/bin
7.保存bashrc文件
-
source .bashrc
8.修改flume-env.sh
进入cd /usr/flume/conf/ 目录下
发现没有flume-env.sh这个文件,将flume-env.sh.template复制并重新命名则得到这个文件
-
cp flume-env.sh.template flume-env.sh
打印Java环境变量所对应的值:
-
echo $JAVA_HOME
修改flume-env.sh这个文件:
-
vi flume-env.sh
加入以下内容:
export JAVA_HOME=/usr/jdk18
#Give Flume more memory and pre-allocate, enable remote monitoring via JMX
export JAVA_OPTS="-Xms100m -Xmx200m -Dcom.sun.management.jmxremote"
9.配置一个导入导出工程
首先配置一个导入flume_conf.conf文件
-
vi flume_conf.conf
添加内容:
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /home/hadoop/flume/log.log
# 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
10.新建一个文件并添加内容
11.启动flume
退到flume根目录下启动flume
./bin/flume-ng agent --conf ./conf --conf-file ./conf/flume_conf.conf --name a1 -Dflume.root.logger=INFO,console
12.在log.log文件下写东西,看flume端是否接收到
已经接收成功
(此文章仅作为个人学习笔记使用,如有错误欢迎指正~)