Learn to Live and Live to Learn

IT(たまにビジネス)に関する記事を読んで、考えて、使ってみたことをまとめる場。

MacでHadoop【スタンドアロンモード編】

サーバが複数台なくてもHadoopは使えます(知ってるわ!という話かもしれませんし、早い処理はできませんが)。
勉強のためMacにHadoopを入れてみました。

http://ftp.yz.yamagata-u.ac.jp/pub/network/apache/hadoop/common/stable2/
にてhadoop-2.2.0.tar.gzをダウンロード(2系初の安定板!)。

hadoopと打ってみる。

$ /usr/local/bin/hadoop-2.2.0/bin/hadoop
Usage: hadoop [--config confdir] COMMAND
       where COMMAND is one of:
  fs                   run a generic filesystem user client
  version              print the version
  jar <jar>            run a jar file
  checknative [-a|-h]  check native hadoop and compression libraries availability
  distcp <srcurl> <desturl> copy file or directories recursively
  archive -archiveName NAME -p <parent path> <src>* <dest> create a hadoop archive
  classpath            prints the class path needed to get the
                       Hadoop jar and the required libraries
  daemonlog            get/set the log level for each daemon
 or
  CLASSNAME            run the class named CLASSNAME

Most commands print help when invoked w/o parameters.

Usage出たー!

ファイルとディレクトリを用意。

$ mkdir input
$ vim input/test.txt
To be or not to be, that is the question.
$ mkdir output

jarファイルを実行してみる。

$ hadoop jar hadoop-mapreduce-examples-2.2.0.jar wordcount input output/wordcount

よし!

$ ls output/wordcount/
_SUCCESS	part-r-00000
$ cat output/wordcount/part-r-00000
To	1
be	1
be,	1
is	1
not	1
or	1
question.	1
that	1
the	1
to	1


Hadoopをどこに置くか(/usr/bin/と/usr/local/bin/の差異)
http://oswald.hatenablog.com/entry/20100416/1271368477

Hadoop事始め
http://www.scienceq.com/itinfra/index.php?Hadoop%2F%A5%A4%A5%F3%A5%B9%A5%C8%A1%BC%A5%EB