hbase报错TTransportException(type=4,message=’TSocket read 0 bytes’)

hbase报错TTransportException(type=4,message=’TSocket read 0 bytes’)

(1)报错信息:

thrift.transport.TTransport.TTransportException: TSocket read 0 bytes

(2)产生原因:

是因为thrift 的server端和client端的协议不匹配造成的。
Python要使用TCompactProtocol,而不能使用TBinaryProtocol。
TBinaryProtocol:缺省简单的二进制序列化协议。
TCompactProtocol:高效的二进制序列化协议。

(3)解决办法:

1.在服务端修改hbase-site.xml,增加TFramedTransport和TCompactProtocol功能,即:

   
      hbase.regionserver.thrift.framed</name>
     true</value>
   </property>
   
      hbase.regionserver.thrift.compact</name>
      true</value>
   </property>

2.然后重启thrift:$HBASE_HOME/bin/hbase-daemon.sh restart thrift

3.在客户端建立连接时增加protocol,transport参数:

conn = happybase.Connection(host="10.255.111.92",port=9090)
#修改为:
conn = happybase.Connection(host="10.255.111.92",port=9090,protocol='compact',transport='framed')

你可能感兴趣的:(大数据,hbase)