1

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?

xingbin
  • 27,410
  • 9
  • 53
  • 103

1 Answers1

3

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.

catpaws
  • 2,263
  • 16
  • 18
  • thanks, I have multiple `hive.metastore.uris`, which should I use? – xingbin Dec 13 '18 at 01:34
  • For upgrades, I've heard you should use the first metastore in the list, but don't think it matters in your case. I think multiple metastores are just replications for failover (see https://docs.hortonworks.com/HDPDocuments/HDP3/HDP-3.1.0/fault-tolerance/content/use_cases_and_failover_scenarios.html). Good luck. – catpaws Dec 13 '18 at 17:03
  • see also https://cwiki.apache.org/confluence/display/Hive/AdminManual+Metastore+3.0+Administration – catpaws Dec 13 '18 at 17:16
  • what would be host in this case. host="hive.metastore.uris=//myuri.com".? – vikrant rana Jul 10 '19 at 02:32
  • The Hive metastore host's fully qualified domain name in this example is myuri.com. I think the python conn = hive.Connection(host=... accepts an IP address or the FQDN of the Hive metastore host. – catpaws Jul 10 '19 at 17:27