Chinaunix首页 | 论坛 | 博客
  • 博客访问: 215819
  • 博文数量: 39
  • 博客积分: 945
  • 博客等级: 准尉
  • 技术积分: 532
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-04 17:25
文章分类

全部博文(39)

文章存档

2012年(39)

我的朋友

分类: 服务器与存储

2012-05-11 11:19:34

php链接hive执行sql语句需要重新安装thrift

编译好的thrift下载地址


安装后启动hive thrift

点击(此处)折叠或打开

  1. hadoop@hadoop-master:~$ hive --service hiveserver
  2. hadoop@hadoop-master:~$netstat -nat | grep 10000
  3. tcp6 0 0 :::10000 :::* LISTEN   #默认端口
php测试hive代码

点击(此处)折叠或打开

  1. #!/usr/bin/php
  2. <?
  3. $GLOBALS['THRIFT_ROOT'] = '/home/hadoop/Thrift/';
  4. require_once $GLOBALS['THRIFT_ROOT'] . 'packages/hive_service/ThriftHive.php';
  5. require_once $GLOBALS['THRIFT_ROOT'] . 'transport/TSocket.php';
  6. require_once $GLOBALS['THRIFT_ROOT'] . 'protocol/TBinaryProtocol.php';

  7. $transport = new TSocket('master', 10000);
  8. $protocol = new TBinaryProtocol($transport);
  9. $client = new ThriftHiveClient($protocol);
  10. $transport->open();

  11. $client->execute('add jar /home/hadoop/hadoop-1.0.1/contrib/hive/lib/hive-contrib-0.8.1.jar');
  12. $client->execute("insert overwrite local directory '/home/hadoop/hive-out' select sum(price) from erp_crstorage");
  13. $transport->close();

  14. ?>



阅读(5317) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~