Spark-寒假-实验6

1、flume安装

  1)上传压缩包并解压

    Spark-寒假-实验6

 

  2)文件配置

    flume-env.sh

# 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/java/jdk1.8.0_301
export HADOOP_HOME=/opt/Hadoop/hadoop-2.7.3

 

Spark-寒假-实验6

 

  3)启动测试

    Spark-寒假-实验6

 

2. 使用 Avro 数据源测试 Flume

  1)在flume安装目录下conf文件夹中创建文件:

    zavro.conf:

a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.channels = c1
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port = 4141

# 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

  Spark-寒假-实验6

  2)在flume安装目录下创建helloworld.txt文件:

    helloworld.txt:

helloworld

  3)运行(右边为第一个终端,左边为第二个终端):

    在第一个终端下运行:

./bin/flume-ng agent agent -c conf -f ./conf/avro.conf -n a1 -Dflume.root.logger=INFO,console

    在第二个终端下运行:

./bin/flume-ng avro-client -H localhost -p 4141 -F ./helloworld.txt

Spark-寒假-实验6

3. 使用 netcat 数据源测试 Flume

  1)创建文件

    example.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

    Spark-寒假-实验6

 

  2)运行测试(右边为第一个终端,左边为第二个终端):

    在第一个终端下运行:

./bin/flume-ng agent --conf ./conf --conf-file ./conf/example.conf --name a1 -Dflume.root.logger=INFO,console

    在第二个终端下运行:

  

telnet localhost 44444

Spark-寒假-实验6

 

上一篇:gem 更换源及目前能用的源


下一篇:IDEA下载源码报错java.lang.RuntimeException: Cannot reconnect.的解决办法