您的位置:首页 > 其它

Hive学习之HiveServer2服务端配置与启动

2016-03-30 11:20 363 查看
在之前的学习和实践Hive中,使用的都是CLI或者hive –e的方式,该方式仅允许使用HiveQL执行查询、更新等操作,并且该方式比较笨拙单一。幸好Hive提供了轻客户端的实现,通过HiveServer或者HiveServer2,客户端可以在不启动CLI的情况下对Hive中的数据进行操作,两者都允许远程客户端使用多种编程语言如Java、Python向Hive提交请求,取回结果。HiveServer或者HiveServer2都是基于Thrift的,但HiveSever有时被称为Thrift server,而HiveServer2却不会。既然已经存在HiveServer为什么还需要HiveServer2呢?这是因为HiveServer不能处理多于一个客户端的并发请求,这是由于HiveServer使用的Thrift接口所导致的限制,不能通过修改HiveServer的代码修正。因此在Hive-0.11.0版本中重写了HiveServer代码得到了HiveServer2,进而解决了该问题。HiveServer2支持多客户端的并发和认证,为开放API客户端如JDBC、ODBC提供了更好的支持。

既然HiveServer2提供了更强大的功能,将会对其进行着重学习,但也会简单了解一下HiveServer的使用方法。在命令中输入hive --service help,结果如下。从结果可以了解到,可以使用hive <parameters> --service serviceName <serviceparameters>启动特定的服务,如cli、hiverserver、hiveserver2等。

[plain] view
plain copy

print?





[hadoop@hadoop~]$ hive --service help

Usage ./hive<parameters> --service serviceName <service parameters>

Service List: beelinecli help hiveserver2 hiveserver hwi jar lineage metastore metatool orcfiledumprcfilecat schemaTool version

Parametersparsed:

--auxpath : Auxillary jars

--config : Hive configuration directory

--service : Starts specificservice/component. cli is default

Parameters used:

HADOOP_HOME or HADOOP_PREFIX : Hadoop installdirectory

HIVE_OPT : Hive options

For help on aparticular service:

./hive --service serviceName --help

Debug help: ./hive --debug --help

在命令行输入hive --service hiveserver –help查看hiveserver的帮助信息:

[plain] view
plain copy

print?





[hadoop@hadoop~]$ hive --service hiveserver --help

Starting Hive Thrift Server

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 portnumber, default:10000

-v,--verbose Verbose mode

启动hiveserver服务,可以得知默认hiveserver运行在端口10000,最小100工作线程,最大2147483647工作线程。

[plain] view
plain copy

print?





[hadoop@hadoop~]$ hive --service hiveserver -v

Starting Hive Thrift Server

14/08/01 11:07:09WARN conf.HiveConf: DEPRECATED: hive.metastore.ds.retry.* no longer has anyeffect. Use hive.hmshandler.retry.*instead

Starting hive serveron port 10000 with 100 min worker threads and 2147483647 maxworker threads

接下来学习更强大的hiveserver2。Hiveserver2允许在配置文件hive-site.xml中进行配置管理,具体的参数为:

[plain] view
plain copy

print?





hive.server2.thrift.min.worker.threads– 最小工作线程数,默认为5。

[plain] view
plain copy

print?





hive.server2.thrift.max.worker.threads – 最小工作线程数,默认为500。

hive.server2.thrift.port– TCP 的监听端口,默认为10000。

hive.server2.thrift.bind.host– TCP绑定的主机,默认为localhost。

也可以设置环境变量HIVE_SERVER2_THRIFT_BIND_HOST和HIVE_SERVER2_THRIFT_PORT覆盖hive-site.xml设置的主机和端口号。从Hive-0.13.0开始,HiveServer2支持通过HTTP传输消息,该特性当客户端和服务器之间存在代理中介时特别有用。与HTTP传输相关的参数如下:

[plain] view
plain copy

print?





hive.server2.transport.mode – 默认值为binary(TCP),可选值HTTP。

hive.server2.thrift.http.port– HTTP的监听端口,默认值为10001。

[plain] view
plain copy

print?





hive.server2.thrift.http.path – 服务的端点名称,默认为 cliservice。

hive.server2.thrift.http.min.worker.threads– 服务池中的最小工作线程,默认为5。

hive.server2.thrift.http.max.worker.threads– 服务池中的最小工作线程,默认为500。

启动Hiveserver2有两种方式,一种是上面已经介绍过的hive --service hiveserver2,另一种更为简洁,为hiveserver2。使用hive--service hiveserver2 –H或hive--service hiveserver2 –help查看帮助信息:

[plain] view
plain copy

print?





Starting HiveServer2

Unrecognizedoption: -h

usage:hiveserver2

-H,--help Print help information

--hiveconf <property=value> Use value for given property

默认情况下,HiveServer2以提交查询的用户执行查询(true),如果hive.server2.enable.doAs设置为false,查询将以运行hiveserver2进程的用户运行。为了防止非加密模式下的内存泄露,可以通过设置下面的参数为true禁用文件系统的缓存:

[plain] view
plain copy

print?





fs.hdfs.impl.disable.cache – 禁用HDFS文件系统缓存,默认值为false。

fs.file.impl.disable.cache – 禁用本地文件系统缓存,默认值为false。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: