Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Install Apache Thrift Gateway to CentOS 2

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Generate thrift module for python

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

(the path is from the source code file of hbase)

This generates a gen-py path on the current path

2. Installation

Cd gen-py/hbase

Python * .py build

Python * .py install

Cd..

Cp-rhbase/usr/lib/python2.6/site-packages/

3. Testing

Python

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.137.101)

Transport = TTransport.TBufferedTransport (transport)

Protocol = TBinaryProtocol.TBinaryProtocol (transport)

Client = Hbase.Client (protocol)

Transport.open ()

Scan = TScan ()

TableName = 'ttable'

Id = client.scannerOpenWithScan (tableName, scan, None)

Result1 = client.scannerGetList (id, 10)

Print result1

Don't forget to start the thrift daemon

. / bin/hbase-daemon.sh start thrift

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report