本文的目的主要是爲了說明如何單點配置hadoop,從而能使用單個節點進行Hadoop MapReduce 和Hadoop Distributed File System (HDFS)運算。 html
不管在Linux 仍是在 Windows都須要以下軟件: node
另外 Windows 環境還須要安裝以下軟件: web
若是你的集羣沒有安裝必要的軟件,請安裝他們. shell
Ubuntu Linux 的一個例子: express
$ sudo apt-get install ssh $ sudo apt-get install rsync在 Windows上, 若是在你安裝cygwin的時候你沒有安裝必要的軟件, 開啓cygwin安裝軟件選擇以下文件夾:
從這裏下載一個穩定版本 stable release . apache
解壓下載的Hadoop distribution文件. 編輯 conf/hadoop-env.sh 定義 JAVA_HOME 到你的安裝目錄. ssh
嘗試使用以下命令: 分佈式
$ bin/hadoop將展現出對於使用 hadoop script 有用的文檔信息.
如今你能夠開始如下三種中的一種你的開啓你的 Hadoop cluster : oop
在默認狀況下會以非分佈式模式(non-distributed mode)做爲一個Java進程運行.這樣作的好處是有利於調試..
The following example copies the unpacked conf directory to use as input and then finds and displays every match of the given regular expression. Output is written to the given output directory. 學習
$ mkdir input $ cp conf/*.xml input $ bin/hadoop jar hadoop-examples-*.jar grep input output 'dfs[a-z.]+' $ cat output/*
Hadoop也能夠運行一個單點,每一個Hadoop 實例(daemon) 以一個獨立的Java進程運行,從而使Hadoop以僞分佈式模式運行。
使用以下配置:
conf/core-site.xml:
<configuration> <property> <name>fs.default.name</name> <value>hdfs://localhost:9000</value> </property> </configuration>
conf/hdfs-site.xml:
<configuration> <property> <name>dfs.replication</name> <value>1</value> </property> </configuration>
conf/mapred-site.xml:
<configuration> <property> <name>mapred.job.tracker</name> <value>localhost:9001</value> </property> </configuration>
檢查您能夠經過 ssh登陸 localhost 不適用密碼:
$ ssh localhost
If you cannot ssh to localhost without a passphrase, execute the following commands:
$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
格式化一個分佈式文件系統:
$ bin/hadoop namenode -format運行hadoop daemons:
$ bin/start-all.sh
hadoop daemon 把日誌輸出在 ${HADOOP_LOG_DIR} 指定的目錄下 (默認在 ${HADOOP_HOME}/logs).
瀏覽NameNode和JobTracker的web接口,默認狀況下在:
拷貝文件到分佈式系統:
$ bin/hadoop fs -put conf input
運行提供的例子:
$ bin/hadoop jar hadoop-examples-*.jar grep input output 'dfs[a-z.]+'
檢查輸出的文件:
拷貝輸出的文件到本地文件系統,而且檢查他們:
$ bin/hadoop fs -get output output $ cat output/*或者,你也能夠這麼作,
瀏覽分佈式系統上輸出的文件:
$ bin/hadoop fs -cat output/*當你完成工做以後,使用以下命令中止daemons:
$ bin/stop-all.sh以上是本人我的爲了學習hadoop,對官方的文檔的翻譯,若有差錯,請你們指正!謝謝。
官網該篇的地址是:http://hadoop.apache.org/docs/stable/single_node_setup.html