2

EMRクラスターでhadoopジョブを実行しようとしています。それは私がjar-with-dependenciesを使用するJavaコマンドとして実行されています。ジョブはTeradataからデータを取得し、Teradata関連のjarもjar-with-dependencies内に格納されていると仮定しています。しかし、私はまだ例外を取得しています:AWS EMRカスタムjarアプリケーションで追加のjarを指定する

Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.teradata.jdbc.TeraDriver 
at org.apache.hadoop.mapreduce.lib.db.DBInputFormat.setConf(DBInputFormat.java:171) 

は私のpomは、以下の関連の依存関係があります。

<dependency> 
    <groupId>teradata</groupId> 
    <artifactId>terajdbc4</artifactId> 
    <version>14.10.00.17</version> 
</dependency> 

<dependency> 
    <groupId>teradata</groupId> 
    <artifactId>tdgssconfig</artifactId> 
    <version>14.10.00.17</version> 
</dependency> 

下のように私は完全なjarファイルをパッケージ化しています:

<build> 
    <plugins> 
     <plugin> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>3.1</version> 
     <configuration> 
      <source>1.8</source> 
      <target>1.8</target> 
      <compilerArgument>-Xlint:-deprecation</compilerArgument> 
     </configuration> 
     </plugin> 

     <plugin> 
     <artifactId>maven-assembly-plugin</artifactId> 
     <version>2.2.1</version> 

     <configuration> 
      <descriptors> 
      </descriptors> 
      <archive> 
      <manifest> 
      </manifest> 
      </archive> 
      <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> 

    </plugins> 
    </build> 

assembly.xmlファイル:

<assembly> 
    <id>aws-emr</id> 
    <formats> 
     <format>jar</format> 
    </formats> 
    <includeBaseDirectory>false</includeBaseDirectory> 
    <dependencySets> 
     <dependencySet> 
      <unpack>false</unpack> 
      <includes> 
      </includes> 
      <scope>runtime</scope> 
      <outputDirectory>lib</outputDirectory> 
     </dependencySet> 
     <dependencySet> 
      <unpack>true</unpack> 
      <includes> 
       <include>${groupId}:${artifactId}</include> 
      </includes> 
     </dependencySet> 
    </dependencySets> 
</assembly> 
EMRのコマンドを実行

aws emr create-cluster --release-label emr-5.3.1 \ 
--instance-groups \ 
    InstanceGroupType=MASTER,InstanceCount=1,InstanceType=m3.xlarge \ 
    InstanceGroupType=CORE,InstanceCount=5,BidPrice=0.1,InstanceType=m3.xlarge \ 
--service-role EMR_DefaultRole --log-uri s3://my-bucket/logs \ 
--applications Name=Hadoop --name TeradataPullerTest \ 
--ec2-attributes <ec2-attributes> \ 

--steps Type=CUSTOM_JAR,Name=EventsPuller,Jar=s3://path-to-jar-with-dependencies.jar,\ 
Args=[com.my.package.EventsPullerMR],ActionOnFailure=TERMINATE_CLUSTER \ 
--auto-terminate 

は、私はマップ-削減ジョブを実行しながら、それらをクラスパスに追加されているようなのTeradataのjarファイルを指定することができる方法はありますか?

EDIT:欠落しているクラスがjar-with-dependenciesにパッケージされていることを確認しました。

aws-emr$ jar tf target/aws-emr-0.0.1-SNAPSHOT-jar-with-dependencies.jar | grep TeraDriver 
com/ncr/teradata/TeraDriver.class 
com/teradata/jdbc/TeraDriver.class 

答えて

0

私はまだこの問題を完全には解決していませんが、この作業を行う方法を発見しました。理想的な解決策は、ウベアジャー内のテラデータジャーを梱包したはずです。それはまだ起こっていますが、それらのジャーは何とかクラスパスに追加されません。なぜそうなのかわからない。

2つの別々のjarファイルを作成して解決しました.1つは自分のコードパッケージ用で、もう1つは必要なすべての依存関係です。私は、S3にそれらのjarファイルの両方をアップロードして、次の(擬似コード)を実行するスクリプトを書いた:

# download main jar 
aws s3 cp <s3-path-to-myjar.jar> . 

# download dependency jar in a temp directory 
aws s3 cp <s3-path-to-dependency-jar> temp 

# unzip the dependencies jar into another directory (say `jars`) 
unzip -j temp/dependencies.jar <path-within-jar-to-unzip>/* -d jars 

LIBJARS=`find jars/*.jar | tr -s '\n' ','` 

HADOOP_CLASSPATH=`echo ${LIBJARS} | sed s/,/:/g` 

CLASSPATH=$HADOOP_CLASSPATH 

export CLASSPATH HADOOP_CLASSPATH 

# run via hadoop command 
hadoop jar myjar.jar com.my.package.EventsPullerMR -libjars ${LIBJARS} <arguments to the job> 

これは、ジョブをキックオフ。

関連する問題