php thrift for HBase

1. Download thrift

wget -O thrift.tgz “http://gitweb.thrift-rpc.org/?p=thrift.git;a=snapshot;h=HEAD;sf=tgz”
tar -xzf thrift.tgz
cd thrift2. Install thrift

./boostrap.sh
./configure
make
sudo make install3. Make php API for HBase

You have to instll HBase in advance.

cp -r /usr/local/hbase/src/java/org/apache/hadoop/hbase/thrift ~/thrift_src
cd ~/thrift_src

thrift -php Hbase.thrift

cp -r ~/thrift_src/lib/php/src /opt/lampp/htdocs/thrift
mkdir /opt/lampp/htdocs/thrift/packages
cp -r ~/thrift_src/gen_php /opt/lampp/htdocs/thrift/packages/Hbase
4. Start HBase thrift server

/usr/local/hbase/bin/hbase thrift start5. Test to access HBase

cp /usr/local/hbase/src/examples/thrift/DemoClient.php /opt/lampp/htdocs/DemoClient.phpYou have to change the THRIFT_ROOT variable in DemoClient.php to the match your thrift root.

eg:

$GLOBALS['THRIFT_ROOT'] = ‘/root/thrift-0.6.1/lib/php/src’;php DemoClient.php

6. Attention

Lf you use clouder CDH to install thrift. You can just:

yum install hadoop-hbase-thrift -yBut you still have to do the above thing in order to get the thrift php API for HBase.

你可能感兴趣的:(php thrift for HBase)