日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

在Ubuntu上裝Hadoop - fuliang - JavaEye技術(shù)網(wǎng)站

 ShangShujie 2010-04-15

在裝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./core/releases.html 下 載最近發(fā)布的版本

 

最好為hadoop創(chuàng)建一個用戶:

比如創(chuàng)建一個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  

 

 修改成java的安裝目錄:(我的是:/usr/lib/jvm/java-6-sun-1.6.0.15)

 

# The java implementation to use. Required.
export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.15
 

 

現(xiàn)在可以使用單節(jié)點的方式運行:

 

$ 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

 

Java代碼
  1. <?xml version="1.0"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3.   
  4. <!-- Put site-specific property overrides in this file. -->  
  5.   
  6. <configuration>  
  7.    <property>  
  8.     <name>hadoop.tmp.dir</name>  
  9.         <value>/home/hadoop/hadoop-datastore/hadoop-${user.name}</value>  
  10.    </property>  
  11.    <property>  
  12.     <name>fs.default.name</name>  
  13.     <value>hdfs://localhost:9000</value>  
  14.    </property>  
  15. </configuration>  

 

 hadoop.tmp.dir配置為你想要的路徑,${user.name} 會自動擴展為運行hadoop的用戶名

 

conf/hdfs-site.xml

 

Xml代碼
  1. <configuration>  
  2.   <property>  
  3.     <name>dfs.replication</name>  
  4.     <value>1</value>  
  5.   </property>  
  6. </configuration>  

 

 dfs.replication為默認block復(fù)制數(shù)量

conf/mapred-site.xml

 

Xml代碼
  1. <configuration>  
  2.   <property>  
  3.     <name>mapred.job.tracker</name>  
  4.     <value>localhost:9001</value>  
  5.   </property>  
  6. </configuration>  

 

 執(zhí)行

 

格式化分布式文件系統(tǒng):

 

$ bin/hadoop namenode -format

 

 啟動hadoop:

 

Java代碼
  1. $ bin/start-all.sh  

 

 可以從

 

NameNode - http://localhost:50070/
JobTracker - http://localhost:50030/

 

 查看NameNode和JobTracker

 

運行例子:

 

 

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

 

look at the run result:

$ bin/hadoop fs -get output output
$ cat output/*
 

 

參考: 1、http://hadoop./common/docs/current/quickstart.html
2、http://www./wiki /Running_Hadoop_On_Ubuntu_Linux_%28Single-Node_Cluster%29

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多