您的位置:首页 > 其它

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

2016-07-16 16:43 369 查看
Hive提供了轻客户端的实现,通过HiveServer或者HiveServer2,客户端可以在不启动CLI的情况下对Hive中的数据进行操作,两者都允许远程客户端使用多种编程语言如JavaPython向Hive提交请求,取回结果。HiveServer或者HiveServer2都是基于Thrift的,但HiveSever有时被称为Thrift
server,而HiveServer2却不会。既然已经存在HiveServer为什么还需要HiveServer2呢?这是因为HiveServer不能处理多于一个客户端的并发请求,这是由于HiveServer使用的Thrift接口所导致的限制,不能通过修改HiveServer的代码修正。因此在Hive-0.11.0版本中重写了HiveServer代码得到了HiveServer2,进而解决了该问题。HiveServer2支持多客户端的并发和认证,为开放API客户端如JDBC、ODBC提供了更好的支持。

[hadoop@Master1 apache-hive-1.2.1-bin]$ bin/hive --service  help

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

Service List: beeline cli help hiveburninclient hiveserver2 hiveserver hwi jar lineage metastore metatool orcfiledump rcfilecat schemaTool version 

Parameters parsed:

  --auxpath : Auxillary jars 

  --config : Hive configuration directory

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

Parameters used:

  HADOOP_HOME or HADOOP_PREFIX : Hadoop install directory

  HIVE_OPT : Hive options

For help on a particular service:

  ./hive --service serviceName --help

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

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

[hadoop@Master1 apache-hive-1.2.1-bin]$ bin/hive --service hiveserver --help

Starting Hive Thrift Server

Exception in thread "main" java.lang.ClassNotFoundException: org.apache.hadoop.hive.service.HiveServer

        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

        at java.lang.Class.forName0(Native Method)

        at java.lang.Class.forName(Class.java:274)

        at org.apache.hadoop.util.RunJar.run(RunJar.java:214)

        at org.apache.hadoop.util.RunJar.main(RunJar.java:136)

结果出现如上错误,Google之后发现在hive1.0以后已经被hiveserver2取代,所以执行如下命令:

[hadoop@Master1 apache-hive-1.2.1-bin]$ bin/hive --service hiveserver2 --help

usage: hiveserver2

    --deregister <versionNumber>   Deregister all instances of given

                                   version from dynamic service discovery

 -H,--help                         Print help information

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

[hadoop@Master1 apache-hive-1.2.1-bin]$ 

启动hiveserver2服务:

hive --service hiveserver2 --hiveconf hive.server2.thrift.port=10000

[hadoop@Master1 bin]$ jps

31335 HMaster

28562 NameNode

2596 CassandraDaemon

28876 DFSZKFailoverController

7701 QuorumPeerMain

29023 ResourceManager

1196 Jps

之后多了一个RunJar进程

[hadoop@Master1 bin]$  jps

31335 HMaster

28562 NameNode

2596 CassandraDaemon

1222 RunJar

28876 DFSZKFailoverController

1308 Jps

7701 QuorumPeerMain

29023 ResourceManager

[hadoop@Master1 bin]$
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: