我使用默认的Zookeeper创建了HBase单节点集群。我的hbase-site.xml包含条目:
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:50077/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/usr/local/hbase/zookeeper</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
我在Hbase上创建了一个表'emp',可以通过hbase shell对其进行访问:
hbase(main):001:0> list
TABLE
emp
sample_data:rfic
2 row(s) in 0.1530 seconds
=> ["emp", "sample_data:rfic"]
hbase(main):005:0> scan 'emp'
ROW COLUMN+CELL
1 column=personal data:city, timestamp=1549970066226, value=hyder
abad
1 column=personal data:name, timestamp=1549970049857, value=raju
1 column=professional data:designation, timestamp=1549970125784,
value=manager
1 column=professional data:salary, timestamp=1549970141915, value
=50000
2 column=personal data:name, timestamp=1550137295051, value=Bhupe
sh
2 row(s) in 0.0940 seconds
现在,当我尝试使用python脚本访问此表时:
import happybase
conn = happybase.Connection(host='ec2-<my host ip>.compute-1.amazonaws.com', port=2181, autoconnect=True)
print("Connection established")
tbl_nm = 'emp'
table = conn.table(tbl_nm)
print("Checking table object",table)
它正在执行脚本[能够连接到HBase并能够获取emp对象],但是在读取表数据时抛出一些错误:
Connection established
('Checking table object', <happybase.table.Table name='emp'>)
Traceback (most recent call last):
File "HBaseConnectionScript.py", line 19, in <module>
for key, data in table.scan(b'1'):
File "/home/ubuntu/.local/lib/python2.7/site-packages/happybase/table.py", line 402, in scan
self.name, scan, {})
File "/home/ubuntu/.local/lib/python2.7/site-packages/thriftpy/thrift.py", line 198, in _req
return self._recv(_api)
File "/home/ubuntu/.local/lib/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 "/home/ubuntu/.local/lib/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)
我无法确定问题出在哪里?
我什至尝试运行hbasethrift服务器并执行脚本,但仍然面临相同的问题。
HBase专家的任何快速帮助将不胜感激。
关于, 布普什