18
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Chefで構築するHadoop環境

Last updated at Posted at 2014-07-05

環境

  • Mac OSX Mavericks
  • Vagrant 1.6.3 (box: chef/centos-6.5)
  • Chef-solo 11.14.0.alpha.4
  • jdk: jdk-8u5-linux-x64
  • hadoop: 0.18.3-14.cloudera.CH0_3(stable?)

Hadoop導入の流れ

  1. JDKをインストールする
  2. Hadoopをインストールする
  3. 試験する

今回は、chefを使用して1.と2.を実現します。3.は、Hadoopインストール時にサンプルとして導入されるプログラムをHadoop上で動かしてみます。

レシピ

レシピの中身

recipes/default.rb
#
# making environment for hadoop
#

# 1. JDKをインストールする
jdk_file_name="jdk-8u5-linux-x64"

execute "download_jdk" do
	user "vagrant"
	group "vagrant"
	cwd "/home/vagrant"
	command "wget --no-check-certificate --no-cookies --header 'Cookie: oraclelicense=accept-securebackup-cookie' http://download.oracle.com/otn-pub/java/jdk/8u5-b13/#{jdk_file_name}.rpm -O #{jdk_file_name}.rpm"
	not_if { ::File.exists?("/home/vagrant/#{jdk_file_name}.rpm") }
end

package "install_jdk" do
	source "/home/vagrant/#{jdk_file_name}.rpm"
	provider Chef::Provider::Package::Rpm
	action :install
end

# 2. Hadoopをインストールする
execute "add_repo_for_cloudera" do
	user "root"
	group "root"
	command "wget http://archive-primary.cloudera.com/redhat/cdh/cloudera-stable.repo -O /etc/yum.repos.d/cloudera-stable.repo"
	not_if { ::File.exists?("/etc/yum.repos.d/cloudera-stable.repo") }
end

%w(
	hadoop
	hadoop-conf-pseudo
).each do |package_name|
	package package_name do
		action :install
	end
end

%w(
	hadoop-datanode
	hadoop-jobtracker
	hadoop-namenode
	hadoop-secondarynamenode
	hadoop-tasktracker
).each do |service_name|
	service service_name do
		action [ :enable, :start ]
		supports :start => true, :stop => true, :restart => true
	end
end

## ポイント

  • JDKをダウンロードする際には、ライセンス条項への同意が必要となるので、wgetの引数に--header 'Cookie: oraclelicense=accept-securebackup-cookie'を与える必要がある
  • JDKのダウンロードと、Clouderaのレポジトリファイルを追加する際にはnot_ifを使用してべき等性を確保する

インストール後の動作確認

インストールが上手くいっているかの確認をするために、サンプルプログラムをHadoop上で動作させてみます。

terminal
[vagrant@localhost ~]$ hadoop jar /usr/lib/hadoop/hadoop-0.18.3-14.cloudera.CH0_3-test.jar mrbench
MRBenchmark.0.0.2
14/07/05 12:50:07 INFO mapred.MRBench: creating control file: 1 numLines, ASCENDING sortOrder
14/07/05 12:50:07 INFO mapred.MRBench: created control file: /benchmarks/MRBench/mr_input/input_475033013.txt
14/07/05 12:50:07 INFO mapred.MRBench: Running job 0: input=hdfs://localhost/benchmarks/MRBench/mr_input output=hdfs://localhost/benchmarks/MRBench/mr_output/output_-320582194
14/07/05 12:50:07 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
14/07/05 12:50:07 INFO mapred.FileInputFormat: Total input paths to process : 1
14/07/05 12:50:07 INFO mapred.FileInputFormat: Total input paths to process : 1
14/07/05 12:50:08 INFO mapred.JobClient: Running job: job_201407051248_0001
14/07/05 12:50:09 INFO mapred.JobClient:  map 0% reduce 0%
14/07/05 12:50:18 INFO mapred.JobClient:  map 100% reduce 0%
14/07/05 12:50:23 INFO mapred.JobClient: Job complete: job_201407051248_0001
14/07/05 12:50:23 INFO mapred.JobClient: Counters: 16
14/07/05 12:50:23 INFO mapred.JobClient:   Map-Reduce Framework
14/07/05 12:50:23 INFO mapred.JobClient:     Combine output records=0
14/07/05 12:50:23 INFO mapred.JobClient:     Reduce input records=1
14/07/05 12:50:23 INFO mapred.JobClient:     Reduce output records=1
14/07/05 12:50:23 INFO mapred.JobClient:     Map input records=1
14/07/05 12:50:23 INFO mapred.JobClient:     Map output records=1
14/07/05 12:50:23 INFO mapred.JobClient:     Map output bytes=5
14/07/05 12:50:23 INFO mapred.JobClient:     Combine input records=0
14/07/05 12:50:23 INFO mapred.JobClient:     Map input bytes=2
14/07/05 12:50:23 INFO mapred.JobClient:     Reduce input groups=1
14/07/05 12:50:23 INFO mapred.JobClient:   File Systems
14/07/05 12:50:23 INFO mapred.JobClient:     HDFS bytes written=3
14/07/05 12:50:23 INFO mapred.JobClient:     Local bytes written=128
14/07/05 12:50:23 INFO mapred.JobClient:     HDFS bytes read=4
14/07/05 12:50:23 INFO mapred.JobClient:     Local bytes read=21
14/07/05 12:50:23 INFO mapred.JobClient:   Job Counters
14/07/05 12:50:23 INFO mapred.JobClient:     Launched map tasks=2
14/07/05 12:50:23 INFO mapred.JobClient:     Launched reduce tasks=1
14/07/05 12:50:23 INFO mapred.JobClient:     Data-local map tasks=2
DataLines	Maps	Reduces	AvgTime (milliseconds)
1		2	1	16407

うまく動作してるっぽいです。

今後に向けて

  • Jenkins等を使ってインフラ試験も自動化したい
  • Vagrantで複数ノード立ちあげて、本当の同時並列処理を試してみたい
18
17
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?