Flume-安装与 NetCat UDP Source 监控端口
Flume 文档:https://flume.apache.org/FlumeUserGuide.html
Flume 下载:https://archive.apache.org/dist/flume/ & https://flume.apache.org/download.html
JDK 下载:https://mirrors.huaweicloud.com/java/jdk/
Flume 不是一个分布式程序,也不需要启动什么进程。在有任务时,运行程序,指定任务即可。
一、安装
# 下载
curl -o /opt/apache-flume-1.9.-bin.tar.gz http://mirrors.tuna.tsinghua.edu.cn/apache/flume/1.9.0/apache-flume-1.9.0-bin.tar.gz # 解压
tar -zxf /opt/apache-flume-1.9.-bin.tar.gz -C /opt/ # 配置
cd /opt/apache-flume-1.9.-bin/conf/
cp flume-env.sh.template flume-env.sh
vim flume-env.sh
flume-env.sh 改一个 JDK 路径即可
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License. # If this file is placed at FLUME_CONF_DIR/flume-env.sh, it will be sourced
# during Flume startup. # Enviroment variables can be set here. export JAVA_HOME=/opt/jdk1.8.0_202 # Give Flume more memory and pre-allocate, enable remote monitoring via JMX
# export JAVA_OPTS="-Xms100m -Xmx2000m -Dcom.sun.management.jmxremote" # Let Flume write raw event data and configuration information to its log files for debugging
# purposes. Enabling these flags is not recommended in production,
# as it may result in logging sensitive user information or encryption secrets.
# export JAVA_OPTS="$JAVA_OPTS -Dorg.apache.flume.log.rawdata=true -Dorg.apache.flume.log.printconfig=true " # Note that the Flume conf directory is always included in the classpath.
#FLUME_CLASSPATH=""
二、HelloWorld
https://flume.apache.org/FlumeUserGuide.html#a-simple-example
监控端口数据官方案例:使用 Flume 监听一个端口,收集该端口数据,并打印到控制台。
1.使用 nc 做为网络通信
yum install -y nc # 服务端,接受消息
nc -lk # 客户端,发送消息
nc 127.0.0.1
2.编写 Flume Agent 配置文件
https://flume.apache.org/FlumeUserGuide.html#netcat-tcp-source
https://flume.apache.org/FlumeUserGuide.html#netcat-udp-source
flume-netcat-logger.conf
# Name the components on this agent
# a1:表示 agent 的名称
# r1:表示 a1 的 Source 的名称
a1.sources = r1
# k1:表示 a1 的 Sink 的名称
a1.sinks = k1
# c1:表示 a1 的 Channel 的名称
a1.channels = c1 # Describe/configure the source
# 表示 a1 的输入源类型为 netcat 端口类型
a1.sources.r1.type = netcat
# 表示 a1 的监听的主机
a1.sources.r1.bind = 127.0.0.1
# 表示 a1 的监听的端口号
a1.sources.r1.port = 4444 # Describe the sink
# 表示 a1 的输出目的地是控制台 logger 类型
a1.sinks.k1.type = logger # Use a channel which buffers events in memory
# 表示 a1 的 channel 类型是 memory 内存型
a1.channels.c1.type = memory
# 表示 a1 的 channel 总容量 1000 个 event
a1.channels.c1.capacity = 1000
# 表示 a1 的 channel 传输时收集到了 100 条 event 以后再去提交事务
a1.channels.c1.transactionCapacity = 100 # Bind the source and sink to the channel
# 表示将 r1 和 c1 连接起来
a1.sources.r1.channels = c1
# 表示将 k1 和 c1 连接起来
a1.sinks.k1.channel = c1
3.开启 Flume 监听端口
cd /opt/apache-flume-1.9.-bin/ # 第一种写法
bin/flume-ng agent --conf conf/ --name a1 --conf-file /tmp/flume-netcat-logger.conf -Dflume.root.logger=INFO,console # 第二种写法
bin/flume-ng agent -c conf/ -n a1 -f /tmp/flume-netcat-logger.conf -Dflume.root.logger=INFO,console # --conf/-c:表示配置文件存储在 conf/目录
# --name/-n:表示给 agent 起名为 a1
# --conf-file/-f:flume 本次启动读取的配置文件是在 /tmp 文件夹下的 flume-telnet.conf 文件。
# -Dflume.root.logger=INFO,console :-D 表示 flume 运行时动态修改 flume.root.logger 参数属性值,并将控制台日志打印级别设置为 INFO 级别。日志级别包括:log、info、warn、error。
4.向监听的网络端口发送数据
nc 127.0.0.1
再看 Flume 监控日志
Flume-安装与 NetCat UDP Source 监控端口的更多相关文章
- Flume简介与使用(一)——Flume安装与配置
Flume简介与使用(一)——Flume安装与配置 Flume简介 Flume是一个分布式的.可靠的.实用的服务——从不同的数据源高效的采集.整合.移动海量数据. 分布式:可以多台机器同时运行采集数据 ...
- Flume篇---Flume安装配置与相关使用
一.前述 Copy过来一段介绍Apache Flume 是一个从可以收集例如日志,事件等数据资源,并将这些数量庞大的数据从各项数据资源中集中起来存储的工具/服务,或者数集中机制.flume具有高可用, ...
- flume学习以及ganglia(若是要监控hive日志,hive存放在/tmp/hadoop/hive.log里,只要运行过hive就会有)
python3.6hdfs的使用 https://blog.csdn.net/qq_29863961/article/details/80291654 https://pypi.org/ 官网直接搜 ...
- 大数据学习day35----flume01-------1 agent(关于agent的一些问题),2 event,3 有关agent和event的一些问题,4 transaction(事务控制机制),5 flume安装 6.Flume入门案例
具体见文档,以下只是简单笔记(内容不全) 1.agent Flume中最核心的角色是agent,flume采集系统就是由一个个agent连接起来所形成的一个或简单或复杂的数据传输通道.对于每一个Age ...
- flume安装配置
1 下载安装包并解压 下载地址:http://flume.apache.org/download.html 解压:tar zxvf apache-flume-1.8.0-bin.tar.gz 2 配置 ...
- Flume 安装和配置
安装步骤 1.安装jdk,1.6版本以上 2.上传flume的安装包 3.解压安装 4.在conf目录下,创建一个配置文件,比如:template.conf(名字可以不固定,后缀也可以不固定) 5.配 ...
- Flume安装部署
Flume安装部署 Flume的安装(非常简单) 上传安装包到数据源所在节点上,实际上不是数据源节点也是可以的,只要运行Flume的这台机器与数据源节点的这台机器能够通过某种协议进行通信即可. 然后解 ...
- 大数据笔记(十九)——数据采集引擎Sqoop和Flume安装测试详解
一.Sqoop数据采集引擎 采集关系型数据库中的数据 用在离线计算的应用中 强调:批量 (1)数据交换引擎: RDBMS <---> Sqoop <---> HDFS.HBas ...
- flume安装及使用
最近在学习hadoop大数据平台,但是却感觉无从下手,于是看了一些专业的书籍,觉得还是先从下往上为学习也就是从源数据--数据抽取--存储--计算--展示这个路线来学习比较容易一些,所以就先从非结构化数 ...
随机推荐
- ASE19团队项目alpha阶段model组 scrum8 记录
本次会议于11月12日,19时整在微软北京西二号楼sky garden召开,持续15分钟. 与会人员:Jiyan He, Kun Yan, Lei Chai, Linfeng Qi, Xueqing ...
- php-amqplib库操作RabbitMQ
RabbitMQ基本原理 首先,建议去大概了解下RabbitMQ(以下简称mq)的基本工作原理,可以参考这篇文章最主要的几个对象如下 对象名称 borker 相当于mq server channe ...
- Flutter——Image组件(图片组件)
Image组件有很多构造函数,这里只说两个. Image.asset 本地图片 1.在根目录新建文件夹 /images 2.在 images 文件夹下建立两个文件夹 /images/2.0x /i ...
- django的几种缓存配置
前言 首先说,为什么要用缓存的,由于Django是动态网站,所有每次请求均会去数据进行相应的操作,当程序访问量大时,耗时必然会更加明显,最简单解决方式是使用:缓存,缓存将一个某个views的返回值保存 ...
- AJAX—JSON和Django内置序列化
JSON 什么是JSON JSON 指的是 JavaScript 对象表示法(JavaScript Object Notation) JSON 是轻量级的文本数据交换格式 JSON 独立于语言 * J ...
- 关于JPype报FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/jvm'错误的解决
部署到线上的项目正常运行一年,今天早上突然报FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/jvm'错误. JPyp ...
- Hadoop_28_MapReduce_自定义 inputFormat
1. 自定义inputFormat 1.1.需求: 无论hdfs还是mapreduce,对于小文件都有损效率,实践中,又难免面临处理大量小文件,此时就需要有相应解决方案; 1.2.分析: 小文件的优化 ...
- day_02比特币的转账机制及其7个名词
一:比特币的转账机制: 类似于普通转账:登录钱包--->选择转出(入)币的钱包地址--->填入转出数额及其手续费--->比特币签名--->提交比特币网络--->进行矿工打 ...
- iTerm2快速SSH连接并保存密码
背景 Mac自带terminal,以及比较好用的iTerm2命令行工具,都缺乏一个功能,就是远程SSH连接,无法保存密码.一种方法是将本机的ssh_key放到远程服务器中实现无密码登录.这种方法在很多 ...
- Gym - 102141D 通项公式 最短路
题目很长,但是意思就是给你n,A,B,C,D n表示有n个城市 A是飞机的重量 B是一个常数表示转机代价 C是单位燃油的价格 D是一个常数 假设一个点到另外一个点的距离为整数L 起飞前的油量为f 则 ...