flume 写入文件服务器,Flume环境配置以及基本操作

flume的作用是从接受外界的日志信息,然后输出到本地的一个框架。

agent是Flume很重要的组成,包括有source,channel,sink。

source是从外部接受日志。

channel跟内存相似,读满了之后再写到sink中。

sink是将数据写到本地,可以写在HDFS上也能先写在Fafka等等。

配置

1.

首先下载包,解压,并将bin路径配置到~/.bash_profile

复制flume-env.sh.template配置文件并修改,指定jdk的路径。

2.

在conf文件夹下新建conf文件:

# example.conf: A single-node Flume configuration

# Name the components on this agent

a1.sources=r1

a1.sinks=k1

a1.channels=c1

#Describe/configure the source

a1.sources.r1.type=netcat

a1.sources.r1.bind=localhost

a1.sources.r1.port=44444

# Describe the sink

a1.sinks.k1.type=logger

# Use a channel which buffers events in memory

a1.channels.c1.type=memory

a1.channels.c1.capacity=1000

a1.channels.c1.transactionCapacity=100

# Bind the source and sink to the channel

a1.sources.r1.channels=c1

a1.sinks.k1.channel=c1

启动agent

flume-ng agent \

--name a1 \

--conf $FLUME_HOME/conf \

--conf-file $FLUME_HOME/conf/example.conf \

-Dflume.root.logger=INFO.console

在另一个控制台里输入telnet hadoop000 44444 输入些文字测试。。。

以上是Flume监听端口信息,接下来实时监听本地文件信息:

只需将#Describe/configure the source下的三行改为:

a1.sources.r1.type = exec

a1.sources.r1.command = tail -F /home/hadoop/data/data.log

a1.sources.r1.shell = /bin/sh -C

在conf目录下新建 exec-memory-logger.conf文件写入以上配置信息,然后启动agent。

flume-ng agent \

--name a1 \

--conf $FLUME_HOME/conf \

--conf-file $FLUME_HOME/conf/exec-memory-logger.conf \

-Dflume.root.logger=INFO.console

在另一个控制台里往data.log里写数据

echo hello >> data.log

echo world >> data.log

这样agent就会输出日志信息了。

接下来将A服务器上的日志实时采集到B服务器上、

54662417204c

图1

机器A的conf配置:

# exec-memory-avro.conf:

# Name the components on this agent

exec-memory-avro.sources=exec-source

exec-memory-avro.sinks=avro-sink

exec-memory-avro.channels= memory-channel

#Describe/configure the source

exec-memory-avro.sources.exec-source.type=exec

exec-memory-avro.sources.exec-source.command=tail -F /home/hadoop/data/data.log

exec-memory-avro.sources.exec-source.shell= /bin/sh -c

# Describe the sink

exec-memory-avro.sinks.avro-sink.type=avro

exec-memory-avro.sinks.avro-sink.hostname = hadoop000

exec-memory-avro.sinks.avro-sink.port = 44444

# Use a channel which buffers events in memory

exec-memory-avro.channels.memory-channel.type=memory

# Bind the source and sink to the channel

exec-memory-avro.sources.exec-source.channels=memory-channel

exec-memory-avro.sinks.avro-sink.channel=memory-channel

机器B的conf文件:

avro-memory-logger.sources = avro-source

avro-memory-logger.sinks = logger-sink

avro-memory-logger.channels = memory-channel

avro-memory-logger.sources.avro-source.type = avro

avro-memory-logger.sources.avro-source.bind = hadoop000

avro-memory-logger.sources.avro-source.port = 44444

avro-memory-logger.sinks.logger-sink.type = logger

avro-memory-logger.channels.memory-channel.type = memory

avro-memory-logger.sources.avro-source.channels = memory-channel

avro-memory-logger.sinks.logger-sink.channel = memory-channel

配置完成。先启动机器B(第一个控制台):

flume-ng agent \

--name avro-memory-logger \

--conf $FLUME_HOME/conf \

--conf-file $FLUME_HOME/conf/avro-memory-logger.conf \

-Dflume.root.logger=INFO,console

再启动机器A

(第二个控制台)

flume-ng agent \

--name exec-memory-avro \

--conf $FLUME_HOME/conf \

--conf-file $FLUME_HOME/conf/exec-memory-avro.conf \

-Dflume.root.logger=INFO,console

在第三个控制台的data目录输入echo welcome >> data.log

第一个控制台就会有日志信息显示了。。。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/564066.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C 字符串个数

C语言求字符串个数。 使用C语言获取输入的字符串并计算字符串的个数在控制台输出显示字符串个数。 完整代码 #include <stdio.h> #include <stdlib.h> int main() {int len;char str[20];printf("请输入字符串:\n");scanf("%s",str);lenlen…

Redis发布订阅模式

使用银行卡消费的时候&#xff0c;银行往往会通过微信、短信或邮件通知用户这笔交易的信息&#xff0c;这便是一种发布订阅模式&#xff0c;这里的发布是交易信息的发布&#xff0c;订阅则是各个渠道。这在实际工作中十分常用&#xff0c;Redis 支持这样的一个模式。 发布订阅…

css的属性是变量是怎么表达,CSS自定义变量属性——像less,sass那样在css中使用变量(译)...

初步使用:root {--main-color: #06c;--accent-color: #006;}/* The rest of the CSS file */#foo h1 {//引用变量color: var(--main-color);}以下使用方法错误&#xff01;&#xff01;&#xff01;他错误地尝试使用变量名代替属性名&#xff1a;.foo {--side: margin-top;var(…

Redis的超时命令和垃圾回收策略

正如 Java 虚拟机&#xff0c;它提供了自动 GC&#xff08;垃圾回收&#xff09;的功能&#xff0c;来保证 Java 程序使用过且不再使用的 Java 对象及时的从内存中释放掉&#xff0c;从而保证内存空间可用。 当程序编写不当或考虑欠缺的时候&#xff08;比如读入大文件&#x…

小米微信无法连接到服务器1-10087,微信无法连接到服务器【搞定方向】

win7系统电脑使用过程中有不少朋友表示遇到过微信无法连接到服务器的状况&#xff0c;当出现微信无法连接到服务器怎么样才能快速解决呢&#xff1f;其实解决微信无法连接到服务器也是非常简单的。网上有各种各样的解决方法&#xff0c;我给大家详细介绍一下关于微信无法连接到…

服务器虚拟机的固定ip怎么设置,虚拟机还能设置静态ip?Vmware 虚拟机配置全攻略...

前言&#xff1a;虚拟机应该是我们大多数人都会接触到的&#xff0c;尽管目前虚拟机的配置都十分简单便捷&#xff0c;几乎可以说是上手即用。但是对于一些较不常用的操作&#xff0c;可能配置起来还是会繁琐一些&#xff0c;比如解锁 macOS 的安装限制 &#xff0c;设置 静态 …

Redis流水线性能提高

我们希望在没有任何附加条件的场景下去使用队列批量执行一系列的命令&#xff0c;从而提高系统性能&#xff0c;这就是 Redis 的流水线&#xff08;pipelined&#xff09;技术。而现实中 Redis 执行读/写速度十分快&#xff0c;而系统的瓶颈往往是在网络通信中的延时&#xff0…

ajax离开页面方法,如果用户在页面加载完成之前离开页面,则触发jQuery ajaxError()处理程序...

我们使用jQuery的全局ajaxError()处理函数来警告用户任何AJAX失败&#xff1a;$(document).ajaxError(function() {$("There was a network or server error. Please try again later.").dialog({title: "Error",modal: true,resizable: false,buttons: { …

Redis中使用Lua语言

在 Redis 的 2.6 以上版本中&#xff0c;除了可以使用命令外&#xff0c;还可以使用 Lua 语言操作 Redis。从前面的命令可以看出 Redis 命令的计算能力并不算很强大&#xff0c;而使用 Lua 语言则在很大程度上弥补了 Redis 的这个不足。 只是在 Redis 中&#xff0c;执行 Lua …

服务器预装操作系统,服务器预装操作系统吧

服务器预装操作系统吧 内容精选换一换镜像是一个包含了软件及必要配置的服务器或磁盘模版&#xff0c;包含操作系统或业务数据&#xff0c;还可以包含应用软件(例如&#xff0c;数据库软件)和私有软件。镜像分为公共镜像、私有镜像、共享镜像、市场镜像。镜像服务(Image Manage…

Redis的两种备份方式:RDB和AOF

在 Redis 中存在两种方式的备份&#xff1a;一种是快照恢复&#xff08;RDB&#xff09;&#xff0c;通过快照&#xff08;snapshotting&#xff09;实现的&#xff0c;它是备份当前瞬间 Redis 在内存中的数据记录。 另一种是只追加文件&#xff08;Append-Only File&#xff…

C 创建链表

C语言创建链表 完整代码 #include<stdio.h> #include<stdlib.h> #include<malloc.h> typedef struct LNode{int data;struct LNode *next; }LNode,*LinkList;LinkList CreateList(int n); void print(LinkList h); int main() {LinkList HeadNULL…

刀片服务器显示连接线,通过浏览器对刀片服务器进行管理

为了通过浏览器的方式对刀片服务器进行管理&#xff0c;第一步是通过cat5类线连接管理模块的以太网口&#xff0c;或者通过直连线进行连接。在浏览器中敲入管理模块的固定ip 地址(192.168.70.125)进行连接&#xff0c;如果存在dhcp服务&#xff0c;需要在dhcp服务器端查看管理模…

Redis内存回收策略

Redis 也会因为内存不足而产生错误&#xff0c;也可能因为回收过久而导致系统长期的停顿&#xff0c;因此掌握执行回收策略十分有必要。在 Redis 的配置文件中&#xff0c;当 Redis 的内存达到规定的最大值时&#xff0c;允许配置 6 种策略中的一种进行淘汰键值&#xff0c;并且…

visual报表服务器项目,为 Visual Studio ALM 创建报表服务器项目

为 Visual Studio ALM 创建报表服务器项目06/09/2015本文内容通过使用 SQL Server 报表设计器来创建报表可以跟踪团队的进度。 在可以使这些报表基于 Visual Studio Team Foundation Server (TFS) 中的数据之前&#xff0c;必须首先在 Visual Studio 中创建一个报表服务器项目。…

Redis悲观锁、乐观锁和调用Lua脚本的优缺点

悲观锁使用了数据库的锁机制&#xff0c;可以消除数据不一致性&#xff0c;对于开发者而言会十分简单&#xff0c;但是&#xff0c;使用悲观锁后&#xff0c;数据库的性能有所下降&#xff0c;因为大量的线程都会被阻塞&#xff0c;而且需要有大量的恢复过程&#xff0c;需要进…

从RedisTemplate中获得Jedis实例

很多时候&#xff0c;我们也许需要使用一些更为高级的缓存服务器的 API&#xff0c;如 Redis 的流水线、事务和 Lua 语言等&#xff0c;所以也许会使用到 RedisTemplate 本身。 首先&#xff0c;定义 RedisTemplateService 的接口&#xff0c;代码如下所示。 package com.ser…

Spring整合Redis详解

用注解驱动的方式来使用 Redis。和数据库事务一样&#xff0c;Spring 提供了缓存的管理器和相关的注解来支持类似于 Redis 这样的键值对缓存。 准备测试环境 首先&#xff0c;定义一个简单的角色 POJO&#xff0c;代码如下所示。 package com.pojo; import java.io.Serializ…

Redis和数据库的结合

使用 Redis 可以优化性能&#xff0c;但是存在 Redis 的数据和数据库同步的问题&#xff0c;这是我们需要关注的问题。假设两个业务逻辑都是在操作数据库的同一条记录&#xff0c;而 Redis 和数据库不一致。 Redis 和数据库不一致 在图中&#xff0c;T1 时刻以键 key1 保存数…

C 字符串排序

使用C语言对字符串进行排序 编写程序对字符串进行排序输出&#xff0c;用户根据提示输入三个字符串&#xff0c;程序根据26个英文字母的顺序进行排序输出。 完整代码 #include<stdio.h> #include<stdlib.h> #include <string.h>void swap(char*str1,char*…