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> 

내가 아래로 전체 단지를 포장하고 있습니다 :

<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> 
내가지도-감소 작업을 실행하는 동안 그들은 클래스 패스에 추가되도록 테라 데이타 단지를 지정할 수있는 방법이 있나요

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 

:

는 같은 EMR 명령을 실행?

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

아직 완전히이 문제를 해결하지는 못했지만이 방법을 찾았습니다. 이상적인 해결책은 uber jar 내의 teradata jar를 압축해야합니다. 그것은 여전히 ​​일어나고 있지만 그 항아리들은 어떻게 든 classpath에 추가되지 않습니다. 그 이유가 확실하지 않습니다.

2 개의 별도 jar 파일을 만들었습니다. 하나는 코드 패키지 용이고 다른 하나는 필요한 모든 종속성 패키지입니다. 나는 S3에 모두 그 항아리를 업로드 한 후 다음 (의사 코드)를 수행하는 스크립트 작성 :

# 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> 

이 일을 개막한다.

관련 문제