$ wget apache.strygunov.com//thrift/0.6.1/thrift-0.6.1.tar.gz
$ tar xfz thrift-0.6.1.tar.gz
$ cd thrift-0.6.1/
$ ./configure
$ make
$ make install
$ cd ..
Building C++ Library ......... : no
Building C (GLib) Library .... : no
Building Java Library ........ : no
Building C# Library .......... : no
Building Python Library ...... : yes
Building Ruby Library ........ : no
Building Haskell Library ..... : no
Building Perl Library ........ : no
Building PHP Library ......... : yes
Building Erlang Library ...... : yes
$ wget apache.infocom.ua//hbase/hbase-0.90.3/hbase-0.90.3.tar.gz
$ tar xfz hbase-0.90.3.tar.gz
$ vim hbase-0.90.3/conf/hbase-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///path/to/folder/for/hbase</value>
</property>
</configuration>
$ ./hbase-0.90.3/bin/start-hbase.sh
$ thrift --gen php hbase-0.90.3/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
$ ./hbase-0.90.3/bin/hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version: 0.90.0, r1001068, Fri Sep 24 13:55:42 PDT 2010
hbase(main):001:0> create 'blogposts', 'post', 'image'
0 row(s) in 1.2200 seconds
hbase(main):002:0> put 'blogposts', 'post1', 'post:title', 'Hello World'
hbase(main):003:0> put 'blogposts', 'post1', 'post:author', 'The Author'
hbase(main):004:0> put 'blogposts', 'post1', 'post:body', 'This is a blog post'
hbase(main):005:0> put 'blogposts', 'post1', 'image:header', 'image1.jpg'
hbase(main):006:0> put 'blogposts', 'post1', 'image:bodyimage', 'image2.jpg'
hbase(main):007:0> get 'blogposts', 'post1'
COLUMN CELL
image:bodyimage timestamp=1229953133260, value=image2.jpg
image:header timestamp=1229953110419, value=image1.jpg
post:author timestamp=1229953071910, value=The Author
post:body timestamp=1229953072029, value=This is a blog post
post:title timestamp=1229953071791, value=Hello World
hbase(main):008:0> exit
create 'blogposts', 'post', 'image'
created a table blogposts with two families of columns post and image. Next, put 'blogposts', 'post1', 'post:title', '...'
we created one line with a set of values, and at the end we checked the availability of data in the table and left the shell.$ ./hbase-0.90.3/bin/hbase thrift start
<?php // Thrift $GLOBALS['THRIFT_ROOT'] = '/usr/lib/php'; require_once( $GLOBALS['THRIFT_ROOT'].'/Thrift.php' ); require_once( $GLOBALS['THRIFT_ROOT'].'/transport/TSocket.php' ); require_once( $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php' ); require_once( $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php' ); // HBase require_once( $GLOBALS['THRIFT_ROOT'].'/packages/Hbase/Hbase.php' ); // thrift $socket = new TSocket( 'localhost', 9090 ); $socket->setSendTimeout( 10000 ); $socket->setRecvTimeout( 20000 ); $transport = new TBufferedTransport( $socket ); $protocol = new TBinaryProtocol( $transport ); $client = new HbaseClient( $protocol ); $transport->open(); // HBase print_r($client->getTableNames()); print_r($client->getColumnDescriptors( 'blogposts' )); print_r($client->getRow( 'blogposts', 'post1' )); $transport->close(); ?>
Source: https://habr.com/ru/post/123560/
All Articles