查看默认java版本:
[sam@bigdataspark ~]$ java -version
java version "1.7.0_51"
OpenJDK Runtime Environment (rhel-2.4.5.5.el7-x86_64 u51-b31)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
通过Xshell 和 Xftp 把java安装文件上传到服务器。
以下只说明jdk,hadoop一样操作即可。
步骤1:安装文件解压到相应目录:
[root@bigdataspark Downloads]# ls
hadoop-2.7.5.tar.gz jdk-7u80-linux-x64.tar.gz spark-2.3.1-bin-hadoop2.7.tgz
[root@bigdataspark Downloads]# tar -zxvf jdk-7u80-linux-x64.tar.gz -C /root/training/
步骤2:配置环境变量
[root@bigdataspark Downloads]# cd ~
[root@bigdataspark ~]# ls -a
. anaconda-ks.cfg .bash_logout .bashrc .config .dbus .tcshrc .xauthwpMUKX
.. .bash_history .bash_profile .cache .cshrc initial-setup-ks.cfg training
[root@bigdataspark ~]# vi .bash_profile
JAVA_HOME=/root/training/jdk1.7.0_80
export JAVA_HOME
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
HADOOP_HOME=/root/training/hadoop-2.7.5
export HADOOP_HOME
PATH=$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH
export PATH
步骤3:使环境变量生效
[root@bigdataspark ~]# source .bash_profile
[root@bigdataspark ~]# java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
[root@localhost ~]# hadoop version
Hadoop 2.7.5
Subversion https://shv@git-wip-us.apache.org/repos/asf/hadoop.git -r 18065c2b6806ed4aa6a3187d77cbe21bb3dba075
Compiled by kshvachk on 2017-12-16T01:06Z
Compiled with protoc 2.5.0
From source with checksum 9f118f95f47043332d51891e37f736e9
This command was run using /root/training/hadoop-2.7.5/share/hadoop/common/hadoop-common-2.7.5.jar