milk3422
milk3422

Reputation: 660

CDH4 JAVA_HOME Ubuntu

I have installed CDH4 in pseudo distributed mode on CentOs without any problems, but when I am installing it on Ubuntu 12.04 I am getting some errors with setting my JAVA_HOME environment variable.

I installed JDK and and have JAVA_HOME set correctly in /etc/profile.d and in ~/bash.rc using the following lines:

export JAVA_HOME=/usr/local/java/latest
export PATH=${JAVA_HOME}/bin:$PATH

I know that is redundant to define it in both places, but apparently setting it in /etc/profile.d wasn't working. From my user, when I type $echo $JAVA_HOME I get:

/usr/local/java/latest

From sudo, I run $ sudo -E echo $JAVA_HOME, I get:

/usr/local/java/latest

If you are wondering, I am specifying the -E option for sudo to preserver my environment.

So my real problem is when I am trying to start HDFS, using the following command:

for x in `cd /etc/init.d ; ls hadoop-hdfs-*` ; do sudo service $x start ; done

I get the following error:

* Starting Hadoop datanode: 
Error: JAVA_HOME is not set and could not be found.

Running the same command with the -E option gives me the same result. Has anyone had this problem?

Thanks in advance.

Upvotes: 1

Views: 287

Answers (1)

milk3422
milk3422

Reputation: 660

After some research, I found the answer to my question.

I am using CDH4 and have hadoop installed in pseudo-distributed mode.

To fix my JAVA_HOME problems, I created a the hadoop-env.sh file in /etc/hadoop/conf.pseudo.mr1

The file contained the line:

export JAVA_HOME=/usr/local/java/latest

Where /usr/local/java/latest is the path to my installation of JAVA_HOME

Upvotes: 2

Related Questions