flume 安装

环境准备

主机名称 IP地址
flume 192.168.200.81

其他信息:
[root@flume ~]# uname -r
2.6.32-358.el6.x86_64
[root@flume ~]# uname -m
x86_64
[root@flume ~]# getenforce
Disabled

echo "192.168.200.81 flume">>/etc/hosts

一、安装JDK

请参考:Linux下快速安装JDK

二、安装flume

2.1 安装配置

下载

wget http://mirrors.tuna.tsinghua.edu.cn/apache/flume/1.8.0/apache-flume-1.8.0-bin.tar.gz

解压

tar zxf  /usr/local/src/apache-flume-1.8.0-bin.tar.gz  -C /usr/local/

创建软链接

ln -s /usr/local/apache-flume-1.8.0-bin /usr/local/flume

创建测试配置文件

  • mkdir /usr/local/flume/mytest
  • vim /usr/local/flume/mytest/1-example.conf
# example.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 = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444
# Describe the sink
a1.sinks.k1.type = logger
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a1.sources.r1.channels = c1a1.sinks.k1.channel = c1

2.2 启动

cd /usr/local/flume/
bin/flume-ng agent --conf conf --conf-file mytest/1-example.conf --name a1 -Dflume.root.logger=INFO,console

2.3 测试

另开启一个ssh连接端,执行telnet localhost 44444,成功后,输入hello flume

[root@flume ~]# telnet localhost 44444
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
hello flume
OK

在启动端可以查看到对应的hello flume,表示成功

2017-12-03 14:05:17,752 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:95)] Event: { headers:{} body: 68 65 6C 6C 6F 20 66 6C 75 6D 65 0D             hello flume. }

三、flume从日志文件中收集数据

3.1 编写配置文件

vim mytest/2-sourceFromFile.conf

# Name the components on this agent
a2.sources = r1
a2.sinks = k1
a2.channels = c1
# Describe/configure the source
a2.sources.r1.type = exec
a2.sources.r1.command = tail -F /tmp/temp.log
a2.sources.r1.channels = c1
# Describe the sink
a2.sinks.k1.type = logger
# Use a channel which buffers events in memory
a2.channels.c1.type = memory
a2.channels.c1.capacity = 1000
a2.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a2.sources.r1.channels = c1
a2.sinks.k1.channel = c1

创建测试日志文件

echo `date +%F\ %T` >> /tmp/temp.log

3.2 启动

bin/flume-ng agent --conf conf --conf-file mytest/2-sourceFromFile.conf --name a2 -Dflume.root.logger=INFO,console

3.3 测试观察

执行以下命令,并观察控制台

echo `date +%F\ %T` >>  /tmp/temp.log
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1.安装 Java 安装Flume配置文件解析Flume Agent启动(1)Flume 配置文件(Agent的配...
    lmem阅读 5,585评论 0 0
  • Flume的下载方式: wget http://www.apache.org/dyn/closer.lua/flu...
    晴天哥_王志阅读 3,890评论 0 1
  • 前段时间学了flume,怕忘记就写点日志总结一下。避免踩第二次坑 。。。 首先是安装flume,简单的说,flum...
    在朝阳寺树下阅读 4,294评论 0 0
  • Linux-Server-Notes PMS /home/softwareluke/图片/2017-09-11 0...
    燕京博士阅读 3,715评论 0 1
  • 秋日的阳光 ,倾洒在阳台上 ,伫立,任那温热的光覆盖脸庞, 想象家乡冬日的暖阳 , 让人慵懒倦怠。 灰色的深圳 深...
    逝我阅读 4,093评论 8 7

友情链接更多精彩内容