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
Open your bash profile (~/.profile or ~/.bash_profile) for editing and add the following:
export HADOOP_HOME="/usr/local/Cellar/hadoop" then Replace with your own path
export HADOOP_CLASSPATH=$(find $HADOOP_HOME -name '*.jar' | xargs echo | tr ' ' ':')
Save the changes and reload.
source ~/.profile
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/*
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.
As per this blog post, it is in an environment variable named HADOOP_CLASSPATH. You can set it as you would any other environment variable, the specifics of which depend on which shell you use. If you use bash, then you can call like export HADOOP_CLASSPATH=/path/to/wherever:/path/to/wherever/else.
I also encountered the problem and have solved it, but my hadoop version is 2.10.1.
I hope it have some help for people who use a newer hadoop version. So far, the following methods should have worked as well in the latest hadoop version 3.3.0.
You just need to edit your .bashrc or .profile, I will give an example of .bashrc.
# edit .bashrc
$ vim ~/.bashrc
Add HADOOP_HOME, PATH of hadoop bin direcotry and HADOOP_CLASSPATH in .bashrc.
# export HADOOP_HOME=${your hadoop install directory}, an example as follows:
export HADOOP_HOME=/usr/local/hadoop-2.10.1
export PATH=${HADOOP_HOME}/bin:${PATH}
export HADOOP_CLASSPATH=`hadoop classpath`
Then,
$ source ~/.bashrc
Related
I tried to install laravel Framework in my mac OSX 10 .And I ended modifying my ~/.bash_profile to add the laravel command. laravel command seems to work normally .But another problem came out . ls ,sudo ...and other shell commands does not work .
-bash: ls: command not found
My bash.profile file contains the two links
export PATH="/Applications/MAMP/bin/php/php5.6/bin"
export PATH="$PATH:$HOME/.composer/vendor/bin"
check in ~/.bash_profile if this PATHs exist
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
your complete line should looks like this
export PATH=/Applications/MAMP/bin/php/php5.6/bin:$HOME/.composer/vendor/bin:/opt/local/bin:/opt/local/sbin:$PATH
reboot needed.
The binaries for the above mentioned utilities for debian distribution are usually in /bin or /usr/bin directory. Of course exporting path won't help if the binaries are not there.
There could be one simple approach to it -
Check for the location of binaries and then export the path in the bash_profile or .bashrc.
Run the bashrc script (. ~/.bashrc) following you may not require a reboot.
I have installed hadoop using tar files. i have added $HADOOP_PREFIX=/usr/local/hadoop in the .bashrc file . everything was working fine. Now , i installed Hadoop using Horton's Ambari. I have removed the previous hadoop environment variable $HADOOP_PREFIX from all the system from .bashrc file.
Now when i give the command echo $HADOOP_PREFIX it is still showing the old path /usr/local/hadoop . Is there any way to remove that variable.?
delete the $HADOOP_PREFIX from .bahrc file then run this command
unset HADOOP_PREFIX
After installing python(EPDFee), I want to add the /bin directory to $PATH variable. I am use bash shell. I have found that I have to add the following line in the file .bashrc
export PATH=/home/usrname/epd/bin:$PATH
I have found the file .bashrc, it reads
PATH=$PATH:/opt/bin
# Added by Canopy installer on 2014-03-29
# VIRTUAL_ENV_DISABLE_PROMPT can be set to '' to make bashprompt show that Canopy is active, otherwise 1
VIRTUAL_ENV_DISABLE_PROMPT=1 source /home/an/Enthought/Canopy_64bit/User/bin/activate
Could you please tell me where can I add export PATH=/home/usrname/epd/bin:$PATH to or is should be added in another file?
add the following line to your .bashrc file ...don't forget to replace your path.
export PATH="/path/directory:$PATH"
then do
source .bashrc
to let the changes make effects. I am not sure about other distributions of Linux but It will work on CentOS and RedHat.
You can do it like this :
Define a EPD_HOME var and append it to PATH
EPD_HOME=/home/usrname/epd/bin
PATH=$PATH:$EPD_HOME:$HOME/bin
export PATH
Notice that the $EPD_HOME variable is in the PATH variable and is now loaded once you open a connection to your user on the machine.
I am completely new to Hadoop and I am trying to install Hadoop single node cluster on ubuntu but I am unable to figure out the reason I am unable to.I am following the tutorials in the following link "http://codesfusion.blogspot.in/2013/10/setup-hadoop-2x-220-on-ubuntu.html?m=1"
Everything went smoothly but when I give the command "Hadoop version" I get the following error.
"/usr/local/hadoop/bin/hadoop: line 133: /usr/lib/jvm/jdk//bin/java: No such file or directory"
I also opened the same file and searched the entire file but could not find such a line at all .
my .bashrc
export JAVA_HOME=/usr/lib/jvm/jdk/
export HADOOP_INSTALL=/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
export YARN_HOME=$HADOOP_INSTALL
###end of paste
After that I opened hadoop-env.sh and pasted this ,the java home
export JAVA_HOME=/usr/lib/jvm/jdk/
Later I re-logged in and checked the hadoop version I am getting this error
"/usr/local/hadoop/bin/hadoop: line 133: /usr/lib/jvm/jdk//bin/java: No such file or directory"
I also cross verified that particular file but there is no line as such .Anybody kindly help me with this since I am new to this.
I found the solution.
First remove / from the end /usr/lib/jvm/jdk/ in bot bashrc and hadoop-env.sh
navigate to /usr/lib/jvm/jdk/bin
see if it has java folder or not. If its not there then check if u have made the correct soft link.
You must create a soft link for folder that has java in it so check before this command:
$ cd /usr/lib/jvm
$ ln -s java-7-openjdk-amd64 jdk
in above step as u might have seen in the tutorial change as following
$ cd /usr/lib/jvm
$ ln -s java-7-openjdk-amd64/ jdk
the 7 here is dependent on verion of jdk u have so check that and change accordingly.
I have jdk 6 so i changed for java-6-**
hope it works
This is error due to $JAVA_HOME variable. Change this variable path. you will be free from the error.
go to .bashrc using this command
vim ~/.bashrc
Change the JAVA_HOME variable
export JAVA_HOME=/usr/lib/jvm/jdk
export PATH=PATH:$PATH/bin
if you have jdk 8 then replace jdk with java-8-oracle .
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export PATH=PATH:$PATH/bin
restart you terminal and check the java command first, then hadoop command.
Like everyone else in the world, I'm following this hadoop tutorial. I get to the point where I format HDFS, and I get this:
user#linux01:~$ sudo $HADOOP_INSTALL/bin/hadoop namenode -format
Error: JAVA_HOME is not set.
Well that's funny, I set JAVA_HOME in my /etc/profiles.
user#linux01:~$ tail -n 4 /etc/profile
export JAVA_HOME=/usr/local/jdk1.6.0_32/bin
export JDK_HOME=$JAVA_HOME
export PATH=$PATH:/usr/local/jdk1.6.0_32/bin
export HADOOP_INSTALL=/usr/local/hadoop/hadoop-1.0.3
Did I mess that up somehow?
user#linux01:~$ echo $JAVA_HOME
/usr/local/jdk1.6.0_32/bin
user#linux01:~$ ls $JAVA_HOME
appletviewer extcheck jar javac and so forth...
Seems to work. Maybe it absolutely has to be set in my hadoop-env.sh?
# The java implementation to use. Required.
export JAVA_HOME=$JAVA_HOME
Lazy, yeah, but I still get "JAVA_HOME is not set" with or without this comment. I'm running low on ideas. Anyone see anything I'm missing?
Thank you #Chris Shain and #Chris White for your hints. I was running hadoop as su, and su doesn't automatically know about the environmental variables I set. I logged in as my hadoop user (I had chown'd the hadoop install directory to this user), and was able to format the hdfs.
Secondary problem: When I tried to start Hadoop, NameNode and JobTracker started successfully but DataNode, SecondaryNameNode, and TaskTracker failed to start. I dug in a little bit. NameNode and JobTracker are started via hadoop-daemon.sh, but DataNode, SecondaryNameNode, and TaskTracker are started by hadoop-daemon*s*.sh. The resolution here was to properly set JAVA_HOME in conf/hadoop-env.sh.
First a general note: If you are working on CYGWIN, please be logged in to your system as an Administrator.
I faced this problem of Java_Home not found while executing namenode -format. Below is what i did to fix it
Reinstalled JDK out of program files in a location where there was no space in the folder name. For example: D:/Installations/JDK7
Got into the bin folder of hadoop (version 1.2.1) installation and edited the "hadoop" configuration file. This is the file which has no file extension.
Searched for java_home variable
Just before the first instance of variable $JAVA_HOME I added this line:
export JAVA_HOME=/cygdrive/D/Installations/JDK7/
This is how it looks now:
fi
export JAVA_HOME=/cygdrive/D/Installations/JDK7/
# some Java parameters
if [ "$JAVA_HOME" != "" ]; then
#echo "run java in $JAVA_HOME"
JAVA_HOME=$JAVA_HOME
fi
Note: /cygdrive/ has to preceed your jdk installation path. Colon after the drive letter is not needed and the path should have forward slash.
Additionally, I did set JAVA_HOME in the system env properties. Just to be double sure.
Run the program and it will work now.
Blockquote
Try to use short name to avoid a space in a path.
"C:\Program Files" should have short name C:\Progra~1 (you can verify it using DOS dir command or entering it into address bar in file explorer).
Set your JAVA_HOME this way:
export JAVA_HOME="/cygdrive/c/Progra~1/Java/jdk1.7.0_10"
Answered by user2540312