Search code examples
pythonhivepyhive

Where to find hive url, username and password?


In the command line, I can enter hive to get hive shell like:

hive>

then execute some queries.

Now I need write a python script with PyHive to execute some tasks, like:

conn = hive.Connection(host="10.111.22.11", port=10000, username="user1")

Where can I find the host, port, username, password used by shell?


Solution

  • This is just guesswork, but might help if you're willing to experiment. To find the url of HiveServer, from the hive> prompt, try set hive.metastore.uris; Output is something like this:

    +----------------------------------------------------+
    |                        set                         |
    +----------------------------------------------------+
    | hive.metastore.uris=thrift://myuri.com:9083 |
    +----------------------------------------------------+
    1 row selected (0.26 seconds)
    

    Ignore thrift: and 9083. 10000 is the default port for Hive. Set up a Hive user with a password. In Hive 3, user permissions can be based on HDFS access control. This doc might help.