【Hadoop】10、Flume组件
Flume组件安装配置
1、下载和解压 Flume
# 传Flume安装包
[root@master ~]# cd /opt/software/
[root@master software]# ls
apache-flume-1.6.0-bin.tar.gz hadoop-2.7.1.tar.gz jdk-8u152-linux-x64.tar.gz mysql-5.7.18.zip sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz
apache-hive-2.0.0-bin.tar.gz hbase-1.2.1-bin.tar.gz mysql-5.7.18 mysql-connector-java-5.1.46.jar zookeeper-3.4.8.tar.gz
# 使用root用户解压Flume到“/usr/local/src”路径
[root@master software]# tar xf /opt/software/apache-flume-1.6.0-bin.tar.gz -C /usr/local/src/
# 修改Flume安装路径文件夹名称
[root@master software]# cd /usr/local/src
[root@master src]# mv apache-flume-1.6.0-bin flume
# 修改文件夹归属用户和归属组为hadoop用户和hadoop组
[root@master src]# chown -R hadoop.hadoop /usr/local/src/
2、Flume 组件部署
# 编辑系统环境变量配置文件
[root@master src]# vi /etc/profile.d/flume.sh
添加:
export FLUME_HOME=/usr/local/src/flume
export PATH=${FLUME_HOME}/bin:$PATH
# 切换hadoop用户
[root@master src]# su - hadoop
# 查看是否成功
[hadoop@master ~]$ echo $PATH
/usr/local/src/zookeeper/bin:/usr/local/src/sqoop/bin:/usr/local/src/hbase/bin:/usr/local/src/jdk/bin:/usr/local/src/hadoop/bin:/usr/local/src/hadoop/sbin:/usr/local/src/flume/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/src/hive/bin:/home/hadoop/.local/bin:/home/hadoop/bin
# 修改hbase-env.sh文件
[hadoop@master ~]$ vim /usr/local/src/hbase/conf/hbase-env.sh
#export HBASE_CLASSPATH=/usr/local/src/hadoop/etc/hadoop/ 注释掉这一行的内容
# 拷贝 flume-env.sh.template 文件
[hadoop@master ~]$ cd /usr/local/src/flume/conf
[hadoop@master conf]$ cp flume-env.sh.template flume-env.sh
# 修改并配置 flume-env.sh 文件
[hadoop@master conf]$ vi flume-env.sh
修改:
export JAVA_HOME=/usr/local/src/jdk
# 启动hadoop
[hadoop@master conf]$ start-all.sh
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
Starting namenodes on [master]
hadoop@master's password:
master: namenode running as process 50448. Stop it first.
192.168.100.30: datanode running as process 43460. Stop it first.
192.168.100.20: datanode running as process 46094. Stop it first.
Starting secondary namenodes [0.0.0.0]
hadoop@0.0.0.0's password:
0.0.0.0: secondarynamenode running as process 50670. Stop it first.
starting yarn daemons
resourcemanager running as process 50836. Stop it first.
192.168.100.30: nodemanager running as process 43584. Stop it first.
192.168.100.20: nodemanager running as process 46228. Stop it first.
# 执行以上命令后要确保master上有NameNode、SecondaryNameNode、ResourceManager进程,在slave节点上要能看到DataNode、NodeManager进程
# master节点查看
[hadoop@master conf]$ jps
50448 NameNode
50836 ResourceManager
47502 QuorumPeerMain
50670 SecondaryNameNode
55855 Jps
# slave1节点查看
[root@slave1 ~]# su - hadoop
[hadoop@slave1 ~]$ jps
2070 DataNode
2364 Jps
2191 NodeManager
[hadoop@slave1 ~]$
# slave2节点查看
[root@slave2 ~]# su - hadoop
[hadoop@slave2 ~]$ jps
2166 NodeManager
2055 DataNode
2345 Jps
[hadoop@slave2 ~]$
# 验证安装是否成功
[hadoop@master conf]$ flume-ng version
Flume 1.6.0
Source code repository: https://git-wip-us.apache.org/repos/asf/flume.git
Revision: 2561a23240a71ba20bf288c7c2cda88f443c2080
Compiled by hshreedharan on Mon May 11 11:15:44 PDT 2015
From source with checksum b29e416802ce9ece3269d34233baf43f
# 若能够正常查询 Flume 组件版本为1.6.0,则表示安装成功。
3、使用 Flume 发送和接受信息
# 在 Flume 安装目录中创建 simple-hdfs-flume.conf 文件
[hadoop@master conf]$ cd /usr/local/src/flume
[hadoop@master flume]$ vi simple-hdfs-flume.conf
a1.sources=r1
a1.sinks=k1
a1.channels=c1
a1.sources.r1.type=spooldir
a1.sources.r1.spoolDir=/usr/local/src/hadoop/logs
a1.sources.r1.fileHeader=true
a1.sources.r1.deserializer.maxLineLength=30000
a1.sinks.k1.type=hdfs
a1.sinks.k1.hdfs.path=hdfs://master:9000/tmp/flume
a1.sinks.k1.hdfs.rollsize=1024000
a1.sinks.k1.hdfs.rollCount=0
a1.sinks.k1.hdfs.rollInterval=900
a1.sinks.k1.hdfs.useLocalTimeStamp=true
a1.channels.c1.type=file
a1.channels.c1.capacity=10000
a1.channels.c1.transactionCapacity=1000
a1.sources.r1.channels=c1
a1.sinks.k1.channel=c1
# 删除/tmp
[hadoop@master flume]$ hdfs dfs -rm -r /tmp
22/05/08 22:16:44 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 0 minutes, Emptier interval = 0 minutes.
Deleted /tmp
# 创建/tmp/flume
[hadoop@master flume]$ hdfs dfs -mkdir -p /tmp/flume
# 查看文件
[hadoop@master flume]$ hdfs dfs -ls /
Found 5 items
drwxr-xr-x - hadoop supergroup 0 2022-04-29 15:26 /hbase
drwxr-xr-x - hadoop supergroup 0 2022-04-29 11:59 /input
drwxr-xr-x - hadoop supergroup 0 2022-04-29 12:00 /output
drwxr-xr-x - hadoop supergroup 0 2022-05-08 22:16 /tmp
drwxr-xr-x - hadoop supergroup 0 2022-04-29 16:49 /user
# 使用 flume-ng agent 命令加载 simple-hdfs-flume.conf 配置信息,启动 flume 传输数据
[hadoop@master flume]$ flume-ng agent --conf-file simple-hdfs-flume.conf --name a1
22/05/08 22:17:56 INFO hdfs.BucketWriter: Creating hdfs://master:9000/tmp/flume/FlumeData.1652019471497.tmp
22/05/08 22:17:56 INFO hdfs.BucketWriter: Closing hdfs://master:9000/tmp/flume/FlumeData.1652019471497.tmp
22/05/08 22:17:56 INFO hdfs.BucketWriter: Renaming hdfs://master:9000/tmp/flume/FlumeData.1652019471497.tmp to hdfs://master:9000/tmp/flume/FlumeData.1652019471497
22/05/08 22:17:56 INFO hdfs.BucketWriter: Creating hdfs://master:9000/tmp/flume/FlumeData.1652019471498.tmp
22/05/08 22:17:56 INFO hdfs.BucketWriter: Closing hdfs://master:9000/tmp/flume/FlumeData.1652019471498.tmp
22/05/08 22:17:56 INFO hdfs.BucketWriter: Renaming hdfs://master:9000/tmp/flume/FlumeData.1652019471498.tmp to hdfs://master:9000/tmp/flume/FlumeData.1652019471498
22/05/08 22:17:56 INFO hdfs.BucketWriter: Creating hdfs://master:9000/tmp/flume/FlumeData.1652019471499.tmp
22/05/08 22:17:56 INFO hdfs.BucketWriter: Closing hdfs://master:9000/tmp/flume/FlumeData.1652019471499.tmp
22/05/08 22:17:56 INFO hdfs.BucketWriter: Renaming hdfs://master:9000/tmp/flume/FlumeData.1652019471499.tmp to hdfs://master:9000/tmp/flume/FlumeData.1652019471499
22/05/08 22:17:56 INFO hdfs.BucketWriter: Creating hdfs://master:9000/tmp/flume/FlumeData.1652019471500.tmp
22/05/08 22:17:57 INFO hdfs.BucketWriter: Closing hdfs://master:9000/tmp/flume/FlumeData.1652019471500.tmp
22/05/08 22:17:57 INFO hdfs.BucketWriter: Renaming hdfs://master:9000/tmp/flume/FlumeData.1652019471500.tmp to hdfs://master:9000/tmp/flume/FlumeData.1652019471500
22/05/08 22:17:57 INFO hdfs.BucketWriter: Creating hdfs://master:9000/tmp/flume/FlumeData.1652019471501.tmp
22/05/08 22:17:57 INFO hdfs.BucketWriter: Closing hdfs://master:9000/tmp/flume/FlumeData.1652019471501.tmp
22/05/08 22:17:57 INFO hdfs.BucketWriter: Renaming hdfs://master:9000/tmp/flume/FlumeData.1652019471501.tmp to hdfs://master:9000/tmp/flume/FlumeData.1652019471501
22/05/08 22:17:57 INFO hdfs.BucketWriter: Creating hdfs://master:9000/tmp/flume/FlumeData.1652019471502.tmp
22/05/08 22:17:57 INFO hdfs.BucketWriter: Closing hdfs://master:9000/tmp/flume/FlumeData.1652019471502.tmp
22/05/08 22:17:57 INFO hdfs.BucketWriter: Renaming hdfs://master:9000/tmp/flume/FlumeData.1652019471502.tmp to hdfs://master:9000/tmp/flume/FlumeData.1652019471502
22/05/08 22:17:57 INFO hdfs.BucketWriter: Creating hdfs://master:9000/tmp/flume/FlumeData.1652019471503.tmp
22/05/08 22:17:57 INFO hdfs.BucketWriter: Closing hdfs://master:9000/tmp/flume/FlumeData.1652019471503.tmp
22/05/08 22:17:57 INFO hdfs.BucketWriter: Renaming hdfs://master:9000/tmp/flume/FlumeData.1652019471503.tmp to hdfs://master:9000/tmp/flume/FlumeData.1652019471503
# 查看 Flume 传输到 HDFS 的文件
[hadoop@master flume]$ hdfs dfs -ls /tmp/flume
-rw-r--r-- 2 hadoop supergroup 1329 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471536
-rw-r--r-- 2 hadoop supergroup 1479 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471537
-rw-r--r-- 2 hadoop supergroup 1360 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471538
-rw-r--r-- 2 hadoop supergroup 1249 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471539
-rw-r--r-- 2 hadoop supergroup 1349 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471540
-rw-r--r-- 2 hadoop supergroup 1550 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471541
-rw-r--r-- 2 hadoop supergroup 1241 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471542
-rw-r--r-- 2 hadoop supergroup 1372 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471543
-rw-r--r-- 2 hadoop supergroup 1362 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471544
-rw-r--r-- 2 hadoop supergroup 1485 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471545
-rw-r--r-- 2 hadoop supergroup 17253 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471546
-rw-r--r-- 2 hadoop supergroup 1296 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471547
-rw-r--r-- 2 hadoop supergroup 1285 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471548
-rw-r--r-- 2 hadoop supergroup 1447 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471549
-rw-r--r-- 2 hadoop supergroup 1363 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471550
-rw-r--r-- 2 hadoop supergroup 1246 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471551
-rw-r--r-- 2 hadoop supergroup 1366 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471552
-rw-r--r-- 2 hadoop supergroup 1630 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471553
-rw-r--r-- 2 hadoop supergroup 1250 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471554
-rw-r--r-- 2 hadoop supergroup 1425 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471555
-rw-r--r-- 2 hadoop supergroup 1329 2022-05-08 22:17 /tmp/flume/FlumeData.1652019471556
……
# 若能查看到 HDFS 上/tmp/flume 目录有传输的数据文件,则表示数据传输成功。
使用 flume-ng agent 命令加载 simple-hdfs-flume.conf 配置信息
查看 Flume 传输到 HDFS 的文件:
浏览器查看:http://master:50070
查看文件:
声明:未经许可,不得转载
【Hadoop】10、Flume组件的更多相关文章
- Flume 组件安装配置
下载和解压 Flume 实验环境可能需要回至第四,五,六章(hadoop和hive),否则后面传输数据可能报错(猜测)! 可 以 从 官 网 下 载 Flume 组 件 安 装 包 , 下 载 地 址 ...
- Hadoop生态圈-Flume的组件之自定义Sink
Hadoop生态圈-Flume的组件之自定义Sink 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本篇博客主要介绍sink相关的API使用两个小案例,想要了解更多关于API的小技 ...
- Hadoop生态圈-Flume的组件之自定义拦截器(interceptor)
Hadoop生态圈-Flume的组件之自定义拦截器(interceptor) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本篇博客只是举例了一个自定义拦截器的方法,测试字节传输速 ...
- Hadoop生态圈-Flume的组件之sink处理器
Hadoop生态圈-Flume的组件之sink处理器 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一. 二.
- Hadoop生态圈-Flume的组件之拦截器与选择器
Hadoop生态圈-Flume的组件之拦截器与选择器 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本篇博客只是配置的是Flume主流的Interceptors,想要了解更详细 ...
- Hadoop生态圈-Flume的主流source源配置
Hadoop生态圈-Flume的主流source源配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本篇博客只是配置的是Flume主流的Source,想要了解更详细的配置信息请参 ...
- Hadoop生态圈-flume日志收集工具完全分布式部署
Hadoop生态圈-flume日志收集工具完全分布式部署 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 目前为止,Hadoop的一个主流应用就是对于大规模web日志的分析和处理 ...
- hadoop伪分布式组件安装
一.版本建议 Centos V7.5 Java V1.8 Hadoop V2.7.6 Hive V2.3.3 Mysql V5.7 Spark V2.3 Scala V2.12.6 Flume V1. ...
- Hadoop生态圈-Flume的主流Sinks源配置
Hadoop生态圈-Flume的主流Sinks源配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本篇博客只是配置的是Flume主流的Sinks,想要了解更详细的配置信息请参考官 ...
随机推荐
- 什么是 REST / RESTful 以及它的用途是什么?
Representational State Transfer(REST)/ RESTful Web 服务是一种帮助计 算机系统通过 Internet 进行通信的架构风格.这使得微服务更容易理解和实现 ...
- ElasticSearch-学习笔记04-复杂查询
service package com.huarui.service; import com.huarui.entity.SearchEntity; import com.huarui.exectio ...
- yum下载安装git服务
yum install git 安装成功后,配置 用户 邮箱信息 注: youxiu326 github账号名称 youxiu326@163.com github账号对应邮箱 git confi ...
- vue3在组件上使用v-model
v-model用于在元素上创建双向数据绑定,负责监听用户输入事件来更新数据. v-model应用于输入框 <input v-model="searchText" /> ...
- Altium design16设计技巧
第一栏:共有界面 1.在原理图和PCB都打开的情况下,选中原理图可以对应到PCB界面元件里面 第二栏:原理图界面 1.批量改变元件属性 选择某一元件-查找相似对象-将其要改变的内容设置为same-点击 ...
- Web前端初级问题—ajax登录跳转登录实现
当我们的用户进行系统登录时,用户名和密码的验证都是后端验证的.而且,用户登录状态也是要后端设置的,查询数据库后,用户名和密码正确,则在session中存储一个uuid,每个页面需要根据登录状态判断展示 ...
- 【Android开发】【布局】 仿QQ的UI
Demo地址
- 判断链表是否有环(Java实现)
判断给定的链表中是否有环.如果有环则返回true,否则返回false. 解题思路:设置两个指针,slow和fast,fast每次走两步,slow每次走一步,如果有环的话fast一定会追上slow,判断 ...
- java中switch结构和 while for循环的用法
6.2 switch结构: 变量可以是:variable can be:(mark: tried, can not be long) char/int/short/byte(java1.7 就可 ...
- java中Number Type Casting(数字类型强转)的用法
4.5 Number Type Casting(数字类型强转)隐式 casting(from small to big) byte a = 111; int b = a;显式 casting(from ...