Build the yarn environment: centos7.0 JDK Configuration

Source: Internet
Author: User

Hadoop is written in Java and cannot use openjdk pre-installed in Linux. Therefore, JDK (1.6 or above) must be installed before hadoop is installed)

 

Raw materials: the 32-bit JDK downloaded from the Oracle Official Website:

 

 

Note:

1. The centos 7.0 system currently only has 64-bit data. However, hadoop generally supports 32-bit data. In a 64-bit environment, there may be a warning problem to avoid real problems, select JDK of i586 (32-bit). Of course, 64-bit centos 7 must be compatible with 32-bit JDK. Remember: 64-bit systems must be compatible with 32-bit software, 32-bit systems are not compatible with 64-bit software. 64-bit only indicates that the number of CPU operations at a time is 64-bit, which is more than 32-bit, And the 64-Bit performance is higher.

The RPM installation package is a unique installation file of the RedHat series system (RedHat/RHEL/Fedora/centos). You can run it directly, but we do not know the configuration method. For the bottom layer, I select the tar.gz compressed package for installation.

 

Installation Method:

The built-in openjdk and the later installed JDK cannot have both of them. Therefore, there are two types of operations: 1. Uninstall and delete the original openjdk, and then install JDK 2. The two still coexist. However, which of the following statements is true for JDK?

 

Method 1: uninstall and delete the original openjdk, and then install JDK.

Step 1: uninstall and delete openjdk

To uninstall and delete openjdk, you must first know what to delete:

 

 

[[Email protected] ~] $ Rpm-Qa | grep openjdk-I # Find the installed openjdk.-I indicates that the case sensitivity of "openjdk" is ignored.

 

Delete all of them now:

[[Email protected] ~] $ Sudo Yum remove java-1.6.0-openjdk-devel-1.6.0.0-6.1.13.4.el7_0.x86_64 java-1.7.0-openjdk-devel-1.7.0.65-2.5.1.2.el7_0.x86_64 java-1.7.0-openjdk-headless-1.7.0.65-2.5.1.2.el7_0.x86_64 java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el7_0.x86_64 java-1.6.0-openjdk-1.6.0.0-6.1.13.4.el7_0.x86_64 # Remove openjdk with the yum that comes with the RedHat series system, yum is similar to Apt-Get In ubuntu, are used to install, uninstall, and update the software that comes with the system. Note: The preceding steps are separated by spaces.

 

Step 2: Install JDK

1. Extract

First, decompress the downloaded JDK: (The tar.gz package of JDK is stored in ~ /Dev directory)

[[Email protected] localhost ~] $ Sudo mkdir/usr/lib/JDK # if there is no/usr/lib/JDK path, execute this statement to create the JDK folder [[email protected] ~] $ Sudo tar-zxvf jdk-8u11-linux-i586.tar.gz-C/usr/lib/JDK # Note:-C, -- directory = dir change to directory dir [[email protected] ~] $ Ls/usr/lib/jdkjdk1.8.0 _ 11 [[email protected] ~] $ Ls/usr/lib/JDK/jdk1.8.0 _ 11/bin javafx-src.zip man THIRDPARTYLICENSEREADME-JAVAFX.txtCOPYRIGHT JRE readme.html thirdpartylicensereadme.txt dB lib releaseinclude license src.zip [[email protected] ~] $

 

Move the file in jdk1.8.0 _ 11 to/usr/lib/JDK and delete the jdk1.8.0 _ 11 Folder:

[[Email protected] ~] $ Sudo CP-RF/usr/lib/JDK/jdk1.8.0 _ 11/*/usr/lib/JDK/# Move [email protected] ~] $ [[Email protected] ~] $ Ls/usr/lib/jdkbin javafx-src.zip license src.zip copyright jdk1.8.0 _ 11 man THIRDPARTYLICENSEREADME-JAVAFX.txtdb JRE readme.html thirdpartylicensereadme.txt include lib release [[email protected] ~] $ Sudo Rm-RF/usr/lib/JDK/jdk1.8.0 _ 11/# Delete [email protected] ~] $ Ls/usr/lib/jdkbin javafx-src.zip man THIRDPARTYLICENSEREADME-JAVAFX.txtCOPYRIGHT JRE readme.html thirdpartylicensereadme.txt dB lib releaseinclude license src.zip [[email protected] ~] $

 

2. Configure Environment Variables

[[Email protected] ~] $ Sudo Vim/etc/profile is inserted in the last line: # Java environmentexport java_home =/usr/lib/jdkexport jre_home =/usr/lib/JDK/jreexport Path = $ java_home/bin: $ jre_home/bin: $ pathexport classpath = $ classpath :.: $ java_home/lib: $ jre_home/lib

3. modify the system's default JDK

[[Email protected] ~] $ Sudo Update-alternatives -- install/usr/bin/Java/usr/lib/JDK/bin/Java 300 # Make the default Java command/usr/lib/JDK/ java command in Bin [[email protected] ~] $ Sudo Update-alternatives -- install/usr/bin/javac/usr/lib/JDK/bin/javac 300 # Make the default javac command/usr/lib/JDK/ javac command in Bin
[[Email protected] ~] $ Sudo Update-alternatives -- install/usr/bin/Jar/usr/lib/JDK/bin/jar 300 # Make the default jar command/usr/lib/JDK/ jar command in Bin
[[Email protected] ~] $ Sudo Update-alternatives -- config Java # configure the default Java command. There is a total of 1 program that provides "Java. Option command ------------------------------------------- * + 1/usr/lib/JDK/bin/Java press enter to retain the current option [+], or enter option number: 1 [[email protected] ~] $ Sudo Update-alternatives -- config javac # by default, the configuration of Java commands has a total of 1 program that provides "Java. Option command --------------------------------------------- * + 1/usr/lib/JDK/bin/javac press enter to retain the current option [+], or enter option number: 1

 

Step 3: Test JDK

[[email protected] ~]$ java -versionjava version "1.8.0_11"Java(TM) SE Runtime Environment (build 1.8.0_11-b12)Java HotSpot(TM) Server VM (build 25.11-b03, mixed mode)[[email protected] ~]$ javac -versionjavac 1.8.0_11

 

The test encountered a problem:

[[Email protected] ~] $ Java-Bash:/usr/bin/Java:/lib/ld-linux.so.2: bad elf Interpreter: No file or directory [[email protected] ~] $ Ls/lib/LD-linuxls: inaccessible/lib/LD-Linux: the file or directory does not exist [email protected] ~] $ Java-version-Bash:/usr/bin/Java:/lib/ld-linux.so.2: bad elf Interpreter: No file or directory [[email protected] ~] $

Solution:

[[Email protected] ~] $ Sudo Yum install glibc. i686 # execute a 32-bit program in 64 system. If/lib/ld-linux.so.2: bad elf Interpreter: no such file or directory appears, install glic.

 

Method 2: Both of them coexist.

 

Similar to Method1, you do not need to uninstall or delete openjdk.

 

1. Extract

First, decompress the downloaded JDK: (The tar.gz package of JDK is stored in ~ /Dev directory)

[[Email protected] ~] $ Sudo mkdir/usr/lib/JDK # if there is no/usr/lib/JDK path, execute this statement to create the JDK folder [[email protected] ~] $ Sudo tar-zxvf jdk-8u11-linux-i586.tar.gz-C/usr/lib/JDK # Note:-C, -- directory = dir change to directory dir [[email protected] ~] $ Ls/usr/lib/jdkjdk1.8.0 _ 11 [[email protected] ~] $ Ls/usr/lib/JDK/jdk1.8.0 _ 11/bin javafx-src.zip man THIRDPARTYLICENSEREADME-JAVAFX.txtCOPYRIGHT JRE readme.html thirdpartylicensereadme.txt dB lib releaseinclude license src.zip [[email protected] ~] $

 

Move the file in jdk1.8.0 _ 11 to/usr/lib/JDK and delete the jdk1.8.0 _ 11 Folder:

[[Email protected] ~] $ Sudo CP-RF/usr/lib/JDK/jdk1.8.0 _ 11/*/usr/lib/JDK/# Move [email protected] ~] $ [[Email protected] ~] $ Ls/usr/lib/jdkbin javafx-src.zip license src.zip copyright jdk1.8.0 _ 11 man THIRDPARTYLICENSEREADME-JAVAFX.txtdb JRE readme.html thirdpartylicensereadme.txt include lib release [[email protected] ~] $ Sudo Rm-RF/usr/lib/JDK/jdk1.8.0 _ 11/# Delete [email protected] ~] $ Ls/usr/lib/jdkbin javafx-src.zip man THIRDPARTYLICENSEREADME-JAVAFX.txtCOPYRIGHT JRE readme.html thirdpartylicensereadme.txt dB lib releaseinclude license src.zip [[email protected] ~] $

 

2. Configure Environment Variables

[[Email protected] ~] $ Sudo Vim/etc/profile is inserted in the last line: # Java environmentexport java_home =/usr/lib/jdkexport jre_home =/usr/lib/JDK/jreexport Path = $ java_home/bin: $ jre_home/bin: $ pathexport classpath = $ classpath :.: $ java_home/lib: $ jre_home/lib

3. modify the system's default JDK

[[Email protected] ~] $ Sudo Update-alternatives -- install/usr/bin/Java/usr/lib/JDK/bin/Java 300 # Make the default Java command/usr/lib/JDK/ java command in Bin [[email protected] ~] $ Sudo Update-alternatives -- install/usr/bin/javac/usr/lib/JDK/bin/javac 300 # Make the default javac command/usr/lib/JDK/ javac command in Bin
[[Email protected] ~] $ Sudo Update-alternatives -- install/usr/bin/Jar/usr/lib/JDK/bin/jar 300 # Make the default jar command/usr/lib/JDK/ jar command in Bin
[[Email protected] ~] $ Sudo Update-alternatives -- config Java # configure the default Java command

There are three programs that provide "Java.

Option command
-----------------------------------------------
* 1/usr/lib/JVM/java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el7_0.x86_64/JRE/bin/Java
2/usr/lib/JVM/jre-1.6.0-openjdk.x86_64/bin/Java
+ 3/usr/lib/JDK/bin/Java

Press enter to retain the current option [+], or enter the option number: 3.

[[Email protected] ~] $ Sudo Update-alternatives -- config javac # configure the default Java command

There are three programs that provide "javac.

Option command
-----------------------------------------------
* 1/usr/lib/JVM/java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el7_0.x86_64/JRE/bin/javac
2/usr/lib/JVM/jre-1.6.0-openjdk.x86_64/bin/javac
+ 3/usr/lib/JDK/bin/javac

Press enter to retain the current option [+], or enter the option number: 3.

 

[[Email protected] ~] $

 

Step 3: Test JDK

[[email protected] ~]$ java -versionjava version "1.8.0_11"Java(TM) SE Runtime Environment (build 1.8.0_11-b12)Java HotSpot(TM) Server VM (build 25.11-b03, mixed mode)[[email protected] ~]$ javac -versionjavac 1.8.0_11

 

The test encountered a problem:

[[Email protected] ~] $ Java-Bash:/usr/bin/Java:/lib/ld-linux.so.2: bad elf Interpreter: No file or directory [[email protected] ~] $ Ls/lib/LD-linuxls: inaccessible/lib/LD-Linux: the file or directory does not exist [email protected] ~] $ Java-version-Bash:/usr/bin/Java:/lib/ld-linux.so.2: bad elf Interpreter: No file or directory [[email protected] ~] $

Solution:

[[Email protected] ~] $ Sudo Yum install glibc. i686 # execute a 32-bit program in 64 system. If/lib/ld-linux.so.2: bad elf Interpreter: no such file or directory appears, install glic.

 

 

Appendix:

After completing the JDK environment configuration, let's talk about the settings of the mariadb database that comes with centos 7.

Now, the databases that come with RHEL 7/centos 7 are no longer MySQL, mainly because of the larger open source capability. Google is also migrating its data from MySQL to mariadb. To experience the most advanced ideas, my hive database platform will be mariadb in the future.

 

After the system is installed, the mariadb service of the system is out of the Stop State, so you should first start the service:

[[Email protected] ~] $ Sudo systemctl start mariadb # Run sudo service mariadb start in centos earlier versions, and run the service command in centos 7, but the prompt "redirecting to/bin/systemctl start mariadb" appears. service [[email protected] ~] $ Sudo systemctl stop mariadb # Stop the mariadb service [[email protected] ~] $ Sudo systemctl status mariadb # view mariadb status [[email protected] ~] $

 

Set the root password of mariadb to "root ":

Command Format:

Sudo mysqladmin-u Username Password "new password"

If the root user has set a password, use the following method:

Sudo mysqladmin-u user name password old password "new password"

 

Because there is no password after the system is installed, set the root user password to "root ":

[[email protected] ~]$ sudo mysqladmin -u root password "root"

 

Test:

[[email protected] ~]$ mysql -u root -proot

Display:

Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 3Server version: 5.5.37-MariaDB-log MariaDB ServerCopyright (c) 2000, 2014, Oracle, Monty Program Ab and others.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.MariaDB [(none)]>

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.