美文网首页
尚硅谷大数据技术之Flume

尚硅谷大数据技术之Flume

作者: 尚硅谷教育 | 来源:发表于2018-12-04 14:23 被阅读15次

    3)实现步骤:

    1.安装telnet工具

    将rpm软件包(xinetd-2.3.14-40.el6.x86_64.rpm、telnet-0.17-48.el6.x86_64.rpm和telnet-server-0.17-48.el6.x86_64.rpm)拷入/opt/software文件夹下面。执行RPM软件包安装命令:

    [atguigu@hadoop102 software]$ sudo rpm -ivh xinetd-2.3.14-40.el6.x86_64.rpm

    [atguigu@hadoop102 software]$ sudo rpm -ivh telnet-0.17-48.el6.x86_64.rpm

    [atguigu@hadoop102 software]$ sudo rpm -ivh telnet-server-0.17-48.el6.x86_64.rpm

    2.判断44444端口是否被占用

    [atguigu@hadoop102 flume-telnet]$ sudo netstat -tunlp | grep 44444

    功能描述:netstat命令是一个监控TCP/IP网络的非常有用的工具,它可以显示路由表、实际的网络连接以及每一个网络接口设备的状态信息。

    基本语法:netstat [选项]

    选项参数:

    -t或--tcp:显示TCP传输协议的连线状况;

    -u或--udp:显示UDP传输协议的连线状况;

    -n或--numeric:直接使用ip地址,而不通过域名服务器;

    -l或--listening:显示监控中的服务器的Socket;

    -p或--programs:显示正在使用Socket的程序识别码和程序名称;

    3.创建Flume Agent配置文件flume-telnet-logger.conf

    在flume目录下创建job文件夹并进入job文件夹。

    [atguigu@hadoop102 flume]$ mkdir job

    [atguigu@hadoop102 flume]$ cd job/

    在job文件夹下创建Flume Agent配置文件flume-telnet-logger.conf。

    [atguigu@hadoop102 job]$ touch flume-telnet-logger.conf

    在flume-telnet-logger.conf文件中添加如下内容。

    [atguigu@hadoop102 job]$ vim flume-telnet-logger.conf

    添加内容如下:

    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

    注:配置文件来源于官方手册http://flume.apache.org/FlumeUserGuide.html

    image.png
    1. 先开启flume监听端口
      [atguigu@hadoop102 flume]bin/flume-ng agent --conf conf/ --name a1 --conf-file job/flume-telnet-logger.conf -Dflume.root.logger=INFO,console 参数说明: --conf conf/ :表示配置文件存储在conf/目录 --name a1 :表示给agent起名为a1 --conf-file job/flume-telnet.conf :flume本次启动读取的配置文件是在job文件夹下的flume-telnet.conf文件。 -Dflume.root.logger==INFO,console :-D表示flume运行时动态修改flume.root.logger参数属性值,并将控制台日志打印级别设置为INFO级别。日志级别包括:log、info、warn、error。 5.使用telnet工具向本机的44444端口发送内容 [atguigu@hadoop102 ~] telnet localhost 44444

    6.在Flume监听页面观察接收数据情况

    image.png

    本教程由尚硅谷教育大数据研究院出品,如需转载请注明来源,欢迎大家关注尚硅谷公众号(atguigu)了解更多。

    相关文章

      网友评论

          本文标题:尚硅谷大数据技术之Flume

          本文链接:https://www.haomeiwen.com/subject/oubmcqtx.html