Support Questions
Find answers, ask questions, and share your expertise

Help connecting Hive using CentOS7 ODBC Driver on RHEL 7.3

New Contributor

I have a redhat server 7.3 hosting HDP. I wish to connect python to Hive using an ODBC Driver. The driver I am using is CentOS7 provided by Hortonworks which I learnt from another thread is compatible with RHEL. I followed the setup instructions and tried connecting using a python script tested and working on another box. I keep getting the error, "TTransportException: Could not connect to 10.128.162.151:10000" I beleive that the connection is timing out. But I'm really stumped so any help is appreciated!

The python script used:

import pyhs2
with pyhs2.connect(host='10.128.162.151',
               port=10000,
               authMechanism="PLAIN",
               user='mary',
               password='mary',
               database='default') as conn:
    with conn.cursor() as cur:
        #Show databases
        print cur.getDatabases()

Traceback of the error message:

---------------------------------------------------------------------------
TTransportException                       Traceback (most recent call last)
<ipython-input-5-d6450096c810> in <module>()
      6                user='mary',
      7                password='mary',
----> 8                database='default') as conn:
      9     with conn.cursor() as cur:
     10         #Show databases

//anaconda/lib/python2.7/site-packages/pyhs2/__init__.pyc in connect(*args, **kwargs)
      5     """
      6     from .connections import Connection
----> 7     return Connection(*args, **kwargs)

//anaconda/lib/python2.7/site-packages/pyhs2/connections.pyc in __init__(self, host, port, authMechanism, user, password, database, configuration, timeout)
     44 
     45         self.client = TCLIService.Client(TBinaryProtocol(transport))
---> 46         transport.open()
     47         res = self.client.OpenSession(TOpenSessionReq(username=user, password=password, configuration=configuration))
     48         self.session = res.sessionHandle

//anaconda/lib/python2.7/site-packages/pyhs2/cloudera/thrift_sasl.pyc in open(self)
     53   def open(self):
     54     if not self._trans.isOpen():
---> 55       self._trans.open()
     56 
     57     if self.sasl is not None:

//anaconda/lib/python2.7/site-packages/thrift/transport/TSocket.pyc in open(self)
     99         message = 'Could not connect to %s:%d' % (self.host, self.port)
    100       raise TTransportException(type=TTransportException.NOT_OPEN,
--> 101                                 message=message)
    102 
    103   def read(self, sz):

TTransportException: Could not connect to 10.128.162.151:10000



2 REPLIES 2

Re: Help connecting Hive using CentOS7 ODBC Driver on RHEL 7.3

@Kate Shaw

Can you check that you can connect to 10.128.162.151:10000 using utilities like nc and telnet?

Re: Help connecting Hive using CentOS7 ODBC Driver on RHEL 7.3

Super Guru

@Kate Shaw

This looks more of a network than a driver issue. See if you can ping the hive server. If yes, then try opening telnet to port 10000.

From same machine where you are running python program, see if you can connect using a SQL tool or simple Microsoft Excel to connect to Hive to read data.