一、Hadoop安装需要什么呢?
1. 最低配置4G以上的内存,40g的硬盘是最好的。
本文是基于阿里云centos7.3
所需软件安装包:
hadoop-2.6.0-cdh5.7.0.tar.gz
jdk-8u172-linux-x64.tar.gz
在centos中以下链接就可以下载所需的软件安装包
wget http://archive.cloudera.com/cdh5/cdh/5/hadoop-2.6.0-cdh5.7.0.tar.gz
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/jdk-8u172-linux-x64.tar.gz
二、安装步骤:
1.安装jdk
1.1.下载jdk,然后解压
[root@localhost java]# tar -zxvf jdk-8u172-linux-x64.tar.gz
1.2.设置环境变量
[root@localhost java]# vi /etc/profile
1.3. 在profile中添加如下内容:
#set java environment
JAVA_HOME=/usr/java/jdk1.7.0_79
JRE_HOME=/usr/java/jdk1.7.0_79/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
1.4.让修改生效:
[root@localhost java]# source /etc/profile
1.5.验证JDK有效性
[root@localhost java]# java -version
2.安装ssh
[root@localhost app]# yum install ssh
返回结果,证明已经安装过了的:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
No package ssh available.
Error: Nothing to do
2.1. 生成ssh签名
[root@localhost app]# ssh-keygen -t rsa
[root@localhost app]# ll -la
[root@localhost app]# cd ~/.ssh/
[root@localhost app]# cp id_rsa.pub authorized_keys
3.安装hadoop
[root@localhost app]# tar -zxvf hadoop-2.6.0-cdh5.7.0.tar.gz -C ../app/
[root@localhost app]# vi hadoop-2.6.0-cdh5.7.0/etc/hadoop/hadoop-env.sh
hadoop-env.sh 配置:
#set to the root of your Java installation
export JAVA_HOME=/root/app/jdk1.8.0_172
hosts文件 配置:
vi /etc/hosts
192.168.11.133 hadoop01
4.hadoop两个最重要的配置文件
[root@localhost hadoop]# vi etc/hadoop/core-site.xml
// core-site.xml配置:
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop01:8020</value>
</property>
</configuration>
[root@localhost hadoop]# vi etc/hadoop/hdfs-site.xml
//修改hdfs-site.xml配置:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.http.address</name>
<value>hadoop01:50070</value>
</property>
</configuration>
5.启动:
//安装的时候,只执行一次,格式化文件系统
[root@localhost hadoop]# bin/hdfs namenode -Format
//1.启动hdfs:
[root@localhost hadoop]# sbin/start-dfs.sh
//2.验证是否启动成功
浏览器访问 http://[你的IP]:50070 或者
命令: jps
NameNode
DataNode
SecondaryNameNode
//3.停止hdfs
./stop-dfs.sh
//4.配置hadoop快捷方式跟java的配置一样
vi /etc/profile
HADOOP_HOME=/root/app/hadoop-2.6.0-cdh5.7.0