How to set system environment variable from Mapper Hadoop?

余生长醉 提交于 2020-01-06 07:52:31

问题


The problem below the line is solved but I am facing another problem.

I am doing this :

DistributedCache.createSymlink(job.getConfiguration()); 
DistributedCache.addCacheFile(new URI   
("hdfs:/user/hadoop/harsh/libnative1.so"),conf.getConfiguration()); 

and in the mapper :

System.loadLibrary("libnative1.so");

(i also tried System.loadLibrary("libnative1"); System.loadLibrary("native1");

But I am getting this error:

java.lang.UnsatisfiedLinkError: no libnative1.so in java.library.path

I am totally clueless what should I set java.library.path to .. I tried setting it to /home and copied every .so from distributed cache to /home/ but still it didn't work :(

Any suggestions / solutions please?

IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII

I want to set the system environment variable (specifically, LD_LIBRARY_PATH) of the machine where the mapper is running.

I tried :

Runtime run = Runtime.getRuntime();
Process pr=run.exec("export LD_LIBRARY_PATH=/usr/local/:$LD_LIBRARY_PATH");

But it throws IOException.

I also know about

JobConf.MAPRED_MAP_TASK_ENV

But I am using hadoop version 0.20.2 which has Job & Configuration instead of JobConf.

I am unable to find any such variable, and this is also not a Hadoop specific environment variable but a system environment variable.

Any solution/suggestion? Thanks in advance..


回答1:


Why dont you export this variable on all nodes of the cluster ?

Anyways, use the Configuration class as below while submitting the Job

Configuration conf = new Configuration();
conf.set("mapred.map.child.env",<string value>);
Job job = new Job(conf);

The format of the value is k1=v1,k2=v2



来源:https://stackoverflow.com/questions/10246301/how-to-set-system-environment-variable-from-mapper-hadoop

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