前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >大数据-Flume的负载均衡

大数据-Flume的负载均衡

作者头像
cwl_java
发布2019-12-26 16:08:40
8730
发布2019-12-26 16:08:40
举报
文章被收录于专栏:cwl_Javacwl_Java

4. Flume 的负载均衡

负载均衡是用于解决一台机器(一个进程)无法解决所有请求而产生的一种算法。Load balancing Sink Processor 能够实现 load balance 功能,如下图Agent1 是一个路由节点,负责将 Channel 暂存的 Event 均衡到对应的多个 Sink组件上,而每个 Sink 组件分别连接到一个独立的 Agent 上,示例配置, 如下所示:

在这里插入图片描述
在这里插入图片描述

在此处我们通过三台机器来进行模拟flume的负载均衡 三台机器规划如下:

  • node01:采集数据,发送到node02和node03机器上去
  • node02:接收node01的部分数据
  • node03:接收node01的部分数据.

第一步:开发node01服务器的flume配置

node01服务器配置:

cd /export/servers/apache-flume-1.8.0-bin/conf 
vim load_banlancer_client.conf
# agent name 
<p class="mume-header " id="agent-name"></p> 
a1.channels = c1 
a1.sources = r1 
a1.sinks = k1 k2 
# set gruop 
<p class="mume-header " id="set-gruop"></p> 
a1.sinkgroups = g1 
# set channel 
<p class="mume-header " id="set-channel"></p> 
a1.channels.c1.type = memory 
a1.channels.c1.capacity = 1000 
a1.channels.c1.transactionCapacity = 100 
a1.sources.r1.channels = c1 
a1.sources.r1.type = exec 
a1.sources.r1.command = tail -F /export/servers/taillogs/access_log 
# set sink1 
<p class="mume-header " id="set-sink1"></p> 
a1.sinks.k1.channel = c1 
a1.sinks.k1.type = avro 
a1.sinks.k1.hostname = node02 
a1.sinks.k1.port = 52020 
# set sink2 
<p class="mume-header " id="set-sink2"></p> 
a1.sinks.k2.channel = c1 
a1.sinks.k2.type = avro
a1.sinks.k2.hostname = node03 
a1.sinks.k2.port = 52020 
# set sink group 
<p class="mume-header " id="set-sink-group"></p> 
a1.sinkgroups.g1.sinks = k1 k2 
# set failover 
<p class="mume-header " id="set-failover"></p> 
a1.sinkgroups.g1.processor.type = load_balance 
a1.sinkgroups.g1.processor.backoff = true 
a1.sinkgroups.g1.processor.selector = round_robin 
a1.sinkgroups.g1.processor.selector.maxTimeOut=10000

第二步:开发node02服务器的flume配置

cd /export/servers/apache-flume-1.8.0-bin/conf 
vim load_banlancer_server.conf
# Name the components on this agent 
<p class="mume-header " id="name-the-components-on-this-agent"></p> 
a1.sources = r1 
a1.sinks = k1 
a1.channels = c1 
# Describe/configure the source 
<p class="mume-header " id="describeconfigure-the-source"></p> 
a1.sources.r1.type = avro 
a1.sources.r1.channels = c1 
a1.sources.r1.bind = node02 
a1.sources.r1.port = 52020 
# Describe the sink 
<p class="mume-header " id="describe-the-sink"></p> 
a1.sinks.k1.type = logger 
# Use a channel which buffers events in memory 
<p class="mume-header " id="use-a-channel-which-buffers-events-in-memory"></p> 
a1.channels.c1.type = memory 
a1.channels.c1.capacity = 1000 
a1.channels.c1.transactionCapacity = 100 
# Bind the source and sink to the channel 
<p class="mume-header " id="bind-the-source-and-sink-to-the-channel"></p> 
a1.sources.r1.channels = c1 
a1.sinks.k1.channel = c1

第三步:开发node03服务器flume配置

node03服务器配置

cd /export/servers/apache-flume-1.8.0-bin/conf 
vim load_banlancer_server.conf
# Name the components on this agent 
<p class="mume-header " id="name-the-components-on-this-agent-1"></p> 
a1.sources = r1 
a1.sinks = k1 
a1.channels = c1 
# Describe/configure the source 
<p class="mume-header " id="describeconfigure-the-source-1"></p> 
a1.sources.r1.type = avro 
a1.sources.r1.channels = c1 
a1.sources.r1.bind = node03 
a1.sources.r1.port = 52020 
# Describe the sink 
<p class="mume-header " id="describe-the-sink-1"></p> 
a1.sinks.k1.type = logger 
# Use a channel which buffers events in memory 
<p class="mume-header " id="use-a-channel-which-buffers-events-in-memory-1"></p> 
a1.channels.c1.type = memory 
a1.channels.c1.capacity = 1000 
a1.channels.c1.transactionCapacity = 100 
# Bind the source and sink to the channel 
<p class="mume-header " id="bind-the-source-and-sink-to-the-channel-1"></p> 
a1.sources.r1.channels = c1 
a1.sinks.k1.channel = c1

第四步:准备启动flume服务

启动node03的flume服务

cd /export/servers/apache-flume-1.8.0-bin bin/flume-ng agent -n a1 -c conf -f conf/load_banlancer_server.conf -Dflume.root.logger

启动node02的flume服务

cd /export/servers/apache-flume-1.8.0-bin bin/flume-ng agent -n a1 -c conf -f conf/load_banlancer_server.conf -Dflume.root.logger

启动node01的flume服务

cd /export/servers/apache-flume-1.8.0-bin bin/flume-ng agent -n a1 -c conf -f conf/load_banlancer_client.conf -Dflume.root.logger

第五步:node01服务器运行脚本产生数据

cd /export/servers/shells
sh tail-file.sh
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 4. Flume 的负载均衡
    • 第一步:开发node01服务器的flume配置
      • 第二步:开发node02服务器的flume配置
        • 第三步:开发node03服务器flume配置
          • 第四步:准备启动flume服务
            • 第五步:node01服务器运行脚本产生数据
            相关产品与服务
            负载均衡
            负载均衡(Cloud Load Balancer,CLB)提供安全快捷的流量分发服务,访问流量经由 CLB 可以自动分配到云中的多台后端服务器上,扩展系统的服务能力并消除单点故障。负载均衡支持亿级连接和千万级并发,可轻松应对大流量访问,满足业务需求。
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档