一、软件准备
http://old-releases.ubuntu.com/releases/15.10/ubuntu-15.10-desktop-amd64.iso
http://apache.stu.edu.tw/hadoop/common/hadoop-2.6.5/hadoop-2.6.5.tar.gz
http://spark.apache.org/downloads.html
https://archive.apache.org/dist/spark/spark-1.6.2/spark-1.6.2-bin-hadoop2.6.tgz
https://downloads.lightbend.com/scala/2.10.5/scala-2.10.5.tgz
Hadoop(包含MapReduce、HDFS、Yarn三大基本组件)、Spark、Scala
测试环境配置需求:
CPU: 4V CPU 内存:4G 硬盘:100G
因为测试环境,这次安装为单机安装,主节点与副节点在同一台主机上,正式环境建议使用群集,给予更多的资源,也可以防止单点故障,加速度运算等优点。
(三)Master系统设定
mis@master:~$ sudo su -
输入密码:mis
root@master:~# vim /etc/hostname
root@master:~# vi /etc/hosts
127.0.0.1 localhost
127.0.1.1 Hadoop
10.91.250.132 master
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
root@master:~# vi /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto enp0s3
iface enp0s3 inet static
address 10.91.250.132
netmask 255.255.255.0
gateway 10.91.250.254
dns-nameservers 10.91.250.245
root@master:~# /etc/init.d/networking restart
重起网络服务使用网络生效,如失败则重起服务器使用网络生效
root@master:~# cp /etc/apt/sources.list /etc/apt/sources.list.bak
root@master:~# vi /etc/apt/sources.list
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial main main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
root@master:~# apt-get update
root@master:~# apt-get install openssh-server
mis@master:~$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
mis@master:~$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
mis@master:~$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
mis@master:~$ ssh master
root@master:~# apt-get install vim
root@master:~# apt-get -y install default-jdk
root@master:~# java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
root@master:~# java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
root@master:~# update-alternatives --display java
java - 自动模式
link best version is /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
链接目前指向 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
link java is /usr/bin/java
slave java.1.gz is /usr/share/man/man1/java.1.gz
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java - 优先级 1081
次要 java.1.gz:/usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/java.1.gz
路径:/usr/lib/jvm/java-8-openjdk-amd64 在后续配置中会多次使用到
传送压缩包到服务器,将解压的资料分别移动到:
root@master:/usr/local/hadoop# tar -zxvf hadoop-2.6.5.tar.gz
root@master:/usr/local/hadoop# tar -zxvf spark-1.6.2-bin-hadoop2.6.tgz
root@master:/usr/local/hadoop# tar -zxvf scala-2.10.5.tgz
/usr/local/hadoop
/usr/local/spark
/usr/local/scala
作为安装目录并更改安装目录为mis所拥有。
root@master:/usr/local# chown mis:mis -R /usr/local/hadoop/
root@master:/usr/local# chown mis:mis -R /usr/local/spark/
root@master:/usr/local# chown mis:mis -R /usr/local/scala/
注意:换成mis用户:要设置的是mis用户的环境变量
mis@master:~$ sudo vim ~/.bashrc
在文件最后追加以下变量:
#Java安装路径
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
#Hadoop相关路径
export HADOOP_HOME=/usr/local/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"
export JAVA_LIBRARY_PATH=$HADOOP_HOME/lib/native:$JAVA_LIBRARY_PATH
#Scala相关路径
export SCALA_HOME=/usr/local/scala
export PATH=$PATH:$SCALA_HOME/bin
#Spark相关路径
export SPARK_HOME=/usr/local/spark
export PATH=$PATH:$SPARK_HOME/bin
mis@master:~$ source ~/.bashrc
mis@master:~$ sudo vim /usr/local/hadoop/etc/hadoop/hadoop-env.sh
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
mis@master:~$ mkdir -p /usr/local/hadoop/tmp
mis@master:~$ sudo vim /usr/local/hadoop/etc/hadoop/core-site.xml
mis@master:~$ sudo vim /usr/local/hadoop/etc/hadoop/yarn-site.xml
mis@master:~$sudo cp /usr/local/hadoop/etc/hadoop/mapred-site.xml.template /usr/local/hadoop/etc/hadoop/mapred-site.xml
mis@master:~$ sudo vim /usr/local/hadoop/etc/hadoop/mapred-site.xml
mis@master:~$ mkdir -p /usr/local/hadoop/data/hdfs/namenode
mis@master:~$ mkdir -p /usr/local/hadoop/data/hdfs/datanode
mis@master:~$ sudo vim /usr/local/hadoop/etc/hadoop/hdfs-site.xml
mis@master:~$ hdfs namenode -format
10)启动hdfs和yarn(两种方法)
a.方法一: 同时启动
mis@master:~$ start-all.sh
第一次运行会出现提示:输入yes,输入密码(重复三次)
b.方法二: 分两步启动
mis@master:~$ start-dfs.sh
mis@master:~$ start-yarn.sh
c.查看process
mis@master:~$ jps
在以上:4.1与4.2中已经安装,主要是传送到指定目录,再设置环境变量,使其生效。
http://10.91.250.131:50070
http://10.91.250.131:8088