简体   繁体   English

无法使用python的happybase软件包操作HBase-thriftpy.transport.TTransportException

[英]Unable to manipulate HBase using happybase package of python - thriftpy.transport.TTransportException

I try to connect to HBase and manipulate it through the happybase package of python Here is the code i used to connect to HBase: (the 'print' lines help me to locate where the program is stopped) 我尝试连接到HBase并通过python的happybase包对其进行操作这是我用于连接到HBase的代码:(“打印”行帮助我找到程序停止的位置)

import happybase

connection = happybase.Connection('197.12.8.2',2181)
print('0')
connection.open()
print('1')
table = connection.table('customerLocations')
print('2')

table.put('1', {'latitude': '11','longitude': '22'})
print('3')
row = table.row('0')
print('4')
print(row)
print('5')

But when executing the code,i got this an exception (thriftpy.transport.TTransportException) : 但是当执行代码时,我得到了一个异常(thriftpy.transport.TTransportException):

0
1
2
Traceback (most recent call last):
  File "test2.py", line 10, in <module>
    table.put('1', {'latitude': '11','longitude': '22'})
  File "/usr/lib/python2.7/site-packages/happybase/table.py", line 464, in put
    batch.put(row, data)
  File "/usr/lib/python2.7/site-packages/happybase/batch.py", line 137, in __exit__
    self.send()
  File "/usr/lib/python2.7/site-packages/happybase/batch.py", line 60, in send
    self._table.connection.client.mutateRows(self._table.name, bms, {})
  File "/usr/lib64/python2.7/site-packages/thriftpy/thrift.py", line 198, in _req
    return self._recv(_api)
  File "/usr/lib64/python2.7/site-packages/thriftpy/thrift.py", line 210, in _recv
    fname, mtype, rseqid = self._iprot.read_message_begin()
  File "thriftpy/protocol/cybin/cybin.pyx", line 429, in cybin.TCyBinaryProtocol.read_message_begin (thriftpy/protocol/cybin/cybin.c:6325)
  File "thriftpy/protocol/cybin/cybin.pyx", line 60, in cybin.read_i32 (thriftpy/protocol/cybin/cybin.c:1546)
  File "thriftpy/transport/buffered/cybuffered.pyx", line 65, in thriftpy.transport.buffered.cybuffered.TCyBufferedTransport.c_read (thriftpy/transport/buffered/cybuffered.c:1881)
  File "thriftpy/transport/buffered/cybuffered.pyx", line 69, in thriftpy.transport.buffered.cybuffered.TCyBufferedTransport.read_trans (thriftpy/transport/buffered/cybuffered.c:1948)
  File "thriftpy/transport/cybase.pyx", line 61, in thriftpy.transport.cybase.TCyBuffer.read_trans (thriftpy/transport/cybase.c:1472)
  File "/usr/lib64/python2.7/site-packages/thriftpy/transport/socket.py", line 125, in read
    message='TSocket read 0 bytes')
thriftpy.transport.TTransportException: TTransportException(message='TSocket read 0 bytes', type=4)

I don't know where the problem comes from .. 我不知道问题出在哪里..

here is the error connection = happybase.Connection('197.12.8.2',2181) 这是错误connection = happybase.Connection('197.12.8.2',2181)

you should connect the thrift server, and the server port is 9090 as default, not 2181, it's the port of zookeeper 您应该连接Thrift服务器,服务器端口默认为9090,而不是2181,它是zookeeper的端口

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM