flume1.7源码编译及main方法启动

来源:互联网 发布:西安 人工智能 编辑:程序博客网 时间:2024/05/24 03:53

一、编译
首先下载flume1.7源码,导入eclipse

1.Maven依赖报错Missing artifact jdk.tools:jdk.tools:jar:1.7

添加依赖

<dependency>      <groupId>jdk.tools</groupId>      <artifactId>jdk.tools</artifactId>      <version>1.7</version>      <scope>system</scope>      <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>  </dependency> 

2.eclipse校验提示错误
这里写图片描述

原因:AvroFlumeEvent类是编译生成的,eclipse依赖找不到正常,没影响

3.运行
mvn install -Dmaven.test.skip=true -Dtar

编译成功后会在flume-ng-dist/target下生成tar包
这里写图片描述

4.仓库不全的话有些包下不到需手动添加,也可以直接注释不需要的插件依赖
手动添加方法:

  • 首先,到 http://mvnrepository.com/ 这个网,在搜索栏中输入你要搜索的 JAR 包关键字

  • 运行 mvn install:install-file -Dfile=E:\xxx\xxx.jar -DgroupId=xxx
    -DartifactId=xxx -Dversion=xxx -Dpackaging=jar

二、启动
1.flume-ng-node根目录下创建test.properties

# example.conf: A single-node Flume configuration# Name the components on this agenta1.sources = r1a1.sinks = k1a1.channels = c1# Describe/configure the sourcea1.sources.r1.type = netcata1.sources.r1.bind = localhosta1.sources.r1.port = 44444a1.sources.r1.channels = c1# Describe the sinka1.sinks.k1.type = loggera1.sinks.k1.channel = c1# Use a channel which buffers events in memorya1.channels.c1.type = memorya1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 100

2.创建src/main/resources资源文件夹,复制根目录conf下log4j文件放进去,修改日志级别
这里写图片描述

3.设置Application运行参数 -n a1 -f test.conf
这里写图片描述

4.启动Application
使用telnet命令就可以测试了

5.启动可能报错没有相关类

原因:flume-ng-node默认依赖可能不包括该插件
比如kafka sink需在pom.xml增加依赖

    <dependency>      <groupId>org.apache.flume.flume-ng-sinks</groupId>      <artifactId>flume-ng-kafka-sink</artifactId>    </dependency>
0 0
原创粉丝点击