ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: AMBARI-5091 Ambari should install Hive metastore DB schema using SchemaTool (dsen)
Date Wed, 26 Mar 2014 13:56:53 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 6dcbb8733 -> aa6769c06


AMBARI-5091 Ambari should install Hive metastore DB schema using SchemaTool (dsen)


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

Branch: refs/heads/trunk
Commit: aa6769c06b60bc0b231cb08e099d86ed8579a6c3
Parents: 6dcbb87
Author: Dmitry Sen <dsen@hortonworks.com>
Authored: Wed Mar 26 15:56:43 2014 +0200
Committer: Dmitry Sen <dsen@hortonworks.com>
Committed: Wed Mar 26 15:56:43 2014 +0200

----------------------------------------------------------------------
 .../HIVE/package/scripts/hive_metastore.py        | 18 ++++++++++++++++++
 .../2.0.6/services/HIVE/package/scripts/params.py | 13 ++++++++++++-
 .../stacks/HDP/2.1/role_command_order.json        |  1 +
 3 files changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/aa6769c0/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 c741174..cd250ce 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
@@ -23,12 +23,14 @@ from resource_management import *
 
 from hive import hive
 from hive_service import hive_service
+from mysql_service import mysql_service
 
 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
@@ -59,5 +61,21 @@ 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/aa6769c0/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 2b4a0d9..38aecd6 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
@@ -29,6 +29,7 @@ hive_server_conf_dir = "/etc/hive/conf.server"
 hive_jdbc_connection_url = config['configurations']['hive-site']['javax.jdo.option.ConnectionURL']
 
 hive_metastore_user_passwd = config['configurations']['hive-site']['javax.jdo.option.ConnectionPassword']
+hive_metastore_db_type = config['configurations']['global']['hive_database_type']
 
 #users
 hive_user = config['configurations']['global']['hive_user']
@@ -44,8 +45,11 @@ 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'
+hive_bin = '/usr/lib/hive/bin'
 hive_server_host = config['clusterHostInfo']['hive_server_host'][0]
 hive_url = format("jdbc:hive2://{hive_server_host}:10000")
 
@@ -106,9 +110,16 @@ mysql_host = config['clusterHostInfo']['hive_mysql_host']
 
 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
+else:
+  init_metastore_schema = False
+
 ########## HCAT
 
-if str(config['hostLevelParams']['stack_version']).startswith('2.0'):
+if str(hdp_stack_version).startswith('2.0'):
   hcat_conf_dir = '/etc/hcatalog/conf'
   hcat_lib = '/usr/lib/hcatalog/share/hcatalog'
 # for newer versions

http://git-wip-us.apache.org/repos/asf/ambari/blob/aa6769c0/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 ded1d23..f6b499a 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,6 +5,7 @@
     "_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"],


Mime
View raw message