下载安装
# 下载
$ cd /usr/local
$ wget http://mirrors.hust.edu.cn/apache/hadoop/common/hadoop-2.9.2/hadoop-2.9.2.tar.gz
# 解压安装包
$ tar -zxvf hadoop-2.9.2.tar.gz && rm hadoop-2.9.2.tar.gz
# 编辑环境变量
$ vim ~/.bashrc
# 添加如下两行
export HADOOP_HOME=/usr/local/hadoop-2.9.2.tar.gz
export PATH=$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH
# 使环境变量生效
$ source ~/.bashrc
本地SSH工具配置
# 安装ssh工具
$ sudo apt-get install ssh
$ sudo apt-get install rsync
# 运行失败, 需先生成并写入本地的id_rsa.put到已授权的keys中
$ ssh localhost
# 生成ssh key
$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
# 添加本地的pub key到授权keys中
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# 提升下权限
$ chmod 0600 ~/.ssh/authorized_keys
# 再次尝试可运行成功, 如果不行删掉~/.ssh/known_knows重试
$ ssh localhost
启动HDFS前配置
# etc/hadoop/core-site.xml:
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
# etc/hadoop/hdfs-site.xml:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
启动HDFS文件系统
$ bin/hdfs namenode -format
# 启动hdfs中的NameNode和DataNode, 此时可在host:8088中进行访问
$ start-dfs.sh
# 验证是否成功可通过jps命令
$ jps
19441 Jps
18946 NameNode
19321 SecondaryNameNode
19084 DataNode
5710 jar
# 关闭hdfs
$ stop-dfs.sh
单节点上的YARN
# etc/hadoop/mapred-site.xml:
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
# etc/hadoop/yarn-site.xml:
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
启动关闭
$ start-yarn.sh
$ stop-yarn.sh