flume打包遇到的一些問(wèn)題
創(chuàng)新互聯(lián)建站-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比遼陽(yáng)縣網(wǎng)站開(kāi)發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式遼陽(yáng)縣網(wǎng)站制作公司更省心,省錢(qián),快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋遼陽(yáng)縣地區(qū)。費(fèi)用合理售后完善,十多年實(shí)體公司更值得信賴。
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文件
1.2.1 //hadoop-core-1.2.1.jar 改為hadoop-core-2.3.0-mr1-cdh6.1.0.jar0.92.1 hadoop-core 0.7.0
或者打包時(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文件中更改為:
commons-io commons-io 2.4 //2.1的包沒(méi)有Charsets這個(gè)類(lèi)
如果手動(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.xmlnet.sf.json-lib json-lib 2.4 jdk15
maven-assembly-plugin 2.4 jar-with-dependencies make-assembly package single
或者拷貝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