fluem全分布环境搭建

1.下载fluem安装包

2.通过xshell上传到相应的安装目录中

3.通过tar -zxvf命令 解压到指定目录中

4.找到对应的jdk的安装目录和hadoop相应的位置

JAVA_HOME=/appPath/java/jdk1.8.0

FLUME_CLASSPATH="/appPath/hadoop/hadoop-2.7.3/share/hadoop/hdfs/*"

5.进入fluem的conf文件中

修改

mv flume-conf.properties.template flume-conf.properties

mv flume-env.sh.template flume-env.sh

6.编辑 flume-env.sh并将第五步的内容 复制到相应的位置

7对flume-conf.properties进行定义相应文件内容:

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


# a.conf: A single-node Flume configuration
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = spooldir
a1.sources.r1.spoolDir = /appPath/fluem/fluem-1.7.0/fluemlog
a1.sources.r1.fileHeader = true
a1.sources.r1.deserializer.outputCharset=UTF-8
# Describe the sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = hdfs://192.168.176.131:9000/log
a1.sinks.k1.hdfs.fileType = DataStream
a1.sinks.k1.hdfs.writeFormat=Text
a1.sinks.k1.hdfs.maxOpenFiles = 1
a1.sinks.k1.hdfs.rollCount = 0
a1.sinks.k1.hdfs.rollInterval = 0
a1.sinks.k1.hdfs.rollSize = 1000000
a1.sinks.k1.hdfs.batchSize = 100000
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000000
a1.channels.c1.transactionCapacity = 100000
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

文件内容的说明详情见 fluem的官方说明

创建对应启动的日志文件保存目录

fluemlog 具体位置可以自定义 但是要与这个flume-conf.properties文件中a1.sources.r1.spoolDir = /appPath/fluem/fluem-1.7.0/fluemlog这个属性连接

还需要对该文件夹进行 授权 chmod -r fluemlog

启动fluem

./flume-ng agent -c /appPath/fluem/fluem-1.7.0/conf -f /appPath/fluem/fluem-1.7.0/conf/flume-conf.properties -n a1 -Dflume.root.logger=INFO,console

启动过程中可能遇到问题有:

 java.lang.ClassNotFoundException: org.apache.hadoop.io.SequenceFile$CompressionType

 解决办法:

将hadoop的安装目录中相应的文件复制到fluem安装文件中lib中

cp -r hadoop-common-2.7.3.jar /appPath/fluem/fluem-1.7.0/lib

Caused by: java.lang.ClassNotFoundException: org.apache.htrace.SamplerBuilder

 解决办法:

将hadoop的安装目录中相应的文件复制到fluem安装文件中lib中

cp -rhtrace-core-3.1.0-incubating.jar /appPath/fluem/fluem-1.7.0/lib

原文地址:https://www.cnblogs.com/XiaoLaiTongXueA/p/13625322.html