PHP 连接 Hive 执行 SQL 查询_qq271757232的博客-CSDN博客


本站和网页 https://blog.csdn.net/qq271757232/article/details/10141617 的作者无关,不对其内容负责。快照谨为网络故障时之索引,不代表被搜索网站的即时页面。

PHP 连接 Hive 执行 SQL 查询_qq271757232的博客-CSDN博客
PHP 连接 Hive 执行 SQL 查询
qq271757232
于 2013-08-21 13:08:51 发布
3655
收藏
分类专栏:
Hadoop
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq271757232/article/details/10141617
版权
Hadoop
专栏收录该内容
21 篇文章
0 订阅
订阅专栏
Hive 中的 Thrift 脚本有两个版本的,一个有命名空间,一个没有命名空间,下面使用的是没有命名空间的版本。
无命名空间的PEAR
$ cd /opt/hive/lib/php/packages/
$ mv hive_service hive_service.bak
$ mv hive_service.bak/hive_service ./
$ cd /opt/hive/lib/php/packages/queryplan/queryplan
$ cp queryplan_types.php ../
$ cd /opt/hive/lib/php/packages/hive_metastore/hive_metastore
$ cp ThriftHiveMetastore.php ../
PHP
<?php
$GLOBALS['THRIFT_ROOT'] = '/opt/hive/lib/php';
require_once '/opt/hive/lib/php/autoload.php';
require_once '/opt/hive/lib/php/Thrift.php';
require_once '/opt/hive/lib/php/packages/fb303/FacebookService.php';
require_once '/opt/hive/lib/php/transport/TSocket.php';
require_once '/opt/hive/lib/php/protocol/TBinaryProtocol.php';
require_once '/opt/hive/lib/php/packages/hive_service/ThriftHive.php';
/**
* @author chenliujin <liujin.chen@qq.com>
* @since 2013-08-20
*/
class Hive
/**
* @author chenliujin <liujin.chen@qq.com>
* @since 2013-08-20
*/
public function query($sql)
try {
// Set up the transport/protocol/client
$transport = new TSocket('localhost', 10000);
$transport->setSendTimeout(10000);
$transport->setRecvTimeout(100000);
$protocol = new TBinaryProtocol($transport);
$client = new ThriftHiveClient($protocol);
$transport->open();
// run queries, metadata calls etc
$client->execute($sql);
$result = $client->fetchAll();
$data = array();
foreach ($result as $row) {
$row = explode("\t", $row);
$data[] = $row;
$transport->close();
return $data;
} catch (Exception $e) {
return array();
FAQ
PHP Fatal error:  Uncaught exception 'HiveServerException' with message 'Query returned non-zero code: 40000, cause: FAILED: ParseException line 5:23 cannot recognize input near 'ab' ';' '<EOF>' in expression specification' in /opt/hive/lib/php/packages/hive_service/ThriftHive.php:618
When you write a query in the shell, you should use ';' at the end of the SQL statement, However, you CANNOT use ';' at the end of the SQL statement when you're using Java.
TSocket: timed out reading 4 bytes from localhost:10000
加大超时时间
$transport->setSendTimeout(1000000);
$transport->setRecvTimeout(100000000);
qq271757232
关注
关注
点赞
收藏
打赏
评论
PHP 连接 Hive 执行 SQL 查询
$ cd /opt/hive/lib/php/packages/$ mv hive_service hive_service.bak$ mv hive_service.bak/hive_service ./$ cd /opt/hive/lib/php/packages/queryplan/queryplan$ cp queryplan_types.php ../$ cd /opt/h
复制链接
扫一扫
专栏目录
使用php连接hive
08-05
NULL
博文链接:https://serisboy.iteye.com/blog/2065966
php连接hive执行HQL查询
hzcyclone的专栏
07-02
1409
使用php连接hive的条件
1 需要安装thrift 安装步骤
# ./configure --without-ruby
# make && make install
如果没有安装libevent libevent-devel的应该先安装这两个依赖库yum -y install libevent libevent-devel
安装好后启动hive thr
评论 1
您还未登录,请先
登录
后发表或查看评论
php连接hive执行sql查询
东杰书屋
07-01
1万+
使用php连接hive的条件1 需要安装thrift 安装步骤# ./configure --without-ruby # make && make install如果没有安装libevent libevent-devel的应该先安装这两个依赖库yum -y install libevent libevent-devel安装好后启动hive thrift# ./h
Socket笔记之Read timed out深入分析
热门推荐
jannal专栏
09-10
9万+
ReadTimedOut深入分析
PlainSocketImpl.c
Java_java_net_PlainSocketImpl_socketSetOption
read()时
Java_java_net_SocketInputStream_socketRead0
solaris/native/java/net/bsd_close.c
总结
ReadTimedOut...
hbase报错TTransportException(type=4,message=’TSocket read 0 bytes’)解决方案
qq_41685616的博客
05-15
7283
hbase报错TTransportException(type=4,message=’TSocket read 0 bytes’)
(1)报错信息:
thrift.transport.TTransport.TTransportException: TSocket read 0 bytes
(2)产生原因:
是因为thrift 的server端和client端的协议不匹配造成的。
Python要使用TCompactProtocol,而不能使用TBinaryProtocol。
TBinaryProtocol:缺
Hive SQL运行状态监控(HiveSQLMonitor)
最新发布
u011250186的博客
02-23
925
引言
目前数据平台使用Hadoop构建,为了方便数据分析师的工作,使用Hive对Hadoop MapReduce任务进行封装,我们面对的不再是一个个的MR任务,而是一条条的SQL语句。数据平台内部通过类似JDBC的接口与HiveServer进行交互,仅仅能够感知到一条SQL的开始与结束,而中间的这个过程通常是漫长的(两个因素:数据量、SQL复杂度),某些场景下用户需要了解这条SQL语句的执行进度,从而为我们引入以下几个问题:
(1)通过JDBC接口执行一条SQL语句时,这条SQL语句被转换成..
php 连接hive,php连接hive执行sql查询 | 学步园
weixin_32417571的博客
03-10
214
使用php连接hive的条件1 需要安装thrift 安装步骤# ./configure --without-ruby# make && make install如果没有安装libevent libevent-devel的应该先安装这两个依赖库yum -y install libevent libevent-devel安装好后启动hive thrift# ./hive-...
php 连接hive,PHP连接Hive执行sql查询
weixin_42153615的博客
03-10
270
使用php连接hive的条件1 需要安装thrift 安装步骤# ./configure --without-ruby# make && make install如果没有安装libevent libevent-devel的应该先安装这两个依赖库yum -y install libevent libevent-devel安装好后启动hive thrift# ./hive-...
php 连接hive,php使用thrift 0.8访问操作hive1.0
weixin_33335559的博客
03-10
118
/*** Hive 的PHP操作类* Rain <563268276@qq.com>*/defined('HIVE_LIB_PATH') or define('HIVE_LIB_PATH', realpath(dirname(__FILE__)).'/');//为了避免HIVE查询的结果内存超出,设定返回所有的hive查询记录的最大值define('MAX_ROWS', 1000000...
hive总结
小小怪下士
11-21
1434

1.hive 数据类型
http://www.cnblogs.com/sharpxiajun/archive/2013/06/03/3114560.html
2.substr('abc',0,2) = ab
mysql 是从1开始的 select * from online_server where substr(count_time,1,10)='2011-12-11'
php thrift tsocket timeout,thrift 返回 TSocket read 0 bytes 求助!!!!汗血宝马
weixin_39895977的博客
03-17
91
关键代码(服务器1 start_server.py):# Server 端对中文字段处理if isinstance(value, unicode):value = value.encode("utf8")setattr(tobj, k, value)关键代码(服务器2 start_server.py):# Server 端对中文字段处理if isinstance(value, unicode):p...
socket read time out解决方法_深入浅出讲解:php的socket通信
weixin_39834745的博客
11-27
3300
来源:https://www.cnblogs.com/aipiaoborensheng/p/6708963.html对TCP/IP、UDP、Socket编程这些词你不会很陌生吧?随着网络技术的发展,这些词充斥着我们的耳朵。那么我想问:什么是TCP/IP、UDP?Socket在哪里呢?Socket是什么呢?你会使用它们吗?什么是TCP/IP、UDP?TCP/IP(Transmission ...
关于hive sql报错问题
u013176920的博客
11-06
531
生产跑sql
select sum(col) from (select 1 col from zbg_serv.tf_f_user_svc_item where month_id='201811' and day_id='05' limit 1 union all select 1 col from zbg_serv.tf_f_user_svc where month_id='201811' ...
thrift中的超时(timeout)坑
weixin_34260991的博客
12-02
2394
最近在项目中采用thrift作为后台服务rpc框架,总体用下来性能还不错,跨语言特性使用起来也还行,但是也遇到了一些坑,其中之一就是超时问题(timeout),如果服务端些的某些业务场景耗时较长,thrift client几乎毫无意外的会遇到:Read timed out, 当然解决办法也很容易,thrift client端手动设置一个较长的超时时间即可。
下面才是真正吐槽的开始:
既然号称跨...
php通过 thrift访问hadoop的hive
Sean的专栏
04-28
6120
本文讲解php通过sql查询hadoop中的数据。主要使用的技术是:php通过thrift向hive提交sql查询,hive将sql查询转换成hadoop任务,等到hadoop执行完毕后,返回一个结果uri,然后我们只需要读取这个uri中的内容。
Thrift的诞生是为了解决不同语言之间的访问的问题,可以支持多种程序语言,如c++、php、java、python等。Thrift是由faceboo
thrift TSocket read 0 bytes(string类型中的一个坑)
感谢那一段回忆里的疯狂,在我们最无谓的岁月闪着光。
03-22
1万+
最近把thrif从0.9版本升级到0.10版本之后,一些一直在报thrift TSocket read 0 bytes 错误。
此篇文章记录thrift中的一个坑。
从thrift的官方文档中可以知道,如下:
Base Types
The base types were selected with the goal of simplicity
and clarity rathe
“相关推荐”对你有帮助么?
非常没帮助
没帮助
一般
有帮助
非常有帮助
提交
©️2022 CSDN
皮肤主题:大白
设计师:CSDN官方博客
返回首页
qq271757232
CSDN认证博客专家
CSDN认证企业博客
码龄11年
暂无认证
79
原创
23万+
周排名
93万+
总排名
7万+
访问
等级
1603
积分
粉丝
获赞
评论
收藏
私信
关注
热门文章
Mcrypt加密解密乱码处理
3757
PHP 连接 Hive 执行 SQL 查询
3655
nagios网页密码设置
2515
KVM和远程管理工具virt-manager的部署
2509
Echarts PHP接口
2033
分类专栏
PHP
9篇
activeMQ
1篇
MySQL
3篇
CSS
1篇
Linux
18篇
Hadoop
21篇
Web Analytics
8篇
SSH
1篇
Shell
2篇
Hive
3篇
Nginx
4篇
Redis
4篇
Chart
Firefox
1篇
SEO
TD
1篇
Theme
1篇
Nagios
5篇
网站性能
1篇
FTP
1篇
最新评论
getClientIP
dunkbird:
好用,跨域的时候,在laravel 中用$request->getClientIp()取不到真实IP地址,用这个方法就可以了。
利用linux mutt 发送邮件(在Shell脚本中使用比较方便)
微电子学与固体电子学-俞驰:
看起来好复杂,我试试吧。
Echarts PHP接口
脸肿了:
这个怎么调用啊,我需要用到这个!
Echarts PHP接口
dimingchan:
太有才了,谢谢楼主分享啦
PHP 连接 Hive 执行 SQL 查询
suolemen:
连接hive用户名密码都不要吗?或者是在哪里配置了吗?能说下不?
您愿意向朋友推荐“博客详情页”吗?
强烈不推荐
不推荐
一般般
推荐
强烈推荐
提交
最新文章
PHP SESSION - Redis
www.chenliujin.com
mysql binVars异常
2016年2篇
2014年63篇
2013年42篇
2012年4篇
目录
目录
分类专栏
PHP
9篇
activeMQ
1篇
MySQL
3篇
CSS
1篇
Linux
18篇
Hadoop
21篇
Web Analytics
8篇
SSH
1篇
Shell
2篇
Hive
3篇
Nginx
4篇
Redis
4篇
Chart
Firefox
1篇
SEO
TD
1篇
Theme
1篇
Nagios
5篇
网站性能
1篇
FTP
1篇
目录
评论 1
被折叠的 条评论
为什么被折叠?
到【灌水乐园】发言
查看更多评论
打赏作者
qq271757232
你的鼓励将是我创作的最大动力
¥2
¥4
¥6
¥10
¥20
输入1-500的整数
余额支付
(余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付
您的余额不足,请更换扫码支付或充值
打赏作者
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额
抵扣说明:
1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。 2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。
余额充值