---
title: "Hadoop-1.2 单机部署"
author: "salazar"
date: "2014-06-14T23:19:33Z"
tags: []
categories: ["互联网"]
slug: "hadoop-1-2"
draft: false
lastmod: "2014-06-14T23:19:33Z"
id: 2079682
url: "https://monsters.iteye.com/blog/2079682"
---

准备相关资源环境 

运行环境 工具

Linux Centos 6.3

JDK 1.7.0\_51

SSH Secure Shell

* * *

  **1. 下载Hadoop1.2**

 

http://mirrors.cnnic.cn/apache/hadoop/common/hadoop-1.2.1/

 

这里下载的是hadoop-1.2.1.tar.gz，解压缩：

 

```
tar -zxvf hadoop-1.2.1.tar.gz
```

   ![](http://dl2.iteye.com/upload/attachment/0098/1031/f98d12e8-93db-3e42-a49e-9162036eb022.jpg)

 

* * *

  **2. 配置系统环境变量**

 

```
vi /hadoop/hadoop1.2.1/conf/hadoop-env.sh
```

    ![](http://dl2.iteye.com/upload/attachment/0098/1043/581d6681-2d1c-333e-9938-52b784a03921.jpg) 

* * *

  **3. 测试安装**

```
source hadoop-env.sh
hadoop version
```

     
    ![](http://dl2.iteye.com/upload/attachment/0098/1045/297b60aa-7175-3190-989d-3b4949a4b79c.jpg)  

* * *

  **4. 运行前配置，由于Hadoop是分布式系统，要在单机上运行就要采用伪分布式方式**

   1) 在运行目录中，创建tmp hdfs/name hdfs/data目录

```
cd /hadoop/hadoop-1.2.1
mkdir tmp
mkdir hdfs
mkdir hdfs/name
mkdir hdfs/data
```

    2) mapred-site.xml    

```
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
	<property>
        <name>mapred.job.tracker</name>
        <value>localhost:9001</value>
    </property>
</configuration>
```

   3) hdfs-site.xml   

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

<configuration>
	<property>
        <name>dfs.replication</name>
        <value>1</value>
    </property>
    <property>
        <name>dfs.name.dir</name>
        <value>/hadoop/hadoop-1.2.1/hdfs/name</value>
    </property>
    <property>
        <name>dfs.data.dir</name>
        <value>/hadoop/hadoop-1.2.1/hdfs/data</value>
    </property>
</configuration>
```

    4) core-site.xml

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

<configuration>
   <property>
        <name>fs.default.name</name>
        <value>hdfs://localhost:9000</value>
    </property>
    <property>
        <name>hadoop.tmp.dir</name>
        <value>/hadoop/hadoop-1.2.1/tmp</value>
    </property>
</configuration>
```

  

* * *

  **5. 格式化namenode，不然的话在jps里找不到namenode**   

```
hadoop namenode -format
```

    ![](http://dl2.iteye.com/upload/attachment/0098/1057/faa972fd-740b-37a4-a3ed-aea4f4aae6aa.jpg)  

* * *

  **6. 执行启动**

```
start-all.sh
```

    ![](http://dl2.iteye.com/upload/attachment/0098/1059/4dae272c-d5b8-3e17-a5cf-3964b1bcb528.jpg)  

* * *

 **7. 检查启动是否正常，应出现DataNode/NameNode/TaskTracker/SecondaryNameNode/JobTracker进程**

    ![](http://dl2.iteye.com/upload/attachment/0098/1065/3ffa66f7-b077-39e4-9cdb-b5b08da3d402.jpg)

8\. 一切OK，恭喜Hadoop部署运行成功！

最后可自己去运行Hadoop-examples相关例子来试试效果，如：WordCount。