浏览代码

AMBARI-18386. Handle Ranger hive repo config jdbc url change for stack 2.5 (mugdha)

Mugdha Varadkar 8 年之前
父节点
当前提交
357ba0a9a1

+ 2 - 1
ambari-common/src/main/python/resource_management/libraries/functions/constants.py

@@ -99,4 +99,5 @@ class StackFeature:
   RANGER_ADMIN_PASSWD_CHANGE = "ranger_admin_password_change"
   RANGER_ADMIN_PASSWD_CHANGE = "ranger_admin_password_change"
   STORM_METRICS_APACHE_CLASSES = "storm_metrics_apache_classes"
   STORM_METRICS_APACHE_CLASSES = "storm_metrics_apache_classes"
   SPARK_JAVA_OPTS_SUPPORT = "spark_java_opts_support"
   SPARK_JAVA_OPTS_SUPPORT = "spark_java_opts_support"
-  ATLAS_HBASE_SETUP="atlas_hbase_setup"
+  ATLAS_HBASE_SETUP = "atlas_hbase_setup"
+  RANGER_HIVE_PLUGIN_JDBC_URL = "ranger_hive_plugin_jdbc_url"

+ 9 - 1
ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_linux.py

@@ -88,6 +88,7 @@ version_for_stack_feature_checks = get_stack_feature_version(config)
 upgrade_direction = default("/commandParams/upgrade_direction", None)
 upgrade_direction = default("/commandParams/upgrade_direction", None)
 stack_supports_ranger_kerberos = check_stack_feature(StackFeature.RANGER_KERBEROS_SUPPORT, version_for_stack_feature_checks)
 stack_supports_ranger_kerberos = check_stack_feature(StackFeature.RANGER_KERBEROS_SUPPORT, version_for_stack_feature_checks)
 stack_supports_ranger_audit_db = check_stack_feature(StackFeature.RANGER_AUDIT_DB_SUPPORT, version_for_stack_feature_checks)
 stack_supports_ranger_audit_db = check_stack_feature(StackFeature.RANGER_AUDIT_DB_SUPPORT, version_for_stack_feature_checks)
+stack_supports_ranger_hive_jdbc_url_change = check_stack_feature(StackFeature.RANGER_HIVE_PLUGIN_JDBC_URL, version_for_stack_feature_checks)
 
 
 # component ROLE directory (like hive-metastore or hive-server2-hive2)
 # component ROLE directory (like hive-metastore or hive-server2-hive2)
 component_directory = status_params.component_directory
 component_directory = status_params.component_directory
@@ -615,6 +616,9 @@ if has_hive_interactive:
     hive_llap_principal = (config['configurations']['hive-interactive-site']['hive.llap.zk.sm.principal']).replace('_HOST',hostname.lower())
     hive_llap_principal = (config['configurations']['hive-interactive-site']['hive.llap.zk.sm.principal']).replace('_HOST',hostname.lower())
   pass
   pass
 
 
+hive_server2_zookeeper_namespace = config['configurations']['hive-site']['hive.server2.zookeeper.namespace']
+hive_zookeeper_quorum = config['configurations']['hive-site']['hive.zookeeper.quorum']
+
 # ranger host
 # ranger host
 ranger_admin_hosts = default("/clusterHostInfo/ranger_admin_hosts", [])
 ranger_admin_hosts = default("/clusterHostInfo/ranger_admin_hosts", [])
 has_ranger_admin = not len(ranger_admin_hosts) == 0
 has_ranger_admin = not len(ranger_admin_hosts) == 0
@@ -686,11 +690,15 @@ if has_ranger_admin:
   ranger_previous_jdbc_jar = format("{hive_lib}/{ranger_previous_jdbc_jar_name}") if stack_supports_ranger_audit_db else None
   ranger_previous_jdbc_jar = format("{hive_lib}/{ranger_previous_jdbc_jar_name}") if stack_supports_ranger_audit_db else None
   sql_connector_jar = ''
   sql_connector_jar = ''
 
 
+  ranger_hive_url = format("{hive_url}/default;principal={hive_principal}") if security_enabled else hive_url
+  if stack_supports_ranger_hive_jdbc_url_change:
+    ranger_hive_url = format("jdbc:hive2://{hive_zookeeper_quorum}/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace={hive_server2_zookeeper_namespace}")
+
   hive_ranger_plugin_config = {
   hive_ranger_plugin_config = {
     'username': repo_config_username,
     'username': repo_config_username,
     'password': repo_config_password,
     'password': repo_config_password,
     'jdbc.driverClassName': jdbc_driver_class_name,
     'jdbc.driverClassName': jdbc_driver_class_name,
-    'jdbc.url': format("{hive_url}/default;principal={hive_principal}") if security_enabled else hive_url,
+    'jdbc.url': ranger_hive_url,
     'commonNameForCertificate': common_name_for_certificate
     'commonNameForCertificate': common_name_for_certificate
   }
   }
 
 

+ 5 - 0
ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_features.json

@@ -303,6 +303,11 @@
       "name": "atlas_hbase_setup",
       "name": "atlas_hbase_setup",
       "description": "Use script to create Atlas tables in Hbase and set permissions for Atlas user.",
       "description": "Use script to create Atlas tables in Hbase and set permissions for Atlas user.",
       "min_version": "2.5.0.0"
       "min_version": "2.5.0.0"
+    },
+    {
+      "name": "ranger_hive_plugin_jdbc_url",
+      "description": "Handle Ranger hive repo config jdbc url change for stack 2.5 (AMBARI-18386)",
+      "min_version": "2.5.0.0"
     }
     }
   ]
   ]
 }
 }