ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: AMBARI-5267 Hive metastore install fails on multinode cluster (dsen)
Date Fri, 28 Mar 2014 22:23:13 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk bdddb9bb0 -> aec2d1883


AMBARI-5267 Hive metastore install fails on multinode cluster (dsen)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/aec2d188
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/aec2d188
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/aec2d188

Branch: refs/heads/trunk
Commit: aec2d18830953b7e05280a6fd45a642045ed44e9
Parents: bdddb9b
Author: Dmitry Sen <dsen@hortonworks.com>
Authored: Sat Mar 29 00:23:05 2014 +0200
Committer: Dmitry Sen <dsen@hortonworks.com>
Committed: Sat Mar 29 00:23:05 2014 +0200

----------------------------------------------------------------------
 .../2.0.6/services/HIVE/package/scripts/hive.py |  15 ++
 .../HIVE/package/scripts/hive_metastore.py      |  18 --
 .../services/HIVE/package/scripts/params.py     |   3 +-
 .../stacks/HDP/2.1/role_command_order.json      |   1 -
 .../stacks/2.1/HIVE/test_hive_metastore.py      | 234 +++++++++++++++++++
 .../test/python/stacks/2.1/configs/default.json |   2 +-
 .../test/python/stacks/2.1/configs/secured.json |   2 +-
 7 files changed, 252 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/aec2d188/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive.py
index 8dd2745..e1ef61f 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive.py
@@ -79,6 +79,21 @@ def hive(name=None):
          content=StaticFile('startMetastore.sh')
     )
 
+    if params.init_metastore_schema:
+      create_schema_cmd = format("{hive_bin}/schematool -initSchema "
+                                 "-dbType {hive_metastore_db_type} "
+                                 "-userName {hive_metastore_user_name} "
+                                 "-passWord {hive_metastore_user_passwd}")
+
+      check_schema_created_cmd = format("{hive_bin}/schematool -info "
+                                        "-dbType {hive_metastore_db_type} "
+                                        "-userName {hive_metastore_user_name} "
+                                        "-passWord {hive_metastore_user_passwd}")
+
+      Execute(create_schema_cmd,
+              not_if = check_schema_created_cmd
+      )
+
   elif name == 'hiveserver2':
     File(params.start_hiveserver2_path,
          mode=0755,

http://git-wip-us.apache.org/repos/asf/ambari/blob/aec2d188/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive_metastore.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive_metastore.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive_metastore.py
index cd250ce..7d607f3 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive_metastore.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/hive_metastore.py
@@ -29,8 +29,6 @@ class HiveMetastore(Script):
 
   def install(self, env):
     self.install_packages(env)
-    self.configure(env)
-    self._init_metastore_schema(env)
 
   def configure(self, env):
     import params
@@ -61,21 +59,5 @@ class HiveMetastore(Script):
     # Recursively check all existing gmetad pid files
     check_process_status(pid_file)
 
-  def _init_metastore_schema(self, env):
-    import params
-    env.set_params(params)
-    if params.init_metastore_schema:
-      mysql_service(daemon_name=params.daemon_name, action='start')
-
-      cmd = format("export JAVA_HOME={java_home} ; {hive_bin}/schematool "
-                   "-dbType {hive_metastore_db_type} -initSchema "
-                   "-userName {hive_metastore_user_name} "
-                   "-passWord {hive_metastore_user_passwd}")
-
-      Execute(cmd
-      )
-
-      mysql_service(daemon_name=params.daemon_name, action='stop')
-
 if __name__ == "__main__":
   HiveMetastore().execute()

http://git-wip-us.apache.org/repos/asf/ambari/blob/aec2d188/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/params.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/params.py
index 664b676..52ba5c5 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HIVE/package/scripts/params.py
@@ -45,7 +45,6 @@ check_db_connection_jar_name = "DBConnectionVerification.jar"
 check_db_connection_jar = format("/usr/lib/ambari-agent/{check_db_connection_jar_name}")
 
 #common
-java_home = config['hostLevelParams']['java_home']
 hdp_stack_version = config['hostLevelParams']['stack_version']
 hive_metastore_port = config['configurations']['global']['hive_metastore_port']
 hive_var_lib = '/var/lib/hive'
@@ -113,7 +112,7 @@ mysql_adduser_path = "/tmp/addMysqlUser.sh"
 ######## Metastore Schema
 if str(hdp_stack_version).startswith('2.1') and \
     config['configurations']['global']['hive_database'] == 'New MySQL Database':
-  init_metastore_schema =True
+  init_metastore_schema = True
 else:
   init_metastore_schema = False
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/aec2d188/ambari-server/src/main/resources/stacks/HDP/2.1/role_command_order.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.1/role_command_order.json b/ambari-server/src/main/resources/stacks/HDP/2.1/role_command_order.json
index f6b499a..ded1d23 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.1/role_command_order.json
+++ b/ambari-server/src/main/resources/stacks/HDP/2.1/role_command_order.json
@@ -5,7 +5,6 @@
     "_comment" : "dependencies for all cases",
     "NAGIOS_SERVER-INSTALL" : ["HIVE_CLIENT-INSTALL", "HCAT-INSTALL",
         "MAPREDUCE_CLIENT-INSTALL", "OOZIE_CLIENT-INSTALL"],
-    "HIVE_METASTORE-INSTALL": ["MYSQL_SERVER-INSTALL"],
     "NIMBUS-START" : ["ZOOKEEPER_SERVER-START"],
     "SUPERVISOR-START" : ["NIMBUS-START"],
     "STORM_UI_SERVER-START" : ["NIMBUS-START"],

http://git-wip-us.apache.org/repos/asf/ambari/blob/aec2d188/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py b/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
new file mode 100644
index 0000000..79482eb
--- /dev/null
+++ b/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
@@ -0,0 +1,234 @@
+#!/usr/bin/env python
+
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+'''
+from mock.mock import MagicMock, call, patch
+from stacks.utils.RMFTestCase import *
+
+class TestHiveMetastore(RMFTestCase):
+
+  def test_configure_default(self):
+    self.executeScript("2.0.6/services/HIVE/package/scripts/hive_metastore.py",
+                       classname = "HiveMetastore",
+                       command = "configure",
+                       config_file="../../2.1/configs/default.json"
+    )
+    self.assert_configure_default()
+
+  def test_start_default(self):
+    self.executeScript("2.0.6/services/HIVE/package/scripts/hive_metastore.py",
+                       classname = "HiveMetastore",
+                       command = "start",
+                       config_file="../../2.1/configs/default.json"
+    )
+
+    self.assert_configure_default()
+    self.assertResourceCalled('Execute', 'env HADOOP_HOME=/usr JAVA_HOME=/usr/jdk64/jdk1.7.0_45
/tmp/start_metastore_script /var/log/hive/hive.out /var/log/hive/hive.log /var/run/hive/hive.pid
/etc/hive/conf.server',
+                              not_if = 'ls /var/run/hive/hive.pid >/dev/null 2>&1
&& ps `cat /var/run/hive/hive.pid` >/dev/null 2>&1',
+                              user = 'hive'
+    )
+
+    self.assertResourceCalled('Execute', '/usr/jdk64/jdk1.7.0_45/bin/java -cp /usr/lib/ambari-agent/DBConnectionVerification.jar:/usr/share/java/mysql-connector-java.jar
org.apache.ambari.server.DBConnectionVerification jdbc:mysql://c6402.ambari.apache.org/hive?createDatabaseIfNotExist=true
hive asd com.mysql.jdbc.Driver',
+                              path=['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin']
+    )
+
+    self.assertNoMoreResources()
+
+  def test_stop_default(self):
+    self.executeScript("2.0.6/services/HIVE/package/scripts/hive_metastore.py",
+                       classname = "HiveMetastore",
+                       command = "stop",
+                       config_file="../../2.1/configs/default.json"
+    )
+
+    self.assertResourceCalled('Execute', 'kill `cat /var/run/hive/hive.pid` >/dev/null
2>&1 && rm -f /var/run/hive/hive.pid')
+    self.assertNoMoreResources()
+
+  def test_configure_secured(self):
+    self.executeScript("2.0.6/services/HIVE/package/scripts/hive_metastore.py",
+                       classname = "HiveMetastore",
+                       command = "configure",
+                       config_file="../../2.1/configs/secured.json"
+    )
+    self.assert_configure_default()
+    self.assertNoMoreResources()
+
+  def test_start_secured(self):
+    self.executeScript("2.0.6/services/HIVE/package/scripts/hive_metastore.py",
+                       classname = "HiveMetastore",
+                       command = "start",
+                       config_file="../../2.1/configs/secured.json"
+    )
+
+    self.assert_configure_secured()
+    self.assertResourceCalled('Execute', 'env HADOOP_HOME=/usr JAVA_HOME=/usr/jdk64/jdk1.7.0_45
/tmp/start_metastore_script /var/log/hive/hive.out /var/log/hive/hive.log /var/run/hive/hive.pid
/etc/hive/conf.server',
+                              not_if = 'ls /var/run/hive/hive.pid >/dev/null 2>&1
&& ps `cat /var/run/hive/hive.pid` >/dev/null 2>&1',
+                              user = 'hive'
+    )
+
+    self.assertResourceCalled('Execute', '/usr/jdk64/jdk1.7.0_45/bin/java -cp /usr/lib/ambari-agent/DBConnectionVerification.jar:/usr/share/java/mysql-connector-java.jar
org.apache.ambari.server.DBConnectionVerification jdbc:mysql://c6402.ambari.apache.org/hive?createDatabaseIfNotExist=true
hive asd com.mysql.jdbc.Driver',
+                              path=['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin']
+    )
+
+    self.assertNoMoreResources()
+
+  def test_stop_secured(self):
+    self.executeScript("2.0.6/services/HIVE/package/scripts/hive_metastore.py",
+                       classname = "HiveMetastore",
+                       command = "stop",
+                       config_file="../../2.1/configs/secured.json"
+    )
+
+    self.assertResourceCalled('Execute', 'kill `cat /var/run/hive/hive.pid` >/dev/null
2>&1 && rm -f /var/run/hive/hive.pid')
+    self.assertNoMoreResources()
+
+  def assert_configure_default(self):
+    self.assertResourceCalled('Execute', 'hive mkdir -p /tmp/HDP-artifacts/ ; cp /usr/share/java/mysql-connector-java.jar
/usr/lib/hive/lib//mysql-connector-java.jar',
+      creates = '/usr/lib/hive/lib//mysql-connector-java.jar',
+      path = ['/bin', '/usr/bin/'],
+      not_if = 'test -f /usr/lib/hive/lib//mysql-connector-java.jar',
+    )
+    self.assertResourceCalled('Directory', '/etc/hive/conf.server',
+      owner = 'hive',
+      group = 'hadoop',
+      recursive = True,
+    )
+    self.assertResourceCalled('XmlConfig', 'mapred-site.xml',
+      owner = 'hive',
+      group = 'hadoop',
+      mode = 0600,
+      conf_dir = '/etc/hive/conf.server',
+      configurations = self.getConfig()['configurations']['mapred-site'],
+    )
+    self.assertResourceCalled('XmlConfig', 'hive-site.xml',
+      owner = 'hive',
+      group = 'hadoop',
+      mode = 0600,
+      conf_dir = '/etc/hive/conf.server',
+      configurations = self.getConfig()['configurations']['hive-site'],
+    )
+    self.assertResourceCalled('Execute', "/bin/sh -c 'cd /usr/lib/ambari-agent/ &&
curl -kf --retry 5 http://c6401.ambari.apache.org:8080/resources/DBConnectionVerification.jar
-o DBConnectionVerification.jar'",
+      not_if = '[ -f DBConnectionVerification.jar]',
+    )
+    self.assertResourceCalled('File', '/tmp/start_metastore_script',
+      content = StaticFile('startMetastore.sh'),
+      mode = 0755,
+    )
+    self.assertResourceCalled('Execute', "/usr/lib/hive/bin/schematool -initSchema -dbType
mysql -userName hive -passWord asd",
+      not_if = '/usr/lib/hive/bin/schematool -info -dbType mysql -userName hive -passWord
asd',
+    )
+    self.assertResourceCalled('Directory', '/var/run/hive',
+      owner = 'hive',
+      group = 'hadoop',
+      mode = 0755,
+      recursive = True,
+    )
+    self.assertResourceCalled('Directory', '/var/log/hive',
+      owner = 'hive',
+      group = 'hadoop',
+      mode = 0755,
+      recursive = True,
+    )
+    self.assertResourceCalled('Directory', '/var/lib/hive',
+      owner = 'hive',
+      group = 'hadoop',
+      mode = 0755,
+      recursive = True,
+    )
+    self.assertResourceCalled('File', '/etc/hive/conf.server/hive-env.sh',
+      content = Template('hive-env.sh.j2', conf_dir="/etc/hive/conf.server"),
+      owner = 'hive',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/hive/conf/hive-default.xml.template',
+      owner = 'hive',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/hive/conf/hive-env.sh.template',
+      owner = 'hive',
+      group = 'hadoop',
+    )
+
+  def assert_configure_secured(self):
+    self.assertResourceCalled('Execute', 'hive mkdir -p /tmp/HDP-artifacts/ ; cp /usr/share/java/mysql-connector-java.jar
/usr/lib/hive/lib//mysql-connector-java.jar',
+      creates = '/usr/lib/hive/lib//mysql-connector-java.jar',
+      path = ['/bin', '/usr/bin/'],
+      not_if = 'test -f /usr/lib/hive/lib//mysql-connector-java.jar',
+    )
+    self.assertResourceCalled('Directory', '/etc/hive/conf.server',
+      owner = 'hive',
+      group = 'hadoop',
+      recursive = True,
+    )
+    self.assertResourceCalled('XmlConfig', 'mapred-site.xml',
+      owner = 'hive',
+      group = 'hadoop',
+      mode = 0600,
+      conf_dir = '/etc/hive/conf.server',
+      configurations = self.getConfig()['configurations']['mapred-site'],
+    )
+    self.assertResourceCalled('XmlConfig', 'hive-site.xml',
+      owner = 'hive',
+      group = 'hadoop',
+      mode = 0600,
+      conf_dir = '/etc/hive/conf.server',
+      configurations = self.getConfig()['configurations']['hive-site'],
+    )
+    self.assertResourceCalled('Execute', "/bin/sh -c 'cd /usr/lib/ambari-agent/ &&
curl -kf --retry 5 http://c6401.ambari.apache.org:8080/resources/DBConnectionVerification.jar
-o DBConnectionVerification.jar'",
+      not_if = '[ -f DBConnectionVerification.jar]',
+    )
+    self.assertResourceCalled('File', '/tmp/start_metastore_script',
+      content = StaticFile('startMetastore.sh'),
+      mode = 0755,
+    )
+    self.assertResourceCalled('Execute', "/usr/lib/hive/bin/schematool -initSchema -dbType
mysql -userName hive -passWord asd",
+      not_if = '/usr/lib/hive/bin/schematool -info -dbType mysql -userName hive -passWord
asd',
+    )
+    self.assertResourceCalled('Directory', '/var/run/hive',
+      owner = 'hive',
+      group = 'hadoop',
+      mode = 0755,
+      recursive = True,
+    )
+    self.assertResourceCalled('Directory', '/var/log/hive',
+      owner = 'hive',
+      group = 'hadoop',
+      mode = 0755,
+      recursive = True,
+    )
+    self.assertResourceCalled('Directory', '/var/lib/hive',
+      owner = 'hive',
+      group = 'hadoop',
+      mode = 0755,
+      recursive = True,
+    )
+    self.assertResourceCalled('File', '/etc/hive/conf.server/hive-env.sh',
+      content = Template('hive-env.sh.j2', conf_dir="/etc/hive/conf.server"),
+      owner = 'hive',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/hive/conf/hive-default.xml.template',
+      owner = 'hive',
+      group = 'hadoop',
+    )
+    self.assertResourceCalled('File', '/etc/hive/conf/hive-env.sh.template',
+      owner = 'hive',
+      group = 'hadoop',
+    )
+
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/aec2d188/ambari-server/src/test/python/stacks/2.1/configs/default.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/configs/default.json b/ambari-server/src/test/python/stacks/2.1/configs/default.json
index 26d1a82..f1acd54 100644
--- a/ambari-server/src/test/python/stacks/2.1/configs/default.json
+++ b/ambari-server/src/test/python/stacks/2.1/configs/default.json
@@ -7,7 +7,7 @@
         "ambari_db_rca_password": "mapred", 
         "ambari_db_rca_url": "jdbc:postgresql://c6401.ambari.apache.org/ambarirca", 
         "jce_name": "UnlimitedJCEPolicyJDK7.zip", 
-        "stack_version": "2.0.8", 
+        "stack_version": "2.1",
         "stack_name": "HDP", 
         "ambari_db_rca_driver": "org.postgresql.Driver", 
         "jdk_name": "jdk-7u45-linux-x64.tar.gz", 

http://git-wip-us.apache.org/repos/asf/ambari/blob/aec2d188/ambari-server/src/test/python/stacks/2.1/configs/secured.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/configs/secured.json b/ambari-server/src/test/python/stacks/2.1/configs/secured.json
index 3dd6775..245e5dd 100644
--- a/ambari-server/src/test/python/stacks/2.1/configs/secured.json
+++ b/ambari-server/src/test/python/stacks/2.1/configs/secured.json
@@ -10,7 +10,7 @@
         "oracle_jdbc_url": "http://c6401.ambari.apache.org:8080/resources//ojdbc6.jar", 
         "repo_info": "[{\"baseUrl\":\"http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.0\",\"osType\":\"centos6\",\"repoId\":\"HDP-2.0.8\",\"repoName\":\"HDP\",\"defaultBaseUrl\":\"http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.0\"}]",

         "package_list": "[{\"type\":\"rpm\",\"name\":\"hadoop-yarn\"},{\"type\":\"rpm\",\"name\":\"hadoop-yarn-nodemanager\"},{\"type\":\"rpm\",\"name\":\"hadoop-mapreduce\"},{\"type\":\"rpm\",\"name\":\"hadoop-yarn-proxyserver\"},{\"type\":\"rpm\",\"name\":\"hadoop-yarn-resourcemanager\"}]",

-        "stack_version": "2.0.8", 
+        "stack_version": "2.1",
         "stack_name": "HDP", 
         "db_name": "ambari", 
         "ambari_db_rca_driver": "org.postgresql.Driver", 


Mime
View raw message