Replacing the JDK in a Linux production environment

Source: Internet
Author: User

In order to demonstrate and keep the production environment private, I have built a virtual machine in the local VM that is exactly the same as the production environment, which comes from the local virtual machine. The operation steps are strictly in accordance with the production environment to be replaced.

First of all, to introduce the general structure of the production environment, the front-end with nginx distribution, back-end two Tomcat processing request Application Server, this is only the most basic and most common load balancing architecture.

Here's how to get started: (Note: Use the root account)

First step: First look at the Java version of the system. The system uses OPENJDK and is 1.7.0_85 version

Step Two: Install SUNJDK

1 Create a new folder using the command soft

2 uploading SUNJDK to the soft directory

3 Extracting files using the tar command

After decompression,

4 adding environment variables in/etc/profile

To open a profile using the Vi/etc/profile command

and fill in the bottom of the following content

Use: Source/etc/profile is effective

This SUNJDK has been installed

Step three: Make SUNJDK effective

Due to the previous installation of OPENJDK, so after the second step of the system is the default or OPENJDK (no JDK system finished the second step after the JDK can be used)

We use the java-version command to check the

We see the current system is still only recognized OPENJDK, let's replace the next

1. Use the command to add Java to the bin

update-alternatives--install/usr/bin/javaJava/usr/local/soft/jdk1.7.0_79/bin/java -

2. Add Javac to bin using the command

update-alternatives--install/usr/bin/javacJavac/usr/local/soft/jdk1.7.0_79/bin/javac -

After completing the above two steps, you can choose the JDK.

3. Select the JDK. Use the command to select the JDK version

Update-alternatives--config Java

Select the corresponding serial number, enter on the can.

4 Check for success. Let's take a look at java-version again.

OK, it's ready.

Then we are using load balancer to restart the TOMCAT1,TOMCAT2 separately. This way, you can do this without interruption and update the JDK.


======================= I'm a split line ===========================

Give us a little knowledge.

After configuring the environment variable (modify the/etc/profile file)

Restart Tomcat,tomcat to find the sunjdk we just configured ...

Only then is the Linux system default or OPENJDK, if the single run JAR file system or default is OPENJDK. Tomcat can find SUNJDK, which is related to its loading mechanism.

For the sake of uniformity, I suggest you take the second step and replace the system JDK with SUNJDK.


The update-alternatives--config Java command also has the advantage of being able to switch JDK versions at any time (you don't want to use SUNJDK and you can switch to the original OpenJDK) ... Is it strong?




Replacing the JDK in a Linux production environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.