分享

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

rsgg03 2015-3-30 19:47:46 发表于 实操演练 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 3 180578

问题导读

1.hive允许远程客户端使用哪些编程语言?
2.已经存在HiveServer为什么还需要HiveServer2?
3.HiveServer2有哪些优点?
4.hive.server2.thrift.min.worker.threads-最小工作线程数,默认为多少?
5.启动Hiveserver2有哪两种方式?






在之前的学习和实践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等。

  1. [hadoop@hadoop~]$ hive --service  help
  2. Usage ./hive<parameters> --service serviceName <service parameters>
  3. Service List: beelinecli help hiveserver2 hiveserver hwi jar lineage metastore metatool orcfiledumprcfilecat schemaTool version
  4. Parametersparsed:
  5.   --auxpath : Auxillary jars
  6.   --config : Hive configuration directory
  7.   --service : Starts specificservice/component. cli is default
  8. Parameters used:
  9.   HADOOP_HOME or HADOOP_PREFIX : Hadoop installdirectory
  10.   HIVE_OPT : Hive options
  11. For help on aparticular service:
  12.   ./hive --service serviceName --help
  13. Debug help:  ./hive --debug --help
复制代码
在命令行输入hive --service hiveserver –help查看hiveserver的帮助信息:

  1. [hadoop@hadoop~]$ hive --service hiveserver --help
  2. Starting Hive Thrift Server
  3. usage:hiveserver
  4. -h,--help                        Print help information
  5.     --hiveconf <property=value>   Use value for given property
  6.     --maxWorkerThreads <arg>      maximum number of worker threads,
  7.                                  default:2147483647
  8.     --minWorkerThreads <arg>      minimum number of worker threads,
  9.                                   default:100
  10. -p <port>                        Hive Server portnumber, default:10000
  11. -v,--verbose                     Verbose mode
复制代码


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

  1. [hadoop@hadoop~]$ hive --service hiveserver -v
  2. Starting Hive Thrift Server
  3. 14/08/01 11:07:09WARN conf.HiveConf: DEPRECATED: hive.metastore.ds.retry.* no longer has anyeffect.  Use hive.hmshandler.retry.*instead
  4. Starting hive serveron port 10000 with 100 min worker threads and 2147483647 maxworker threads
复制代码
接下来学习更强大的hiveserver2。Hiveserver2允许在配置文件hive-site.xml中进行配置管理,具体的参数为:

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

  1. hive.server2.thrift.max.worker.threads – 最小工作线程数,默认为500。
  2. hive.server2.thrift.port– TCP 的监听端口,默认为10000。
  3. 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传输相关的参数如下:
  1. hive.server2.transport.mode – 默认值为binary(TCP),可选值HTTP。
  2. hive.server2.thrift.http.port– HTTP的监听端口,默认值为10001。
复制代码

  1. hive.server2.thrift.http.path – 服务的端点名称,默认为 cliservice。
  2. hive.server2.thrift.http.min.worker.threads– 服务池中的最小工作线程,默认为5。
  3. hive.server2.thrift.http.max.worker.threads– 服务池中的最小工作线程,默认为500。
复制代码


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

  1. Starting HiveServer2
  2. Unrecognizedoption: -h
  3. usage:hiveserver2
  4. -H,--help                        Print help information
  5.     --hiveconf <property=value>   Use value for given property
复制代码
默认情况下,HiveServer2以提交查询的用户执行查询(true),如果hive.server2.enable.doAs设置为false,查询将以运行hiveserver2进程的用户运行。为了防止非加密模式下的内存泄露,可以通过设置下面的参数为true禁用文件系统的缓存:
  1. fs.hdfs.impl.disable.cache – 禁用HDFS文件系统缓存,默认值为false。
  2. fs.file.impl.disable.cache – 禁用本地文件系统缓存,默认值为false。
复制代码










欢迎大家如about云官方群371358502,更新咨询,更新资源,随时关注

已有(3)人评论

跳转到指定楼层
feng01301218 发表于 2015-3-31 11:10:52
回复

使用道具 举报

77925978 发表于 2017-7-28 15:22:53
能提供一份完整的hive配置文件吗
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条