centOS7下flume使用

自作多情 提交于 2019-12-04 11:33:51

启动hadoop

./start-all.sh
jps

配置flume环境变量

修改/etc/profile

export FLUME_HOME=/app/flume-1.5.2
export FLUME_CONF_DIR=$FLUME_HOME/conf
export PATH=$PATH:$FLUME_HOME/bin
source /etc/profile
echo $PATH

设置 flume-env.sh 配置文件

在 $FLUME_HOME/conf 下复制改名 flume-env.sh.template 为 flume-env.sh,修改 conf/ flume-env.sh 配置文件

cp flume-env.sh.template flume-env.sh
sudo vi flume-env.sh
cp flume-env.sh.template flume-env.sh
sudo vi flume-env.sh

修改 flume-conf 配置文件

在 $FLUME_HOME/conf 目录下修改 flume-conf.properties.template 文件,复制并改名为 flume-conf.properties

cp flume-conf.properties.template flume-conf.properties
sudo vi flume-conf.properties

修改内容,用来读取hadoop运行时生成的namenode日志文件,并写入hdfs中

# 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'

a1.sources = r1
a1.channels = c1
a1.sinks = k1

# For each one of the sources, the type is defined
a1.sources.r1.type = exec
a1.sources.r1.channels = c1
a1.sources.r1.command = tail -F /opt/hadoop-3.1.2/logs/hadoop-hadoop-namenode-SZV-BZ1-IRDM4.BOOZHONG.COM.log
a1.sinks.k1.type = hdfs
a1.sinks.k1.channel = c1
a1.sinks.k1.hdfs.path = hdfs://localhost:8020/flume
a1.sinks.k1.hdfs.filePrefix = events-
a1.sinks.k1.hdfs.round = true
a1.sinks.k1.hdfs.roundValue = 10
a1.sinks.k1.hdfs.roundUnit = minute
a1.sinks.k1.hdfs.rollSize = 4000000
a1.sinks.k1.hdfs.rollCount = 0
a1.sinks.k1.hdfs.writeFormat = Text
a1.sinks.k1.hdfs.fileType = DataStream
a1.sinks.k1.hdfs.batchSize = 10
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

运行flume

./bin/flume-ng agent --conf ./conf/ --conf-file ./conf/flume-conf.properties --name a1 -Dflume.root.logger=INFO,console

打开hdfs查看导入的日志

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!