HBase: Thrift写数据报错——socket.error: [Errno 32] Broken pip
生活随笔
收集整理的這篇文章主要介紹了
HBase: Thrift写数据报错——socket.error: [Errno 32] Broken pip
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
博主用的是python來讀寫hbase
需要安裝 pip install thrift 和 pip install hbase-thrift
hbase客戶端創(chuàng)建:
from thrift import Thrift from thrift.transport import TSocket, TTransport from thrift.protocol import TBinaryProtocol from hbase import Hbase#server端地址和端口,web是HMaster也就是thriftServer主機(jī)名,9090是thriftServer默認(rèn)端口 transport = TSocket.TSocket('hadoop4’, 9090) #可以設(shè)置超時(shí) transport.setTimeout(5000) #設(shè)置傳輸方式(TFramedTransport或TBufferedTransport) trans = TTransport.TBufferedTransport(transport) #設(shè)置傳輸協(xié)議 protocol = TBinaryProtocol.TBinaryProtocol(trans) #確定客戶端 client = Hbase.Client(protocol) #打開連接 transport.open()如果,在讀寫hbase過程中報(bào)錯(cuò):socket.error: [Errno 32] Broken pip,原因大致是因?yàn)?#xff0c;數(shù)據(jù)還沒有讀寫進(jìn)去,socket已經(jīng)關(guān)閉了,解決辦法就是在創(chuàng)建客戶端設(shè)置超時(shí)時(shí)間。
#可以設(shè)置超時(shí) transport.setTimeout(5000)或者直接在配置文件conf/hbase-site.xml中添加如下配置(每個(gè)節(jié)點(diǎn)都添加):
?
<property><name>hbase.thrift.server.socket.read.timeout</name><value>6000000</value><description>eg:milisecond</description> </property>即設(shè)置超時(shí)時(shí)間為60s。
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的HBase: Thrift写数据报错——socket.error: [Errno 32] Broken pip的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 各个企业创始人记录--【持续更新中!!!
- 下一篇: 使用PDB调试Python程序的完整实践