Connecting to Hive and Impala services on CDP Private Cloud Base

The provided examples use Kerberos for authentication when connecting to Cloudera Data Warehouse (CDW) Hive, and Impala, which requires that the Keytab is set and there are proper permissions to access CDW.

For details on the configuration values, referred to in the code snippets, follow the steps:

  1. Go to the home page of the Cloudera Manager.
  2. Find the base cluster Hive or Impala service you are interested in.
  3. Click the horizontal dots icon next to the service.
  4. Choose Configuration from among the available actions.

Connecting to Impala service on base clusters

Python

from impala.dbapi import connect
import os



#host=ccycloud-3.cml-pvc-ocp.root.comops.site (Impala Daemon from config)
#port=28000 (hs2_http_port from config)
#auth_mechanism="GSSAPI" (should always be GSSAPI)
#use_http_transport=True (should always be true)
#http_path="cliservice" (should always be cliservice)
#use_ssl=True (value should be found in the client_services_ssl_enabled property on impala base cluster service config)
# kerberos_service_name=impala (kerberos_princ_name from config)


#example

conn = connect(
            host="ccycloud-3.cml-pvc-ocp.root.comops.site",
            port=28000,
            auth_mechanism="GSSAPI",
            use_http_transport=True,
            http_path="cliservice",
            use_ssl=True,
            kerberos_service_name = "impala",
        )

Connecting to Hive service on base clusters

Python

from impala.dbapi import connect
import os


#host=ccycloud-1.cml-pvc-ocp.root.comops.site (HS2_SERVER Load Balancer - hiveserver2_load_balancer from config)
#port=10015 (HS2_SERVER port - hiveserver2_load_balancer from config)
#auth_mechanism=GSSAPI (leave this as is)
#use_http_transport=True (leave this as true)
#http_path="cliservice" (leave this as is)
#use_ssl=True (if hive.server2.use.SSL from config is checked, this is true, otherwise false)
#kerberos_service_name=hive (kerberos_princ_name from config)

conn = connect(
            host="ccycloud-1.cml-pvc-ocp.root.comops.site",
            port=10015,
            auth_mechanism="GSSAPI",
            use_http_transport=True,
            http_path="cliservice",
            use_ssl=True,
            kerberos_service_name = "hive",
        )