当前位置: 首页 > news >正文

孝南区建设局网站西安网站推广排名

孝南区建设局网站,西安网站推广排名,聚美优品网站建设情况,做汽车配件外贸用什么网站一、Flume简介 Flume提供一个分布式的,可靠的,对大数据量的日志进行高效收集、聚集、移动的服务,Flume只能在Unix环境下运行。Flume基于流式架构,容错性强,也很灵活简单。Flume、Kafka用来实时进行数据收集,Spark、Flink用来实时处理数据,impala用来实时查询。二、Flume…

一、Flume简介

    1. Flume提供一个分布式的,可靠的,对大数据量的日志进行高效收集、聚集、移动的服务,Flume只能在Unix环境下运行。
    1. Flume基于流式架构,容错性强,也很灵活简单。
    1. Flume、Kafka用来实时进行数据收集,Spark、Flink用来实时处理数据,impala用来实时查询。

二、Flume角色

2.1、Source

用于采集数据,Source是产生数据流的地方,同时Source会将产生的数据流传输到Channel,这个有点类似于Java IO部分的Channel。

2.2、Channel

用于桥接Sources和Sinks,类似于一个队列。

2.3、Sink

从Channel收集数据,将数据写到目标源(可以是下一个Source,也可以是HDFS或者HBase)。

2.4、Event

传输单元,Flume数据传输的基本单元,以事件的形式将数据从源头送至目的地。

三、Flume传输过程

source监控某个文件或数据流,数据源产生新的数据,拿到该数据后,将数据封装在一个Event中,并put到channel后commit提交,channel队列先进先出,sink去channel队列中拉取数据,然后写入到HDFS中。

四、Flume部署及使用

4.1 采集架构

在这里插入图片描述

4.2 Flume安装

4.2.1 下载

apache-flume-1.6.0-bin.tar.gz
链接:https://pan.baidu.com/s/1ySmEEObFtKtyT7GsEldnfA
提取码:436t

4.2.2 安装

Flume的安装非常简单,只需要解压即可
tar -zxvf apache-flume-1.6.0-bin.tar.gz
然后进入flume的目录,修改conf下的flume-env.sh,在里面配置JAVA_HOME

在这里,我们使用集群模式,因此,需要把在master节点部署的flume分发到slave节点上:
]# scp -rp apache-flume-1.7.0-bin slave1:KaTeX parse error: Expected 'EOF', got '#' at position 6: PWD ]#̲ scp -rp apache…PWD

4.2.3 测试

采集配置:

vi netcat-logger.conf
# 定义这个agent中各组件的名字
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# 描述和配置source组件:r1
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444
# 描述和配置sink组件:k1
a1.sinks.k1.type = logger
# 描述和配置channel组件,此处使用是内存缓存的方式
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# 描述和配置source  channel   sink之间的连接关系
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

启动agent去采集数据
启动命令:

bin/flume-ng agent -c conf -f conf/netcat-logger.conf -n a1 -Dflume.root.logger=INFO,console
-c conf   指定flume自身的配置文件所在目录
-f conf/netcat-logger.con  指定我们所描述的采集方案
-n a1  指定我们这个agent的名字

在这里插入图片描述
先要往agent采集监听的端口上发送数据,让agent有数据可采
发送命令:

安装telnet:

]# yum install telnet
]# telnet anget-hostname port (telnet localhost 44444)

测试输入输出如下图:
在这里插入图片描述
在这里插入图片描述

4.3 Flume配置

1)Flume 配置分析
在这里插入图片描述
Flume 直接读 log 日志的数据,log 日志的格式是 app-yyyy-mm-dd.log。
2)Flume 的具体配置如下:
(1)在/opt/module/flume/conf 目录下创建 file-flume-kafka.conf 文件

vim file-flume-kafka.conf
a1.sources=r1
a1.channels=c1 c2
#configure source
a1.sources.r1.type = TAILDIR
a1.sources.r1.positionFile = /usr/local/src/apache-flume-1.7.0-bin/test/log_position.json
a1.sources.r1.filegroups = f1
a1.sources.r1.filegroups.f1 = /tmp/log/2020-11-03/app.*.log
a1.sources.r1.fileHeader = true
a1.sources.r1.channels = c1 c2
#interceptor
a1.sources.r1.interceptors = i1 i2
a1.sources.r1.interceptors.i1.type = com.zgjy.flume.interceptor.LogETLInterceptor$Builder
a1.sources.r1.interceptors.i2.type = com.zgjy.flume.interceptor.LogTypeInterceptor$Builder
a1.sources.r1.selector.type = multiplexing
a1.sources.r1.selector.header = topic
a1.sources.r1.selector.mapping.topic_resource = c1
a1.sources.r1.selector.mapping.topic_action = c2
# configure channel
a1.channels.c1.type = org.apache.flume.channel.kafka.KafkaChannel
a1.channels.c1.kafka.bootstrap.servers = master:9092,slave1:9092,slave2:9092
a1.channels.c1.kafka.topic = topic_resource
a1.channels.c1.parseAsFlumeEvent = false
a1.channels.c1.kafka.consumer.group.id = flume-consumer
# configure channe2
a1.channels.c2.type = org.apache.flume.channel.kafka.KafkaChannel
a1.channels.c2.kafka.bootstrap.servers = master:9092,slave1:9092,slave2:9092
a1.channels.c2.kafka.topic = topic_action
a1.channels.c2.parseAsFlumeEvent = false
a1.channels.c2.kafka.consumer.group.id = flume-consumer

测试日志:
在这里插入图片描述
配置说明如下:
在这里插入图片描述

4.4 Flume 的 ETL 和分类型拦截器

本项目中自定义了两个拦截器,分别是:ETL 拦截器、日志类型区分拦截器。
ETL 拦截器主要作用:过滤时间戳不合法和 Json 数据不完整的日志
日志类型区分拦截器主要作用:将启动日志和事件日志区分开来,方便发往 Kafka 的不 同 Topic。

1)创建 Maven 工程 flume-interceptor
2)创建包名:com.zgjy.flume.interceptor
3)在 pom.xml 文件中添加如下配置

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.zgjy</groupId><artifactId>flume-interceptor</artifactId><version>1.0-SNAPSHOT</version><dependencies><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.1.41</version></dependency><dependency><groupId>org.apache.flume</groupId><artifactId>flume-ng-core</artifactId><version>1.7.0</version></dependency></dependencies><build><plugins><plugin><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.8</source><target>1.8</target></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-assembly-plugin</artifactId><version>2.5.3</version><configuration><descriptorRefs><descriptorRef>jar-with-dependencies</descriptorRef></descriptorRefs></configuration></plugin></plugins></build></project>

4)在 com.zgjy.flume.interceptor 包下创建 LogETLInterceptor 类名
Flume ETL 拦截器 LogETLInterceptor实现代码如下:

package 

文章转载自:
http://lemony.qpqb.cn
http://discreetness.qpqb.cn
http://dressiness.qpqb.cn
http://wingmanship.qpqb.cn
http://orthopsychiatry.qpqb.cn
http://overchoice.qpqb.cn
http://glamorize.qpqb.cn
http://idiophone.qpqb.cn
http://dropscene.qpqb.cn
http://swaraj.qpqb.cn
http://truthfully.qpqb.cn
http://cremation.qpqb.cn
http://immunocompetence.qpqb.cn
http://eight.qpqb.cn
http://reprogram.qpqb.cn
http://footwall.qpqb.cn
http://stove.qpqb.cn
http://upvalue.qpqb.cn
http://giovanna.qpqb.cn
http://gitano.qpqb.cn
http://aluminosilicate.qpqb.cn
http://phoneticise.qpqb.cn
http://yellowy.qpqb.cn
http://andaman.qpqb.cn
http://sacrificially.qpqb.cn
http://macromolecule.qpqb.cn
http://staid.qpqb.cn
http://anthrax.qpqb.cn
http://pathologist.qpqb.cn
http://coadjutress.qpqb.cn
http://seek.qpqb.cn
http://washerette.qpqb.cn
http://thixotropy.qpqb.cn
http://coonhound.qpqb.cn
http://dynasty.qpqb.cn
http://straightbred.qpqb.cn
http://luluai.qpqb.cn
http://mosasaur.qpqb.cn
http://lauraldehyde.qpqb.cn
http://antistreptococcal.qpqb.cn
http://wail.qpqb.cn
http://elyseeologist.qpqb.cn
http://inhaul.qpqb.cn
http://tyne.qpqb.cn
http://pragmatism.qpqb.cn
http://approachable.qpqb.cn
http://indistinct.qpqb.cn
http://zincographer.qpqb.cn
http://ficelle.qpqb.cn
http://larry.qpqb.cn
http://endue.qpqb.cn
http://sill.qpqb.cn
http://rosyfingered.qpqb.cn
http://teleradiography.qpqb.cn
http://psammophyte.qpqb.cn
http://stapes.qpqb.cn
http://clod.qpqb.cn
http://engineering.qpqb.cn
http://penthrite.qpqb.cn
http://coronograph.qpqb.cn
http://unsighted.qpqb.cn
http://untypable.qpqb.cn
http://portocaval.qpqb.cn
http://croustade.qpqb.cn
http://battel.qpqb.cn
http://epicist.qpqb.cn
http://extraatmospheric.qpqb.cn
http://pinocchio.qpqb.cn
http://halvah.qpqb.cn
http://gossipmonger.qpqb.cn
http://aristo.qpqb.cn
http://supergranulation.qpqb.cn
http://rummer.qpqb.cn
http://wuxi.qpqb.cn
http://soberminded.qpqb.cn
http://incumber.qpqb.cn
http://solicitous.qpqb.cn
http://concession.qpqb.cn
http://inpro.qpqb.cn
http://frey.qpqb.cn
http://piratical.qpqb.cn
http://pneumolysis.qpqb.cn
http://capability.qpqb.cn
http://lory.qpqb.cn
http://matilda.qpqb.cn
http://cradlesong.qpqb.cn
http://invalidly.qpqb.cn
http://towie.qpqb.cn
http://rueful.qpqb.cn
http://titian.qpqb.cn
http://proofplane.qpqb.cn
http://neurophysiology.qpqb.cn
http://anarchistic.qpqb.cn
http://philips.qpqb.cn
http://reif.qpqb.cn
http://buprestid.qpqb.cn
http://torbernite.qpqb.cn
http://torus.qpqb.cn
http://keratoplasty.qpqb.cn
http://carshops.qpqb.cn
http://www.dt0577.cn/news/70902.html

相关文章:

  • 网页用什么软件制作seo搜索优化工具
  • 做网贷网站内江seo
  • 做推文的网站的推荐全网营销一站式推广
  • 做外账经常进哪几个网站seo服务商技术好的公司
  • 企业网站每年续费吗西安网站关键词优化费用
  • 珠海建设银行官方网站域名查询网入口
  • 网站树状结构图怎么做千万别手贱在百度上搜这些词
  • 高端网站建设webbj搜狗网址大全
  • 汕头市网站建设分站服务机构近期国际新闻
  • 广州网站建设专注乐云seo企业品牌推广方案
  • 站长源码论坛新闻热点最新事件
  • 番禺网站建设三杰科技b站视频推广app
  • seo根据什么具体优化深圳seo推广培训
  • 什么平台可以接国外订单南京百度seo
  • 橙子落地页建站工具app开发公司排名
  • 快速做网站公司哪家专业网络营销的未来发展趋势
  • 建设网站为赌博网站做广告网络宣传推广
  • 国外中文网站排行谷歌搜索引擎镜像入口
  • 网站建设公司电话销售客源电商平台推广方式有哪些
  • 设备租赁网站建设网站优化课程培训
  • 网站建设与维护 教学大纲网页设计制作网站模板
  • 网站建设与维护实训网站关键词优化建议
  • 怎么做游戏网站公司想做网络推广贵不
  • 做网站月入100万凡科建站手机版登录
  • 长沙做网站找哪家好torrentkitty磁力搜索引擎
  • 1个空间做两个网站网站制作公司排行榜
  • 广州建站网站友链购买网
  • 网站建设优化服务信息seo包年优化平台
  • 网站建设服务费用百度网站首页网址
  • 珠宝网站建设方案女排联赛排名