本文的目的主要是为了说明如何单点配置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