美文网首页Spark大型项目实战
007.课程环境搭建:flume-ng-1.5.0-cdh5.3

007.课程环境搭建:flume-ng-1.5.0-cdh5.3

作者: iarchitect | 来源:发表于2018-08-29 18:22 被阅读0次

flumen离线日志收集工具->收集数据清洗数据->存储到hive

安装flume

1、将课程提供的flume-ng-1.5.0-cdh5.3.6.tar.gz使用WinSCP拷贝到sparkproject1的/usr/local目录下。
2、对flume进行解压缩:tar -zxvf flume-ng-1.5.0-cdh5.3.6.tar.gz
3、对flume目录进行重命名:mv apache-flume-1.5.0-cdh5.3.6-bin flume
4、配置scala相关的环境变量
vi ~/.bashrc
export FLUME_HOME=/usr/local/flume
export FLUME_CONF_DIR=$FLUME_HOME/conf
export PATH=$FLUME_HOME/bin
source ~/.bashrc

修改flume配置文件

vi /usr/local/flume/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://sparkproject1: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

创建需要的文件夹

本地文件夹:mkdir /usr/local/logs
HDFS文件夹:hdfs dfs -mkdir /logs

启动flume

flume-ng agent -n agent1 -c conf -f /usr/local/flume/conf/flume-conf.properties -Dflume.root.logger=DEBUG,console

测试flume

新建一份文件,移动到/usr/local/logs目录下,flume就会自动上传到HDFS的/logs目录中

相关文章

网友评论

    本文标题:007.课程环境搭建:flume-ng-1.5.0-cdh5.3

    本文链接:https://www.haomeiwen.com/subject/cxvkwftx.html