ae35
ae35

Reputation: 93

Set LD_LIBRARY_PATH or java.library.path for YARN / Hadoop2 Jobs

i have a Hadoop FileSystem which is using native libraries with JNI.

Apparently i have to include the shared object independently of the currently executed job. But i can't find a way to tell Hadoop/Yarn where it should look for the shared object.

I had partial success with the following solutions, while starting the wordcount example with yarn.

Does anybody now how i can globally set the LD_LIBRARY_PATH or the java.library.path or can suggest which configuration options i did probably miss? I'd be very thankful!

Upvotes: 2

Views: 8353

Answers (2)

NoUserException
NoUserException

Reputation: 681

Use mapreduce.map.env in your job or site configuration.

Usage is as follows:

<property>
             <name>mapreduce.map.env</name>
             <value>LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/my/libs</value>
</property>

Note: Hadoop docs encourage the use of mapreduce.map.env for this over mapred.child.java.opts. "Usage of -Djava.library.path can cause programs to no longer function if hadoop native libraries are used."

Upvotes: 2

SimSimY
SimSimY

Reputation: 3686

Short Answer: in your mapred-site.xml put the following

<property>
<name>mapred.child.java.opts</name>
<value>-Djava.library.path=$PATH_TO_NATIVE_LIBS</value>
</property>

Explanation: The Job/Applications aren't executed by yarn rather than by a mapred (map/reduce) container, whoose configuration is controlled by the mapred-site.xml file. Specifying custom java parameters there causes that actual workers to spin with the correct path

Upvotes: 5

Related Questions