Python connect to Hive use pyhs2 and Kerberos authentication

12,739

Solution 1

I think it will be something like this:

pyhs2.connect(host='biclient2.server.163.org',
                   port=10000,
                   authMechanism="KERBEROS",
                   password="something",
                   user='[email protected]')

I'm also doing the same, I still not succeed, but at least having a meaningful errorcode: (Server hive/[email protected] not found in Kerberos database)

Solution 2

This connection string will work as long as the user running the script has a valid kerberos ticket:

import pyhs2

with pyhs2.connect(host='biclient2.server.163.org',
                    port=10000,
                    authMechanism="KERBEROS") as conn:

    with conn.cursor() as cur:
            print cur.getDatabases()

Username, password and any other configuration parameters are not passed through the KDC.

Share:
12,739
leeyiw
Author by

leeyiw

Updated on June 22, 2022

Comments

  • leeyiw
    leeyiw almost 2 years

    I'm connecting Hive use pyhs2. But the Hive server required Kerberos authentication. Anyone knows how to convert the JDBC string to pyhs2 parameter? Like: jdbc:hive2://biclient2.server.163.org:10000/default;principal=hive/[email protected]?mapred.job.queue.name=default