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

一、编译
首先下载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 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
a1.sources.r1.channels = c1

# Describe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1

# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

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

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

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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值