编程那点事编程那点事

专注编程入门及提高
探究程序员职业规划之道!

flume安装

安装flume

  • 下载flume

  • 解压到/usr/local目录下

  • 重命名为mv apache-flume-1.5.0-cdh5.3.6-bin flume

  • 配置环境变量

修改配置文件

vi conf/flume-conf.properties#agent1表示代理名称agent1.sources=source1
agent1.sinks=sink1
agent1.channels=channel1#配置source1agent1.sources.source1.type=spooldir
agent1.sources.source1.spoolDir=/usr/local/flume_logs
agent1.sources.source1.channels=channel1
agent1.sources.source1.fileHeader = falseagent1.sources.source1.interceptors = i1
agent1.sources.source1.interceptors.i1.type = timestamp#配置channel1agent1.channels.channel1.type=file
agent1.channels.channel1.checkpointDir=/usr/local/flume_logs_tmp_cp
agent1.channels.channel1.dataDirs=/usr/local/flume_logs_tmp#配置sink1agent1.sinks.sink1.type=hdfs
agent1.sinks.sink1.hdfs.path=hdfs://sparkproject1:9000/flume_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/flume_logs # 本地文件夹hdfs dfs -mkdir /flume_logs # HDFS文件夹

启动flume-agent

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

测试flume

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

未经允许不得转载: 技术文章 » 大数据 » flume安装