版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/someby/article/details/87896953
目录
本文将主要介绍flume安装。
实验环境
flume版本:apache-flume-1.9.0
可以根据自己的需要到官网下载自己需要的版本:http://flume.apache.org/
安装flume
将flume安装到Master目录/usr/local/下
解压
sudo tar apache-flume-1.9.0-bin.tar.gz -C /usr/local/
重命名文件
sudo mv apache-flume-1.9.0-bin flume
修改文件权限
sudo chown -R hadoop:hadoop flume
配置环境变量
sudo vim ~/.bashrc
export FLUME_HOME=/usr/local/flume
export FLUME_CONF_DIR=$FULME_HOME/conf
export PATH=$PATH:$FLUME_HOME/bin
环境变量生效
source ~/.bashrc
配置文件
cd flume/conf
cp flume-conf.properties.template flume-conf.properties
sudo vim 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
gent1.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
配置后的完整文件
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # The configuration file needs to define the sources, # the channels and the sinks. # Sources, channels and sinks are defined per agent, # in this case called 'agent' agent1.sources=source1 agent1.sinks=sink1 agent1.channels=channel1 # For each one of the sources, the type is defined 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 # Each sink's type must be defined agent1.sinks.sink1.type=hdfs agent1.sinks.sink1.hdfs.path=hdfs://Master: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 # Each channel's type is defined. agent1.channels.channel1.type=file agent1.channels.channel1.checkpointDir=/usr/local/logs_tmp_cp agent1.channels.channel1.dataDirs=/usr/local/logs_tmp # Other config values specific to each type of channel(sink or source) # can be defined as well # In this case, it specifies the capacity of the memory channel agent.channels.memoryChannel.capacity = 100
创建需要的文件夹
在/usr/local/目录下创建logs文件夹
cd /usr/local/
sudo mkdir logs
创建hdfs文件夹
hdfs dfs -mkdir /logs
查看文件夹
hdfs dfs -ls /
启动flume-agent
flume-ng agent -n agent1 -c conf -f /usr/local/flume/conf/flume-conf.properties -Dflume.root.logger=DEBUG,console
至此,flume已经安装完成,下一篇将介绍spark的安装步骤。