Browse Source

AMBARI-2775. Ability to add second Namenode to the cluster for 2.0.* stack. (swagle)

Siddharth Wagle 11 năm trước cách đây
mục cha
commit
f319832a8d

+ 26 - 22
ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/namenode/format.pp

@@ -27,31 +27,35 @@ class hdp-hadoop::namenode::format(
   $hdfs_user = $hdp::params::hdfs_user
   $hadoop_conf_dir = $hdp-hadoop::params::conf_dir
 
-  if ($force == true) {
-      hdp-hadoop::exec-hadoop { 'namenode -format' :
-      command => 'namenode -format',
-      kinit_override => true,
-      notify  => Hdp::Exec['set namenode mark']
-    }
-  } else {
+  # Avoid formatting standby namenode in a HA cluster
+  if ($hdp::params::dfs_ha_enabled == false) {
+    if ($force == true) {
+        hdp-hadoop::exec-hadoop { 'namenode -format' :
+        command => 'namenode -format',
+        kinit_override => true,
+        notify  => Hdp::Exec['set namenode mark']
+      }
+    } else {
+
       file { '/tmp/checkForFormat.sh':
-      ensure => present,
-      source => "puppet:///modules/hdp-hadoop/checkForFormat.sh",
-      mode => '0755'
-    }
+        ensure => present,
+        source => "puppet:///modules/hdp-hadoop/checkForFormat.sh",
+        mode => '0755'
+      }
 
-    exec { '/tmp/checkForFormat.sh':
-      command   => "sh /tmp/checkForFormat.sh ${hdfs_user} ${hadoop_conf_dir} ${mark_dir} ${dfs_name_dir} ",
-      unless   => "test -d ${mark_dir}",
-      require   => File['/tmp/checkForFormat.sh'],
-      path      => '/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
-      logoutput => "true",
-      notify   => Hdp::Exec['set namenode mark']
+      exec { '/tmp/checkForFormat.sh':
+        command   => "sh /tmp/checkForFormat.sh ${hdfs_user} ${hadoop_conf_dir} ${mark_dir} ${dfs_name_dir} ",
+        unless   => "test -d ${mark_dir}",
+        require   => File['/tmp/checkForFormat.sh'],
+        path      => '/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
+        logoutput => "true",
+        notify   => Hdp::Exec['set namenode mark']
+      }
     }
-  }
 
-  hdp::exec { 'set namenode mark' :
-    command     => "mkdir -p ${mark_dir}",
-    refreshonly => true
+    hdp::exec { 'set namenode mark' :
+      command     => "mkdir -p ${mark_dir}",
+      refreshonly => true
+    }
   }
 }

+ 3 - 0
ambari-agent/src/main/puppet/modules/hdp-hadoop/templates/hadoop-env.sh.erb

@@ -108,3 +108,6 @@ done
 #Add libraries required by nodemanager
 MAPREDUCE_LIBS=<%=scope.function_hdp_template_var("mapreduce_libs_path")%> 
 export HADOOP_CLASSPATH=${HADOOP_CLASSPATH}${JAVA_JDBC_LIBS}:${MAPREDUCE_LIBS}
+
+# Setting path to hdfs command line
+export HADOOP_LIBEXEC_DIR=<%=scope.function_hdp_template_var("hadoop_libexec_dir")%>

+ 1 - 1
ambari-agent/src/main/puppet/modules/hdp-oozie/files/oozieSmoke2.sh

@@ -64,7 +64,7 @@ export NNHOST=$8
 
 export OOZIE_EXIT_CODE=0
 export JOBTRACKER=`getValueFromField ${hadoop_conf_dir}/yarn-site.xml yarn.resourcemanager.address`
-export NAMENODE=`getValueFromField ${hadoop_conf_dir}/core-site.xml fs.default.name`
+export NAMENODE=`getValueFromField ${hadoop_conf_dir}/core-site.xml fs.defaultFS`
 export OOZIE_SERVER=`getValueFromField ${oozie_conf_dir}/oozie-site.xml oozie.base.url`
 export OOZIE_EXAMPLES_DIR=`rpm -ql oozie-client | grep 'oozie-examples.tar.gz$' | xargs dirname`
 cd $OOZIE_EXAMPLES_DIR

+ 14 - 2
ambari-agent/src/main/puppet/modules/hdp/manifests/params.pp

@@ -293,7 +293,7 @@ class hdp::params()
  
   $exec_path = ["/bin","/usr/bin", "/usr/sbin"]
 
-   #### params used on multiple modules
+  #### params used on multiple modules
   $dfs_data_dir = hdp_default("hdfs-site/dfs.data.dir","/tmp/hadoop-hdfs/dfs/data")
 
   ### artifact dir
@@ -301,7 +301,19 @@ class hdp::params()
 
   ### artifacts download url ##
   $apache_artifacts_download_url = hdp_default("apache_artifacts_download_url","")
-  $gpl_artifacts_download_url = hdp_default("gpl_artifacts_download_url","") 
+  $gpl_artifacts_download_url = hdp_default("gpl_artifacts_download_url","")
+
+  # hdfs ha settings
+  $dfs_ha_nameservices = hdp_default("hdfs-site/dfs.nameservices")
+  $dfs_ha_namenode_ids = hdp_default("hdfs-site/dfs.ha.namenodes.${dfs_ha_nameservices}")
+  if (hdp_is_empty($dfs_ha_namenode_ids) == false) {
+    $dfs_ha_namenode_ids_array_len = inline_template("<%=(dfs_ha_namenode_ids).split(',').size()%>")
+    if ($dfs_ha_namenode_ids_array_len > 1) {
+      $dfs_ha_enabled = true
+    }
+  } else {
+    $dfs_ha_enabled = false
+  }
 
   $packages = 'bigtop' 
   if ($packages == 'hdp') {