Connect to hive using php

Source: Internet
Author: User
When using php to connect to hive, use php to connect to hive. condition 1 & nbsp; thrift & nbsp must be installed; install the dependency Library yuminstallautomakelibtoolflexbisonpkgconfiggcc-c ++ boost-devellibevent-develzlib-develpython-develruby-d using php to connect to hive
Conditions for using php to connect to hive

1. install thrift

Install dependency Library

yum install automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-devel zlib-devel python-devel ruby-devel


#  ./configure --without-ruby #   make && make install


If libevent-devel is not installed, install the two dependent libraries yum-y install libevent-devel first.

Start hive thrift after installation

# ./hive --service hiveserver >/dev/null 2>/dev/null &


Check whether the default port 10000 of hiveserver is enabled. If yes, it indicates that the port is successfully enabled.

 netstat -tnlp|grep :10000


Note: The php version is 5.2 or later.

Php connection hive code

 Open (); // run queries, metadata calletc $ client-> execute ('add jar/usr/local/hadoop/hive/lib/hive-contrib-0.7.0-cdh3u0.jar '); $ client-> execute ('SELECT count (1) from apilog'); var_dump ($ client-> fetchAll (); $ transport-> close ();?>



Save the above code as the www path/var/www/html/from test. php to apache and put the dependency package of php to/var/www/html/hivephp/thrift/

Php connects to the hive lib package: see the attachment.

Open the browser and browse http: // localhost/test. php to view the query results.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.