Flume NG写入数据到Hbase中的问题

发布于 2022-09-03 15:32:01 字数 4512 浏览 14 评论 0

安装的软件版本

hadoop-2.6.4
flume-1.6.0
hbase-1.2.3

hbase-site.xml配置

<configuration>
    <property>
        <name>hbase.rootdir</name>
        <value>hdfs://master2:9000/hbase</value>
    </property>
    <property>    
        <name>hbase.cluster.distributed</name>
        <value>true</value>
    </property>
    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>slave1,slave2,slave3</value>
    </property>
    <property>
        <name>hbase.master.info.port</name>
        <value>60010</value>    
    </property>
    <property>
        <name>hbase.zookeeper.property.dataDir</name>
        <value>/home/hadoop/tmp/zookeeper/datas</value>
    </property>
</configuration>

flume-conf.properties配置

agent1.sources = s1
agent1.channels = fc1
agent1.sinks = k1

#
agent1.sources.s1.channels = fc1
agent1.sources.s1.type = avro
agent1.sources.s1.bind = 192.168.1.11
agent1.sources.s1.port = 44446
agent1.sources.s1.threads = 8

# file channel
agent1.channels.fc1.type = file
agent1.channels.fc1.checkpointDir = /home/hadoop/tmp/flume/fc1/checkpoint
agent1.channels.fc1.useDualCheckpoints = true
agent1.channels.fc1.backupCheckpointDir = /home/hadoop/tmp/flume/fc1/backups
agent1.channels.fc1.dataDirs = /home/hadoop/tmp/flume/fc1/datas
agent1.channels.fc1.transactionCapacity = 100000
agent1.channels.fc1.capacity = 500000
agent1.channels.fc1.checkpointInterval = 60000
agent1.channels.fc1.keep-alive = 5
agent1.channels.fc1.maxFileSize = 5368709120

## 写入Hbase数据库
agent1.sinks.k1.type = hbase
agent1.sinks.k1.channel = fc1
agent1.sinks.k1.table = admin_operation_logs
agent1.sinks.k1.columnFamily = context
agent1.sinks.k1.serializer = org.apache.flume.sink.hbase.RegexHbaseEventSerializer

报错信息

19 Sep 2016 05:24:28,146 ERROR [SinkRunner-PollingRunner-DefaultSinkProcessor] (org.apache.flume.sink.hbase.HBaseSink.process:351)  - Failed to commit transaction.Transaction rolled back.
java.lang.NoSuchMethodError: org.apache.hadoop.hbase.client.Put.setWriteToWAL(Z)V
    at org.apache.flume.sink.hbase.HBaseSink$3.run(HBaseSink.java:377)
    at org.apache.flume.sink.hbase.HBaseSink$3.run(HBaseSink.java:372)
    at org.apache.flume.auth.SimpleAuthenticator.execute(SimpleAuthenticator.java:50)
    at org.apache.flume.sink.hbase.HBaseSink.putEventsAndCommit(HBaseSink.java:372)
    at org.apache.flume.sink.hbase.HBaseSink.process(HBaseSink.java:342)
    at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
    at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
    at java.lang.Thread.run(Thread.java:745)
19 Sep 2016 05:24:28,148 ERROR [SinkRunner-PollingRunner-DefaultSinkProcessor] (org.apache.flume.sink.hbase.HBaseSink.process:354)  - Failed to commit transaction.Transaction rolled back.
java.lang.NoSuchMethodError: org.apache.hadoop.hbase.client.Put.setWriteToWAL(Z)V
    at org.apache.flume.sink.hbase.HBaseSink$3.run(HBaseSink.java:377)
    at org.apache.flume.sink.hbase.HBaseSink$3.run(HBaseSink.java:372)
    at org.apache.flume.auth.SimpleAuthenticator.execute(SimpleAuthenticator.java:50)
    at org.apache.flume.sink.hbase.HBaseSink.putEventsAndCommit(HBaseSink.java:372)
    at org.apache.flume.sink.hbase.HBaseSink.process(HBaseSink.java:342)
    at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
    at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
    at java.lang.Thread.run(Thread.java:745)

错误信息提示java.lang.NoSuchMethodError: org.apache.hadoop.hbase.client.Put.setWriteToWAL(Z)V,可是我查看源码是ort.apache.hadoop.hbase.client.Put里有setWriteToWAL(boolean write)这个方法!但是setWriteWAL方法里调用父类Mutation的setWriteWAL方法,而父类里的这个方法执行了setDurability()方法,这个方法的传入的是枚举类型Durability类,但真正传入的是boolean 类型,我想应该是这里出错了。版本兼容问题
我用的hbases是v1.2.3版,最高版本,但是还是不行,同样会出现这个异常。

Mutation类

  @Deprecated
  public Mutation setWriteToWAL(boolean write)
  {
    setDurability((write) ? Durability.USE_DEFAULT : Durability.SKIP_WAL);
    return this;
  }

  public Mutation setDurability(Durability d)
  {
    this.durability = d;
    return this;
  }
  

有谁遇到过这个问题!帮忙看一下!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾其所爱 2022-09-10 15:32:01

我测试过了, 把flume升级到1.7即可

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文