节俭的 Hive 服务器

HiveServer 是一项可选服务,它允许远程client使用各种编程语言向 Hive 提交请求并检索结果。 HiveServer 是基于 Apache ThriftTM(http://thrift.apache.org/)构建的,因此有时会称为* Thrift 服务器*,尽管这会引起混乱,因为新的名为HiveServer2的服务也是基于 Thrift 构建的。自从引入 HiveServer2 以来,HiveServer 也被称为* HiveServer1 *。

WARNING!

HiveServer 无法处理来自多个 Client 端的并发请求。这实际上是 HiveServer 导出的 Thrift 接口所施加的限制,无法通过修改 HiveServer 代码来解决。
HiveServer2是对 HiveServer 的重写,从 Hive 0.11.0 开始解决了这些问题。建议使用 HiveServer2.

HiveServer 是从 Hive 1.0.0( 以前称为 0.14.1 )开始的 Hive 版本中的removed. 请切换到 HiveServer2. ****

先前已计划将其删除配置单元 0.15(现在称为 1.1.0)。参见HIVE-6977。 **** **** ****

HiveServer 的 Thrift 的接口定义语言(IDL)文件是hive_service.thrift,该文件安装在$HIVE_HOME/service/if/中。

使用Getting Started中的步骤构建 Hive 之后,可以通过运行以下命令来启动 Thrift 服务器:

0.8 及更高版本

$ build/dist/bin/hive --service hiveserver --help
usage: hiveserver
 -h,--help                        Print help information
    --hiveconf <property=value>   Use value for given property
    --maxWorkerThreads <arg>      maximum number of worker threads,
                                  default:2147483647
    --minWorkerThreads <arg>      minimum number of worker threads,
                                  default:100
 -p <port>                        Hive Server port number, default:10000
 -v,--verbose                     Verbose mode

$ bin/hive --service hiveserver

0.7 及更低版本

$ build/dist/bin/hive --service hiveserver --help
usage HIVE_PORT=xxxx ./hive --service hiveserver
  HIVE_PORT : Specify the server port

$ bin/hive --service hiveserver

启动服务器后,要测试服务器是否正常运行,请在“独立”模式下运行 hiveserver 和 jdbc 测试。在这种情况下,localhost 上的 HIVE_PORT 假定为 10000.

$ ant test -Dtestcase=TestJdbcDriver -Dstandalone=true
$ ant test -Dtestcase=TestHiveServer -Dstandalone=true

该服务支持多种语言的 Client 端。有关更多详细信息,请参见Hive Client

Troubleshooting: Connection Error

Hive 服务器和 Client 端通过 Thrift 和 FB303 服务进行通信。在某些发行版中,Hadoop 和 Hive 发行版均具有不同版本的 libthrift.jar 和 libfb303.jar。如果它们不兼容,则在独立模式下运行单元测试时,可能会导致 Thrift 连接错误。解决方案是删除 Hadoop 的 libthrift.jar 和 libfb303.jar 版本。