1.没有详细概念
2.搭建flume环境
2.使用flume监控文件上传至hdfs
1.flume 安装包可以从下面进行下载
链接:http://pan.baidu.com/s/1ntH6I1N 密码:czbp
2.通过ftp上传至Linux
3.解压安装文件(cd /usr/local/):
tar zxvf apache-flume-1.5.0-bin.tar.gz
tar zxvf apache-flume-1.5.0-src.tar.gz
src里面文件内容,覆盖解压后bin文件里面的内容
cp -rf apache-flume-1.5.0-src/* apache-flume-1.5.0-bin
这里会有些确认信息,不出现提示的配置如下
[root@hadoop01 ~]# cat ~/.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
#alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
注释掉alias cp='cp -i' 平时执行的cp 其实执行的是cp -i 然后重新登陆即可 覆盖且不提示
重新命名:mv apache-flume-1.5.0-bin/ flume
添加环境变量:
[root@hadoop01 ~]# cd /etc/profile.d/
[root@hadoop01 profile.d]# vi flume.sh
export FLUME_HOME=/usr/local/flume
export PATH=.:$FLUME_HOME/bin:$PATH
进入flume的配置文件下建立配置文件:
[root@hadoop01 profile.d]# vi /usr/local/flume/conf/example.conf
#agent1
agent1.sources=source1
agent1.sinks=sink1
agent1.channels=channel1
#source1
agent1.sources.source1.type=spooldir
agent1.sources.source1.spoolDir=/flumelog #flume监控的目录
agent1.sources.source1.channels=channel1
agent1.sources.source1.fileHeader = false
#sink1
agent1.sinks.sink1.type=hdfs
agent1.sinks.sink1.hdfs.path=hdfs://192.168.135.1:9000/flumelog #上传到hdfs目录
agent1.sinks.sink1.hdfs.fileType=DataStream
agent1.sinks.sink1.hdfs.writeFormat=TEXT
agent1.sinks.sink1.hdfs.rollInterval=4
agent1.sinks.sink1.channel=channel1
#channel1
agent1.channels.channel1.type=file
agent1.channels.channel1.checkpointDir=/usr/flumelog1
agent1.channels.channel1.dataDirs=/usr/flumelogdata
启动:
[root@hadoop01 profile.d]# cd /usr/local/flume/
[root@hadoop01 profile.d]# bin/flume-ng agent -c conf -f conf/example.conf --n agent1 -Dflume.root.logger=INFO,console
会循环输出(监控目录):
2015-11-11 07:19:05,104 (pool-4-thread-1) [INFO - org.apache.flume.source.SpoolDirectorySource$SpoolDirectoryRunnable.run(SpoolDirectorySource.java:254)] Spooling Directory Source runner has shutdown
#不要关闭这个窗口 打开另一个窗口 执行下面操作
测试向监控目录上新建文件:
[root@hadoop01 flumelog]# vi test1
we are family
查看窗口1变化
验证是否上传成功:
[root@hadoop01 aboutyunlog]# hadoop fs -ls /aboutyunlog
-rw-r--r-- 2 root supergroup 32 2015-11-11 06:55 /aboutyunlog/FlumeData.1447253731236
Ok一个小小的例子完成 睡觉晚安
.