日期:2014-05-16  浏览次数:20464 次

Hadoop伪分布模式搭建
Hadoop伪分布模式搭建?
首先要了解一下Hadoop的运行模式:
单机模式(standalone)
? ?? ? 单机模式是Hadoop的默认模式。当首次解压Hadoop的源码包时,Hadoop无法了解硬件安装环境,便保守地选择了最小配置。在这种默认模式下所有3个XML文件均为空。当配置文件为空时,Hadoop会完全运行在本地。因为不需要与其他节点交互,单机模式就不使用HDFS,也不加载任何Hadoop的守护进程。该模式主要用于开发调试MapReduce程序的应用逻辑。
伪分布模式(Pseudo-Distributed Mode)
? ?? ?伪分布模式在“单节点集群”上运行Hadoop,其中所有的守护进程都运行在同一台机器上。该模式在单机模式之上增加了代码调试功能,允许你检查内存使用情况,HDFS输入输出,以及其他的守护进程交互。
? ?? ?全分布模式(Fully Distributed Mode)
? ???Hadoop守护进程运行在一个集群上。
? ???
1. 配置conf文件夹下hadoop-env.sh文件的JAVA_HOME环境变量指向Java安装目录
<SPAN class=link_title><SPAN class=link_title></SPAN></SPAN>
2. 安装SSH:包括ssh, sshd, ssh-keygen;
3. 生成SSH密钥对,不设置口令:
ssh-keygen -t rsa
? ???4. 设置授权密钥:
01.ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa?
02.cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
? ?5. 配置conf下的几个XML文件
core-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<!-- Put site-specific property overrides in this file. -->

<configuration>

<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
<description>The name of the default file system. A URI whose scheme and authority determine the FileSystem implementation.
</description>
</property>

</configuration>
mapred-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<!-- Put site-specific property overrides in this file. -->

<configuration>

<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
<description>The host and port that the MapReduce job tracker runs at.
</description>
</property>

</configuration>
hdfs-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<!-- Put site-specific property overrides in this file. -->

<configuration>

<property>
<name>dfs.replication</name>
<value>1</value>
<description>The actual number of replication can be specified when the