OSDN Git Service

add user limits recipe.
authorwhitestar <whitestar@gaea.test>
Thu, 13 Jun 2013 09:55:11 +0000 (18:55 +0900)
committerwhitestar <whitestar@gaea.test>
Thu, 13 Jun 2013 09:55:11 +0000 (18:55 +0900)
12 files changed:
cookbooks/hadoop/attributes/default.rb
cookbooks/hadoop/recipes/default.rb
cookbooks/hadoop/templates/default/etc/security/limits.d/hdfs.conf [new file with mode: 0644]
cookbooks/hadoop/templates/default/etc/security/limits.d/mapreduce.conf [new file with mode: 0644]
cookbooks/hadoop/templates/default/etc/security/limits.d/yarn.conf [new file with mode: 0644]
cookbooks/zookeeper/attributes/default.rb
cookbooks/zookeeper/recipes/default.rb
cookbooks/zookeeper/templates/default/conf/zoo.cfg
nodes/localhost.json
roles/test-on-localhost.rb
roles/zookeeper-pseudo-replicated.rb
roles/zookeeper-standalone.rb

index a3b0f13..2687a30 100644 (file)
@@ -28,6 +28,7 @@ default['hadoop']['version'] = '1.1.2'
 default['hadoop']['archive_url'] = 'http://archive.apache.org/dist/hadoop/core'
 default['hadoop']['with_security'] = false
 ## hadoop-env.sh
+default['hadoop']['HADOOP_PREFIX'] = "#{node['grid']['app_root']}/hadoop"
 default['hadoop']['HADOOP_CLASSPATH'] = ''
 default['hadoop']['HADOOP_USER_CLASSPATH_FIRST'] = false
 ## hadoop-policy.xml
index 7447723..6b4e0a4 100644 (file)
@@ -131,11 +131,11 @@ node['grid']['max_vol_nums'].to_i.times {|vol_num|
 }
 log "This node active volumes: #{active_vol_nums}"
 
-hadoop_prefix = "#{node['grid']['app_root']}/hadoop-#{node['hadoop']['version']}"
+hadoop_install_root = "#{node['grid']['app_root']}/hadoop-#{node['hadoop']['version']}"
 hadoop_tarball = "hadoop-#{node['hadoop']['version']}.tar.gz"
 downloaded_hadoop_tarball = "#{Chef::Config[:file_cache_path]}/#{hadoop_tarball}"
 
-if ! FileTest.directory? hadoop_prefix then
+if ! FileTest.directory? hadoop_install_root then
   remote_file downloaded_hadoop_tarball do
     source "#{node['hadoop']['archive_url']}/hadoop-#{node['hadoop']['version']}/#{hadoop_tarball}"
     action :create_if_missing
@@ -149,14 +149,32 @@ if ! FileTest.directory? hadoop_prefix then
     code <<-EOC
       tar xvzf #{downloaded_hadoop_tarball} -C #{node['grid']['app_root']}
     EOC
-    creates hadoop_prefix
+    creates hadoop_install_root
   end
   
-  link "#{node['grid']['app_root']}/hadoop" do
-    to hadoop_prefix
+  link node['hadoop']['HADOOP_PREFIX'] do
+    to hadoop_install_root
   end
 end
 
+limits_files = [
+  'hdfs.conf',
+  'yarn.conf',
+  'mapreduce.conf'
+]
+
+limits_files.each {|limits_file|
+  if limits_file == 'yarn.conf' && hadoop_major_version.to_i < 2 then
+    next
+  end
+  template "/etc/security/limits.d/#{limits_file}" do
+    source "etc/security/limits.d/#{limits_file}"
+    owner 'root'
+    group 'root'
+    mode '0644'
+  end
+}
+
 conf_files = [
   'capacity-scheduler.xml',
   'configuration.xsl',
@@ -229,7 +247,7 @@ if node[:kernel][:machine] != 'x86_64' then
     action :install
   end
 
-  link "#{hadoop_prefix}/libexec/jsvc.i386" do
+  link "#{hadoop_install_root}/libexec/jsvc.i386" do
     to '/usr/bin/jsvc'
   end
 end
diff --git a/cookbooks/hadoop/templates/default/etc/security/limits.d/hdfs.conf b/cookbooks/hadoop/templates/default/etc/security/limits.d/hdfs.conf
new file mode 100644 (file)
index 0000000..d9a2fcf
--- /dev/null
@@ -0,0 +1,2 @@
+hdfs   - nofile 32768
+hdfs   - nproc  65536
diff --git a/cookbooks/hadoop/templates/default/etc/security/limits.d/mapreduce.conf b/cookbooks/hadoop/templates/default/etc/security/limits.d/mapreduce.conf
new file mode 100644 (file)
index 0000000..4f34a6c
--- /dev/null
@@ -0,0 +1,2 @@
+mapred    - nofile 32768
+mapred    - nproc  65536
diff --git a/cookbooks/hadoop/templates/default/etc/security/limits.d/yarn.conf b/cookbooks/hadoop/templates/default/etc/security/limits.d/yarn.conf
new file mode 100644 (file)
index 0000000..6b930fe
--- /dev/null
@@ -0,0 +1,2 @@
+yarn   - nofile 32768
+yarn   - nproc  65536
index ee6ae63..7b31438 100644 (file)
 default['grid']['etc_root'] = '/grid/etc'
 default['grid']['app_root'] = '/grid/usr'
 default['grid']['vol_root'] = '/grid/vol'
-default['grid']['max_vol_nums'] = '1'
 
 # default: for pseudo-replicated
 default['zookeeper']['install_flavor'] = 'apache'
 default['zookeeper']['version'] = '3.4.5'
 default['zookeeper']['archive_url'] = 'http://archive.apache.org/dist/zookeeper'
 default['zookeeper']['colo_name'] = 'localhost'
+default['zookeeper']['member_of_hadoop'] = false
 ## run mode: standalone, pseudo-replicated, full-replicated
 default['zookeeper']['run_mode'] = 'standalone'
 default['zookeeper']['with_security'] = false
 default['zookeeper']['realm'] = 'LOCALDOMAIN'
 default['zookeeper']['keytab_dir'] = "#{node['grid']['etc_root']}/keytabs/#{node['zookeeper']['colo_name']}"
 ## zookeeper-env.sh
+default['zookeeper']['ZOOKEEPER_PREFIX'] = "#{node['grid']['app_root']}/zookeeper"
 default['zookeeper']['ZOO_LOG_DIR_PREFIX'] = "#{node['grid']['vol_root']}/0/var/log/zookeeper"
 ## zoo.cfg
 default['zookeeper']['dataDirPrefix'] = "#{node['grid']['vol_root']}/0/var/lib/zookeeper"
@@ -40,6 +41,16 @@ default['zookeeper']['dataLogDir'] = nil
 default['zookeeper']['clientPort'] = '2181'
 default['zookeeper']['ensemble'] = {
 }
+default['zookeeper']['tickTime'] = '2000'
+default['zookeeper']['initLimit'] = '10'
+default['zookeeper']['syncLimit'] = '5'
+### if with_security
+default['zookeeper']['authProvider'] = {
+  '0' => 'org.apache.zookeeper.server.auth.SASLAuthenticationProvider'
+}
+default['zookeeper']['jaasLoginRenew'] = '3600000'
+default['zookeeper']['kerberos.removeHostFromPrincipal'] = 'true'
+default['zookeeper']['kerberos.removeRealmFromPrincipal'] = 'true'
 ## extra settings
 default['zookeeper']['extra_configs'] = {
   # e.g. 'zoo.cfg' => {'k1' => 'v1', 'k2' => 'v2'},
index 7badfbc..484fff8 100644 (file)
@@ -64,11 +64,13 @@ if key != :hadoop
 end
 }
 
-group users[:hadoop][:name] do
-  gid users[:hadoop][:uid]
-  members ['zookeeper']
-  append true
-  action :create
+if node['zookeeper']['member_of_hadoop'] then
+  group users[:hadoop][:name] do
+    gid users[:hadoop][:uid]
+    members ['zookeeper']
+    append true
+    action :create
+  end
 end
 
 directory node['grid']['app_root'] do
@@ -79,11 +81,11 @@ directory node['grid']['app_root'] do
   recursive true
 end
 
-zookeeper_prefix = "#{node['grid']['app_root']}/zookeeper-#{node['zookeeper']['version']}"
+zookeeper_install_root = "#{node['grid']['app_root']}/zookeeper-#{node['zookeeper']['version']}"
 zookeeper_tarball = "zookeeper-#{node['zookeeper']['version']}.tar.gz"
 downloaded_zookeeper_tarball = "#{Chef::Config[:file_cache_path]}/#{zookeeper_tarball}"
 
-if ! FileTest.directory? zookeeper_prefix then
+if ! FileTest.directory? zookeeper_install_root then
   remote_file downloaded_zookeeper_tarball do
     source "#{node['zookeeper']['archive_url']}/zookeeper-#{node['zookeeper']['version']}/#{zookeeper_tarball}"
     action :create_if_missing
@@ -97,11 +99,11 @@ if ! FileTest.directory? zookeeper_prefix then
     code <<-EOC
       tar xvzf #{downloaded_zookeeper_tarball} -C #{node['grid']['app_root']}
     EOC
-    creates zookeeper_prefix
+    creates zookeeper_install_root
   end
   
-  link "#{node['grid']['app_root']}/zookeeper" do
-    to zookeeper_prefix
+  link "#{node['zookeeper']['ZOOKEEPER_PREFIX']}" do
+    to zookeeper_install_root
   end
 end
 
@@ -118,7 +120,7 @@ conf_files = [
 case node['zookeeper']['run_mode']
   when 'standalone'
     node_id = 'standalone'
-    conf_dir = "#{zookeeper_prefix}/conf.#{node_id}"
+    conf_dir = "#{zookeeper_install_root}/conf.#{node_id}"
     directory conf_dir do
       owner 'root'
       group 'root'
@@ -153,7 +155,7 @@ Start command:
   when 'pseudo-replicated'
     clientPort = node['zookeeper']['clientPort'].to_i
     3.times {|node_id|
-      conf_dir = "#{zookeeper_prefix}/conf.#{node_id}"
+      conf_dir = "#{zookeeper_install_root}/conf.#{node_id}"
       directory conf_dir do
         owner 'root'
         group 'root'
@@ -199,7 +201,7 @@ Start command:
   $ sudo -u zookeeper sh -c 'export ZOOCFGDIR=/grid/usr/zookeeper/conf.2;./bin/zkServer.sh start'
     EOM
   when 'full-replicated'
-    conf_dir = "#{zookeeper_prefix}/conf"
+    conf_dir = "#{zookeeper_install_root}/conf"
     %w{lib log}.each {|dir|
       directory "#{node['grid']['vol_root']}/0/var/#{dir}/zookeeper" do
         owner 'zookeeper'
index 60fd687..ba9b027 100644 (file)
@@ -1,11 +1,11 @@
 # The number of milliseconds of each tick
-tickTime=2000
+tickTime=<%= node['zookeeper']['tickTime'] %>
 # The number of ticks that the initial 
 # synchronization phase can take
-initLimit=10
+initLimit=<%= node['zookeeper']['initLimit'] %>
 # The number of ticks that can pass between 
 # sending a request and getting an acknowledgement
-syncLimit=5
+syncLimit=<%= node['zookeeper']['syncLimit'] %>
 # the directory where the snapshot is stored.
 # do not use /tmp for storage, /tmp here is just 
 # example sakes.
@@ -19,11 +19,17 @@ dataLogDir=<%= dataLogDir %>
 <% end %>
 # the port at which the clients will connect
 clientPort=<%= @clientPort %>
-<% if node['zookeeper']['with_security'] then %>
-authProvider.0=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
-jaasLoginRenew=3600000
-kerberos.removeHostFromPrincipal=true
-kerberos.removeRealmFromPrincipal=true
+<%
+if node['zookeeper']['with_security'] then
+  node['zookeeper']['authProvider'].each do |id, class_name|
+%>
+authProvider.<%= id %>=<%= class_name %>
+<%
+  end
+%>
+jaasLoginRenew=<%= node['zookeeper']['jaasLoginRenew'] %>
+kerberos.removeHostFromPrincipal=<%= node['zookeeper']['kerberos.removeHostFromPrincipal'] %>
+kerberos.removeRealmFromPrincipal=<%= node['zookeeper']['kerberos.removeRealmFromPrincipal'] %>
 # available?!
 #requireClientAuthScheme=sasl
 #allowSaslFailedClients=false
index a26a993..23cc892 100644 (file)
@@ -1,7 +1,5 @@
 {
   "run_list": [
-    "role[mocker]",
-    "role[hadoop-pseudo-distributed-with-security]",
-    "role[zookeeper-pseudo-replicated-with-security]"
+    "role[test-on-localhost]"
   ]
 }
index f576774..55fd982 100644 (file)
@@ -2,7 +2,9 @@ name 'test-on-localhost'
 description 'Testing on local machine'
 
 run_list(
-  'role[hadoop-pseudo-distributed-with-security]'
+  'role[mocker]',
+  'role[hadoop-pseudo-distributed-with-security]',
+  'role[zookeeper-pseudo-replicated-with-security]'
 )
 
 #env_run_lists "prod" => ["recipe[apache2]"], "staging" => ["recipe[apache2::staging]"], "_default" => []
index 9751309..5f008b9 100644 (file)
@@ -10,6 +10,7 @@ run_list(
 default_attributes(
   'zookeeper' => {
     'run_mode' => 'pseudo-replicated',
+    'member_of_hadoop' => true,
     'clientPort' => '2180'
   }
 )
index ab13d37..2dd5402 100644 (file)
@@ -10,6 +10,7 @@ run_list(
 default_attributes(
   'zookeeper' => {
     'run_mode' => 'standalone'
+    'member_of_hadoop' => true
   }
 )