博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
通过Apache Flume向HDFS存储数据
阅读量:7005 次
发布时间:2019-06-27

本文共 1425 字,大约阅读时间需要 4 分钟。

本笔记基于Hadoop2.7.3,Apache Flume 1.8.0。其中flume source为netcat,flume channel为memory,flume sink为hdfs。


1,配置flume代理文件

配置一个flume agent代理,在此名称为shaman。配置文件(netcat-memory-hdfs.conf)如下:

# Identify the components on agent shaman:shaman.sources = netcat_s1shaman.sinks = hdfs_w1shaman.channels = in-mem_c1# Configure the source:shaman.sources.netcat_s1.type = netcatshaman.sources.netcat_s1.bind = localhostshaman.sources.netcat_s1.port = 44444# Describe the sink:shaman.sinks.hdfs_w1.type = hdfsshaman.sinks.hdfs_w1.hdfs.path = hdfs://localhost:8020/user/root/testshaman.sinks.hdfs_w1.hdfs.writeFormat = Textshaman.sinks.hdfs_w1.hdfs.fileType = DataStream# Configure a channel that buffers events in memory:shaman.channels.in-mem_c1.type = memoryshaman.channels.in-mem_c1.capacity = 20000shaman.channels.in-mem_c1.transactionCapacity = 100# Bind the source and sink to the channel:shaman.sources.netcat_s1.channels = in-mem_c1shaman.sinks.hdfs_w1.channel = in-mem_c1

备注:

hdfs://localhost:8020/user/root/test,其中hdfs://localhost:8020为hadoop配置文件core-site.xml中
fs.defaultFS属性的值,root为hadoop的登陆用户。

2,启动flume代理

bin/flume-ng agent -f agent/netcat-memory-hdfs.conf -n shaman  -Dflume.root.logger=DEBUG,console -Dorg.apache.flume.log.printconfig=true -Dorg.apache.flume.log.rawdata=true

3,打开telnet客户端,输入字母测试

telnet localhost 44444

然后输入文字

4,查看hdfs test目录

hdfs dfs -ls /user/root/test

会发现有新的文件出现,文件里面的内容即是通过telent输入的字母。


学习资料:

1,《Hadoop For Dummies》
2,

转载地址:http://tpytl.baihongyu.com/

你可能感兴趣的文章
vue模板的讲解
查看>>
成功都一样,失败各不同;失败的项目也许值得你警醒
查看>>
WdatePicker-限制日期选择
查看>>
给tcpdump加点颜色看看
查看>>
约瑟夫环问题
查看>>
Android笔记——Activity中的数据传递案例(用户注冊)
查看>>
赵雅智_Swift(1)_swift简单介绍及类型
查看>>
PHP中file_exists()函数不能检测包含中文的文件名的解决办法
查看>>
How can I create a dump of SQL Server?
查看>>
排序(3)---------冒泡排序(C语言实现)
查看>>
利用React/anu编写一个弹出层
查看>>
windows下配置nginx+php环境
查看>>
[工具配置]使用requirejs模块化开发多页面一个入口js的使用方式
查看>>
Jenkins具体安装与构建部署使用教程
查看>>
【ES】学习9-聚合2
查看>>
Mindjet MindManager 思维导图软件-使用思维导图跟踪调用流程,绘制软件框架
查看>>
SQLServer判断指定列的默认值是否存在,并修改默认值
查看>>
贝塞尔曲线与CSS3动画、SVG和canvas的应用
查看>>
将NSTimer加入至RunLoop中的两种方法差别
查看>>
[ajax 学习笔记] ajax初试
查看>>