Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the classpath set for hadoop

Where is the classpath for hadoop set? When I run the below command it gives me the classpath. Where is the classpath set?

  bin/hadoop classpath

I'm using hadoop 2.6.0

like image 841
Bourne Avatar asked Feb 01 '15 07:02

Bourne


People also ask

Where is the CLASSPATH in hadoop?

It is set in hadoop-config.sh.

What does hadoop classpath do?

classpath. Prints the class path needed to get the Hadoop jar and the required libraries. If called without arguments, then prints the classpath set up by the command scripts, which is likely to contain wildcards in the classpath entries.


Video Answer


3 Answers

As said by almas shaikh it's set in hadoop-config.sh, but you could add more jars to it in hadoop-env.sh

Here is a relevant code from hadoop-env.sh which adds additional jars like capacity-scheduler and aws jar's.

export HADOOP_CONF_DIR=${HADOOP_CONF_DIR:-"/etc/hadoop"}

# Extra Java CLASSPATH elements.  Automatically insert capacity-scheduler.
for f in $HADOOP_HOME/contrib/capacity-scheduler/*.jar; do
  if [ "$HADOOP_CLASSPATH" ]; then
    export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$f
  else
    export HADOOP_CLASSPATH=$f
  fi
done

# ... some other lines omitted

# Add Aws jar
export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:share/hadoop/tools/lib/*
like image 63
Ashrith Avatar answered Nov 12 '22 00:11

Ashrith


Open your bash profile (~/.profile or ~/.bash_profile) for editing and add the following:

  1. export HADOOP_HOME="/usr/local/Cellar/hadoop" then Replace with your own path
  2. export HADOOP_CLASSPATH=$(find $HADOOP_HOME -name '*.jar' | xargs echo | tr ' ' ':') Save the changes and reload.

  3. source ~/.profile

like image 31
Siva Krishnan Avatar answered Nov 12 '22 02:11

Siva Krishnan


When you run hadoop command, it sources a file hadoop-config.sh that resides in $HADOOP_HDFS_HOME/libexec which sets your classpath (CLASSPATH) by picking jars residing in various directories viz.

$HADOOP_HDFS_HOME/share/hadoop/mapreduce 
$HADOOP_HDFS_HOME/share/hadoop/common
$HADOOP_HDFS_HOME/share/hadoop/hdfs etc.
like image 37
SMA Avatar answered Nov 12 '22 00:11

SMA