溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

flume package遇到的問(wèn)題

發(fā)布時(shí)間:2020-07-12 15:56:04 來(lái)源:網(wǎng)絡(luò) 閱讀:1838 作者:菜菜光 欄目:大數(shù)據(jù)

flume打包遇到的一些問(wèn)題

1.ipc兼容性問(wèn)題,線上使用2.3.0的hdfs,但是打包時(shí)默認(rèn)為1.2.1的

08 Apr 2015 19:38:25,122 WARN  [SinkRunner-PollingRunner-DefaultSinkProcessor] (org.apache.flume.sink.hdfs.HDFSEventSink.process:455)  - HDFS IO error
org.apache.hadoop.ipc.RemoteException: Server IPC version 9 cannot communicate with client version 4
        at org.apache.hadoop.ipc.Client.call(Client.java:1113)
        at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:229)

拷貝hadoop-core包即可,或者更改pom.xml文件

      <properties>
        <hadoop.version>1.2.1</hadoop.version> //hadoop-core-1.2.1.jar  改為hadoop-core-2.3.0-mr1-cdh6.1.0.jar
        <hbase.version>0.92.1</hbase.version>
        <hadoop.common.artifact.id>hadoop-core</hadoop.common.artifact.id>
        <thrift.version>0.7.0</thrift.version>
      </properties>

或者打包時(shí)指定:

mvn clean install -Phadoop-2

2.沒(méi)有跳過(guò)test時(shí)

org.apache.flume.auth.TestFlumeAuthenticator: org/apache/commons/io/Charsets (no class error)

根目錄下的pom.xml文件中更改為:

<dependency>
   <groupId>commons-io</groupId>
   <artifactId>commons-io</artifactId>
   <version>2.4</version> //2.1的包沒(méi)有Charsets這個(gè)類
</dependency>

如果手動(dòng)下載jar包可以使用如下命令導(dǎo)入:

mvn install:install-file -DgroupId=commons-io -DartifactId=commons-io -Dversion=2.0.1 -Dpackaging=jar -Dfile=commons-io-2.4.jar

3. 程序語(yǔ)言問(wèn)題,因?yàn)樵谙到y(tǒng)中使用了中文環(huán)境導(dǎo)致編譯不通過(guò)

1)

@Test
  public void shouldUseUtcAsBasisForDateFormat() {
    assertEquals("Coordinated Universal Time",
        factory.fastDateFormat.getTimeZone().getDisplayName()); //請(qǐng)求英文,返回中文
  }
...

2)

Running org.apache.flume.source.twitter.TestTwitterSource
Tests run: 2, Failures: 0, Errors: 1, Skipped: 1, Time elapsed: 0.247 sec <<< FAILURE!
testCarrotDateFormatBug(org.apache.flume.source.twitter.TestTwitterSource)  Time elapsed: 21 sec  <<< ERROR!
java.text.ParseException: Unparseable date: "Fri Oct 26 22:53:55 +0000 2012"
   at java.text.DateFormat.parse(DateFormat.java:357)
   at org.apache.flume.source.twitter.TestTwitterSource.testCarrotDateFormatBug(TestTwitterSource.java:109)

代碼:

@Test
  public void testCarrotDateFormatBug() throws Exception {
    SimpleDateFormat formatterFrom = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy"); //更改為new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy",Locale.US);
    formatterFrom.parse("Fri Oct 26 22:53:55 +0000 2012");
  }


或者簡(jiǎn)單點(diǎn),更改語(yǔ)言設(shè)置或者直接skip test

mvn clean install -Phadoop-2 -DskipTests


4.json問(wèn)題

替換單個(gè)jar包時(shí),因?yàn)橐蕾噯?wèn)題,包c(diǎn)lass not found:

Exception in thread "PollableSourceRunner-KafkaSource-kafka1" java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher
        at org.apache.flume.source.kafka.KafkaSourceUtil.getDateMessage(KafkaSourceUtil.java:117)
        at org.apache.flume.source.kafka.KafkaSource.process(KafkaSource.java:123)
        at org.apache.flume.source.PollableSourceRunner$PollingRunner.run(PollableSourceRunner.java:139)
        at java.lang.Thread.run(Thread.java:745)

可以打成ensmbly包

flume-1.6.0/flume-ng-sources/flume-kafka-source/pom.xml
<dependency>
   <groupId>net.sf.json-lib</groupId>
   <artifactId>json-lib</artifactId>
   <version>2.4</version>
   <classifier>jdk15</classifier>
</dependency>

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.4</version>
    <configuration>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
    </configuration>
    <executions>
      <execution>
        <id>make-assembly</id>
        <phase>package</phase>
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

或者拷貝jar包:

/Users/nizengguang/.m2/repository/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6.jar
/Users/nizengguang/.m2/repository/net/sf/json-lib/json-lib/2.4/json-lib-2.4-jdk15.jar
/Users/nizengguang/.m2/repository/commons-beanutils/commons-beanutils/1.8.0/commons-beanutils-1.8.0.jar
/Users/nizengguang/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
/Users/nizengguang/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
/Users/nizengguang/.m2/repository/commons-lang/commons-lang/2.5/commons-lang-2.5.jar

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI