1、Flume安装
1.1、下载、解压
1.2、配置环境变量(/etc/profile或者~/.bashrc),环境变量生效
vim ~/.bashrc
## 环境变量基本与Hadoop,Zookeeper等一致,但是需要注意,配置FLUME_CONF_DIR
export FLUME_HOME=/usr/local/flume
export FLUME_CONF_DIR=$FLUME_HOME/conf
export PATH=$FLUME_HOME/bin
source ~/.bahsrc
1.3、配置flume配置文件
vim $FLUME_HOME/conf/flume-conf.properties
#agent1表示代理名称
agent1.sources=source1
agent1.sinks=sink1
agent1.channels=channel1
#配置source1
agent1.sources.source1.type=spooldir
agent1.sources.source1.spoolDir=/usr/local/logs
agent1.sources.source1.channels=channel1
agent1.sources.source1.fileHeader = false
agent1.sources.source1.interceptors = i1
agent1.sources.source1.interceptors.i1.type = timestamp
#配置channel1
agent1.channels.channel1.type=file
agent1.channels.channel1.checkpointDir=/usr/local/logs_tmp_cp
agent1.channels.channel1.dataDirs=/usr/local/logs_tmp
#配置sink1
agent1.sinks.sink1.type=hdfs
agent1.sinks.sink1.hdfs.path=hdfs://spark1:9000/logs
agent1.sinks.sink1.hdfs.fileType=DataStream
agent1.sinks.sink1.hdfs.writeFormat=TEXT
agent1.sinks.sink1.hdfs.rollInterval=1
agent1.sinks.sink1.channel=channel1
agent1.sinks.sink1.hdfs.filePrefix=%Y-%m-%d
上述配置中,将检测该服务器的/usr/local/logs文件夹,如果该文件夹有新文件产生,flume会将该文件上传到hdfs,以供后续spark或者hadoop程序分析使用。
1.4、创建对应本地日志文件以及hdfs日志文件
mkdir /usr/local/logs
hdfs dfs -mkdir /logs
1.5、启动flume-agent
flume-ng agent -n agent1 -c conf -f $FLUME_HOME/conf/flume-conf.properties -Dflume.root.logger=DEBUG,console
1.6、验证flume是否安装成功
新建一份文件,移动到/usr/local/logs目录下,flume就会自动上传到HDFS的/logs目录中
*注释:本文中所有$FLUME_HOME表示本人自己在各个服务器的FLUME安装路径*
该系列笔记:
1. 电商用户行为分析大数据平台相关系列1-环境介绍
2. 电商用户行为分析大数据平台相关系列2-HADOOP环境搭建
3. 电商用户行为分析大数据平台相关系列3-HIVE安装
4. 电商用户行为分析大数据平台相关系列4-ZOOKEEPER安装
5. 电商用户行为分析大数据平台相关系列5-KAFKA安装
6. 电商用户行为分析大数据平台相关系列6-flume安装
7. 电商用户行为分析大数据平台相关系列7-spark安装