Change java for Cloudera cluster using ambari

If you are using Hortonworks (presently Cloudera) cluster, the default value for java is Oracle JDK 1.8. If you have the need to switch java_home from Oracle JDK to OpenJDK (wondering “Why?”), you may follow this playbook!

  1. Install and verify your desired java version. For detailed reading, click here.
[proutray@devnode ~]$ sudo yum install java-1.8.0-openjdk-devel -y
. . .
[proutray@devnode ~]$ java -version
openjdk version "1.8.0_245"
OpenJDK Runtime Environment (build 1.8.0_245-b09)
OpenJDK 64-Bit Server VM (build 25.245-b09, mixed mode)

[proutray@devnode ~]$ /usr/lib/jvm/java/bin/java -version
openjdk version "1.8.0_245"
OpenJDK Runtime Environment (build 1.8.0_245-b09)
OpenJDK 64-Bit Server VM (build 25.245-b09, mixed mode)

2. Update values of java.home and stack.java.home in /etc/ambari-server/conf/ambari.properties file to the full path of java folder which includes the bin folder.

[proutray@devnode ~]$ grep 'java.home' /etc/ambari-server/conf/ambari.properties
java.home=/usr/jdk64/jdk1.8.0_112
stack.java.home=/usr/jdk64/jdk1.8.0_112

to 

java.home=/usr/lib/jvm/java
stack.java.home=/usr/lib/jvm/java

3. Use ambari-server setup command to update the configurations. There is no need to change anything except the change Oracle JDK part. (Highlighting user -input steps)

[proutray@devnode ~]$ ambari-server setup
. . .
Do you want to change Oracle JDK [y/n] (n)? y
[1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8
[2] Custom JDK
==============================================================================
Enter choice (1): 2
WARNING: JDK must be installed on all hosts and JAVA_HOME must be valid on all hosts.
WARNING: JCE Policy files are required for configuring Kerberos security. If you plan to use Kerberos,please make sure JCE Unlimited Strength Jurisdiction Policy Files are valid on all hosts.
Path to JAVA_HOME: /usr/lib/jvm/java
Validating JDK on Ambari Server...done.
Check JDK version for Ambari Server...
JDK version found: 8
Minimum JDK version is 8 for Ambari. Skipping to setup different JDK for Ambari Server.
. . .

4. Restart ambari server. After successful restart, you will have to restart the services inside for the change to take effect.

5. Finally you may verify the changes by executing ps -ef command.

ps -ef | grep java

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s