一、简述
在centos7 Linux下进行伪分布式搭建。Hadoop 伪分布式模式是在单机上模拟 Hadoop 分布式,单机上的分布式并不是真正的伪分布式,而是使用线程模拟分布式。Hadoop 本身是无法区分伪分布式和分布式的,两种配置也很相似,唯一不同的地方是伪分布式是在单机器上配置,数据节点和名字节点均是一个机器。虽然Hadoop的安装步骤并不复杂,但是我在安装期间还是遇到了很多琐碎的问题,现将自己搭建Hadoop的详细过程和遇到的问题记录下来。完全分布式就是一个hadoop集群,有n台机器组成,一般组织方式是:一台机器作为master,上面 运行 namenode和jobtracker,另外的机器作为slave,上面运行datanode和tasktracker,至于secondaryname,可以运行在master上,也可以运行在另外一台机器上。secondaryname是namenode的一个备份里面同样保存了名字空间,和文件到文件块的map关系。建议运行在另外一台机器上,这样master死掉之后,还可以通过secondaryname所在的机器找回名字空间,和文件到文件块得map关系数据,恢复namenode。
二、 环境搭建
1.准备工作
主机名称 | 系统 | jdk | hadoop |
---|---|---|---|
hadoop | centos7 | jdk1.8+ | hadoop-2.7.3 |
2.开始安装
1.关闭防火墙、配置主机明和ip 、 ssh无密码登录
hadoop、jdk的下载、安装以及环境变量的配置请参考:http://blog.csdn.net/qq_38799155/article/details/75949250
2.伪分布hadoop的配置:
2.1core-site.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. See accompanying LICENSE file.
-->
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/home/hadoop/hadoop-2.7.3/tmp</value>
</property>
</configuration>
2.2 hdfs-ssite.xml