using python read/write HBase data

本文介绍如何在服务器端安装配置HBase Thrift服务,并在客户端进行Python测试。主要内容包括:确保Hadoop和HBase正常运行;安装并配置Thrift服务;使用Python进行Thrift客户端测试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. operations on Server side

1. ensure hadoop and hbase are working properly

2. install thrift:  apt-get install thrift

3. download hbase source code package: HERE(hbase 0.98 src) . Then extract package to /home/hadoop/hbase-0.98.12.1

4. cd /home/hadoop/hbase-0.98.12.1

thrift --gen py /hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift

5. cd /hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift/

 cp -r gen-py/ /usr/lib/python2.7/

6. RUN HBase Thrift:  hbase thrift -p 9090 start

 

B. operation on Client side

1. pip install thrift

 pip install hbase-thrift

 

C. TEST

1. on Server side, enter hbase shell

create'member','member_id','address','info'
create 'member1','member_id','address','info'
create 'member2','member_id','address','info'

2. on Client side,

from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from hbase import Hbase
from hbase.ttypes import *

transport =TSocket.TSocket('192.168.2.107', 9090)
transport =TTransport.TBufferedTransport(transport)
protocol =TBinaryProtocol.TBinaryProtocol(transport)
client = Hbase.Client(protocol)
transport.open()
print(client.getTableNames())

3. run 

 

 

REF:

http://www.cnblogs.com/hitandrew/archive/2013/01/21/2870419.html

http://edu.dataguru.cn/thread-354800-1-1.html

http://blog.youkuaiyun.com/a1368783069/article/details/51019835

转载于:https://www.cnblogs.com/pdev/p/6295864.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值