hive/hbase+thrift安装教程

1安装 thrift

安裝需要使用到的软件:

我用的是thrift-0.6.0  

yum  install libboost-dev libevent-dev python-dev automake pkg-config libtool flex bison g++
./configure 
make && make install

 

 

2,配合 hbase

[root@localhost thrift-0.6.0]# cp -r lib/php/src/ /data/html/

[root@localhost thrift-0.6.0]# cd /data/html/src

[root@localhost src]# thrift --gen php /usr/local/hbase/src/

[root@localhost src]# thrift --gen php /usr/local/hbase/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift 
[root@localhost src]# mv gen-php/ packages

[root@localhost src]# cp /usr/local/hbase/src/examples/thrift/DemoClient.php /data/html/

[root@localhost html]# vim DemoClient.php

改路径:$GLOBALS['THRIFT_ROOT'] = '/data/html/src';

[root@localhost html]# /usr/local/hbase/bin/hbase-daemon.sh start thrift

这里要将Hbase.php        Hbase_types.php  放在 Hbase目录下

当然也可以改 DemoClient.php ,将路径对应一下,总之找到就行!!!

[root@localhost packages]# mkdir Hbase

[root@localhost packages]# cp  /data/html/src/packages/gen-php/Hbase/*  Hbase

 

 

安装教程: http://blog.kfchph.com/20-hbase-thrift-050-php5/

API: http://trac.nchc.org.tw/cloud/wiki/waue/2010/HbaseThrift  

 

3,配合 hive

/usr/local /hive /bin/hive  --service hiveserver >/dev/null 2>/dev/null &

查看 10000端口是否开启,如下所示

[root@localhost html]# netstat -an|grep 10000

 

安装教程: http://blog.csdn.net/jiedushi/article/details/6579285

附代码:

<?php

$GLOBALS['THRIFT_ROOT'] = '/data/html/hivephp/Thrift/';

// load the required files for connecting to Hive  

require_once $GLOBALS['THRIFT_ROOT'] . 'packages/hive_service/ThriftHive.php';

require_once $GLOBALS['THRIFT_ROOT'] . 'transport/TSocket.php';

require_once $GLOBALS['THRIFT_ROOT'] . 'protocol/TBinaryProtocol.php';

// Set up the transport/protocol/client  

$transport = new TSocket('localhost', 10000);

$protocol = new TBinaryProtocol($transport);

$client = new ThriftHiveClient($protocol);

$transport->open();

 

// run queries, metadata calls etc  

 

#$client->execute('add jar /usr/local/hadoop/hive/lib/hive-contrib-0.7.0-cdh3u0.jar');  

$client->execute('add jar /usr/local/hive/lib/hive-contrib-0.8.0.jar');

$client->execute('select count(1) from hdfs_orders');

var_dump($client->fetchAll());

$transport->close();

 

?> 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值