flume-ng安装,应用,几个简单测试例子!
来源:互联网 发布:厨师机 知乎 编辑:程序博客网 时间:2024/06/15 11:37
官网文档:http://flume.apache.org/FlumeUserGuide.html
Flume是Cloudera提供的一个高可用的,高可靠的,分布式的海量日志采集、聚合和传输的系统,Flume支持在日志系统中定制各类数据发送方,用于收集数据;同时,Flume提供对数据进行简单处理,并写到各种数据接受方(可定制)的能力。
当前Flume有两个版本Flume 0.9X版本的统称Flume-og,Flume1.X版本的统称Flume-ng。由于Flume-ng经过重大重构,与Flume-og有很大不同,使用时请注意区分。
日志收集
Flume最早是Cloudera提供的日志收集系统,目前是Apache下的一个孵化项目,Flume支持在日志系统中定制各类数据发送方,用于收集数据。
数据处理
Flume提供对数据进行简单处理,并写到各种数据接受方(可定制)的能力 Flume提供了从console(控制台)、RPC(Thrift-RPC)、text(文件)、tail(UNIX tail)、syslog(syslog日志系统,支持TCP和UDP等2种模式),exec(命令执行)等数据源上收集数据的能力。
下载安装:
wget http://mirror.bit.edu.cn/apache/flume/1.7.0/apache-flume-1.7.0-bin.tar.gz
tar -zxvf apache-flume-1.7.0-bin.tar.gz
测试例子:
cd conf/
touch example.conf
vim 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 = c1
a1.sinks.k1.channel = c1
启动:
$ bin/flume-ng agent --conf conf --conf-file conf/example.conf --name a1 -Dflume.root.logger=INFO,console
yum install telnet
telnet localhost 44444
helloworld 测试(a->b传送数据)
安装avro (cmark)
wget https://cmake.org/files/v3.8/cmake-3.8.1.tar.gz
1: wget http://mirrors.hust.edu.cn/apache/avro/avro-1.7.7/c/avro-c-1.7.7.tar.gz
2:tar -zxvf avro-src-1.7.7.tar.gz
3:cd avro-c-1.7.7
4:mkdir build
5:cd build
6:cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=RelWithDebinfo
7:make
8:make install
关闭防火墙
service iptables stop
-------------测试 HTTP Source--------------------------
conf:httppost.conf
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = org.apache.flume.source.http.HTTPSource
a1.sources.r1.port = 5140
a1.sources.r1.channels = c1
# Describe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
启动flume agent al
bin/flume-ng agent --conf conf --conf-file conf/httppost.conf --name a1 -Dflume.root.logger=INFO,console
发送一个请求
curl -XPOST -d '[{"headers" : {"timestamp" : "434324343","host" : "random_host.example.com"},"body" : "random_body"},{"headers" : {"namenode" : "namenode.example.com","datanode" : "random_datanode.example.com"},"body" : "really_random_body" }]' http://localhost:5140
结果:控制台会打印出来 OK-----
-------------测试 avro Source--------------------------
conf:avrotest.conf
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444
a1.sources.r1.channels = c1
# Describe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
启动flume agent al
bin/flume-ng agent --conf conf --conf-file conf/avrotest.conf --name a1 -Dflume.root.logger=INFO,console
echo "hello world" > test.log
发送文件到flume
bin/flume-ng avro-client -c conf -H 192.168.254.129 -p 44444 -F /home/rui/log/test.log
-------------测试 Spooling Directory Source--------------------------
conf:directorytest.conf
# 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 = /home/rui/log/flumespool
a1.sources.r1.fileHeader = true
a1.sources.r1.channels = c1
# Describe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
启动flume agent al
bin/flume-ng agent --conf conf --conf-file conf/directorytest.conf --name a1 -Dflume.root.logger=INFO,console
测试:
cd /home/rui/log/flumespool
echo "hello world" > test.log
-------------测试 avro sink-----------a1服务--send-->a2服---------------
接收端:touch receive.conf
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44445
a1.sources.r1.channels = c1
# Describe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
启动flume agent al
bin/flume-ng agent --conf conf --conf-file conf/receive.conf --name a1 -Dflume.root.logger=INFO,console
发送端:send.conf
# Name the components on this agent
a2.sources = r1
a2.sinks = k1
a2.channels = c1
# Describe/configure the source
#或者目录监听方式
a2.sources.r1.type = syslogtcp
a2.sources.r1.bind = localhost
a2.sources.r1.port = 44446
a2.sources.r1.channels = c1
# Describe the sink !!!!!!!!!!!!!!!!!!!!The point is here
a2.sinks.k1.type = avro
a2.sinks.k1.channel = c1
a2.sinks.k1.hostname = 127.0.0.1
a2.sinks.k1.port = 44445
# Use a channel which buffers events in memory
a2.channels.c1.type = memory
a2.channels.c1.capacity = 1000
a2.channels.c1.transactionCapacity = 100
启动flume agent al
bin/flume-ng agent --conf conf --conf-file conf/send.conf --name a2 -Dflume.root.logger=INFO,console
tcp方式测试:
echo "<37>hello via avro sink" | nc localhost 44446
如果没有nc 就 yum install nc
44445端口控制台打印现来:<37>hello via avro sink, 就成功了!
0 0
- flume-ng安装,应用,几个简单测试例子!
- flume ng简单例子
- flume-ng 实际应用例子,flume采集log4j日志
- Flume 安装,简单测试
- flume-ng+kafka单机安装测试
- Flume-ng 例子
- Flume NG 例子
- flume-ng简单介绍
- Jedis几个简单测试例子
- Jedis几个简单测试例子
- flume-ng应用场景分析
- Flume-ng-extends的应用
- flume-ng的简单使用
- flume-ng 1.4的安装
- Flume-ng集群安装文档
- Flume-NG 日志文件收集 简单实例
- flume ng 1.3 安装配置方法
- flume ng 1.3 安装配置方法
- 【C++学习笔记】函数
- Hibernate用getCurrentSession()增删改查
- snprintf参数类型不严格匹配导致的天大的坑“(null)”------这次不说core dump问题了
- 2017-05-12 华东师范大学网络邀请赛
- Codeforces 782B 二分搜索
- flume-ng安装,应用,几个简单测试例子!
- NYoj 1102 Fibonacci数列
- include指令
- 案例分析:某企业FTP服务动态密码验证模块存在的问题及建议
- 误删appcompat v7后,怎么创建appcompat v7项目。
- 使用SSL加密与Kubernetes apiServer的通信
- Android-Activity-Life
- 欢迎使用CSDN-markdown编辑器
- oracle locked by transaction