Hadoop accessing 3rd party libraries from local file system of a Hadoop node

扶醉桌前 提交于 2019-12-01 11:04:37
Paulo Fidalgo

You need to copy your file to HDFS and not to the local filesystem.

To copy files to HDFS you need to use:

hadoop fs -put localfile hdfsPath

Other option is to change the file path to:

file:///home/ubuntu/libs/javacv-0.9.jar

To add jar files to the classpath, take a look at DistributedCache:

DistributedCache.addFileToClassPath(new Path("file:///home/ubuntu/libs/javacv-0.9.jar"), job);

You may need to iterate over all jar files in that directory.

Another option would be to use distributed cache's addFileToClassPath(new Path("/myapp/mylib.jar"), job); to submit the Jar files that should be added to the classpath of your mapper and reducer tasks.

Note: Make sure you copy the jar file to HDFS first.

You could even add jar files to class path by using hadoop command line argument -libjars <jar_file>.

Note: Make sure your MapReduce application implements ToolRunner to allow -libjars option from command line.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!