互联网

在Ubuntu上装Hadoop

在装Hadoop之前首先需要:

 1.java1.6.x 最好是sun的,1.5.x也可以

 2.ssh

 安装ssh

$ sudo apt-get install ssh

$ sudo apt-get install rsync

下载Hadoop

 从http://hadoop.apache.org/core/releases.html 下载最近发布的版本

 最好为hadoop创建一个用户:

 比如创建一个group为hadoop user为hadoop的用户以及组

 $ sudo addgroup hadoop

$ sudo adduser --ingroup hadoop hadoop

解压下载的hadoop文件,放到/home/hadoop目录下 名字为hadoop

 配置JAVA_HOME:

  gedit ~/hadoop/conf/hadoop-env.sh

将Java代码

1. # The java implementation to use.  Required. 

2. # export JAVA_HOME=/usr/lib/j2sdk1.5-sun 

 

 # The java implementation to use.  Required.

 # export JAVA_HOME=/usr/lib/j2sdk1.5-sun

修改成java的安装目录:

# The java implementation to use. Required.

export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.15

现在可以使用单节点的方式运行:

$ cd hadoop

$ mkdir input

$ cp conf/*.xml input

$ bin/hadoop jar hadoop-*-examples.jar grep input output 'dfs[a-z.]+'

$ cat output/*

 Pseudo-distributed方式跑:

  配置ssh

 $ su - hadoop

$ ssh-keygen -t rsa -P ""

Generating public/private rsa key pair.

Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):

Created directory '/home/hadoop/.ssh'.

Your identification has been saved in /home/hadoop/.ssh/id_rsa.

Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.

The key fingerprint is:

9d:47:ab:d7:22:54:f0:f9:b9:3b:64:93:12:75:81:27 hadoop@ubuntu

让其不输入密码就能登录:

  hadoop@ubuntu:~$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

使用:

  $ ssh localhost

看看是不是直接ok了。

 

hadoop配置文件:

  conf/core-site.xml

[!--page.stats—]
希望看到您的想法,请您发表评论x