且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将Hbase与PHP集成

更新时间:2022-10-18 12:27:06

You cannot access HBase directly from PHP, but you can workaround it by taking a closer look at the Thrift interface.

There's multiple parts to setting it up:

First:

Thrift is a system for inter-language communication and is not specific to HBase. The interface specification that HBase has looks like this.

To use the Thrift interface, you need to compile the specification for the language you are using, in this case, PHP. To do this, you need the Thrift compiler (you can get it at thrift.apache.org).

Complile it:

thrift --gen php [hbase-root]/src/java/org/apache/hadoop/hbase/thrift/Hbase.thrift

This will generate a few PHP interface file. Drop that into your project along with the Thrift library files (that came with the compiler).

An example of using Thrift and PHP can be found here: http:// svn.apache.org/viewvc/thrift/trunk/tutorial/php/PhpServer.php?view=markup - the functions and methods you call will be the ones you see in the interface file.

Second:

You need to have a Thrift server running that will do the actual connection to HBase. Instructions are on the HBase site, but for the most part you should just need to:

[hbase-root]/bin/hbase thrift start

相关阅读

技术问答最新文章