zoukankan      html  css  js  c++  java
  • using python read/write HBase data

    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.csdn.net/a1368783069/article/details/51019835

  • 相关阅读:
    正则表达式基础
    js正则:零宽断言
    IE读取并显示本地图像文件的方法
    转:FileReader详解与实例---读取并显示图像文件
    mysql基础(mysql数据库导入到处) 很基础很实用
    如何禁止页面滚动
    转:字符编码到底是怎样的 有空看
    自己写的一个简单的Tab类
    mysql学习总结
    mysqld守护进程
  • 原文地址:https://www.cnblogs.com/pdev/p/6295864.html
Copyright © 2011-2022 走看看