<概念基础>
■ HiveServer
可选的 Hive 内置服务,允许远程客户端使用不同编程语言操作Hive。
■ HiveServer2
允许客户端远程访问hive问的服务。基于thrift协议,支持跨平台,跨编程语言对hive访问。
HiveServer无法处理多个客户端的并发请求,故有HiveServer2的重写,从Hive 0.11.0版本开始。建议使用HiveServer2。
■ beeline
Hive 0.11版本引入的新命令行客户端工具,基于SQLLine CLI的JDBC客户端。
Beeline支持嵌入模式(embedded mode)和远程模式(remote mode)。在嵌入式模式下,运行嵌入式的Hive(类似Hive CLI),而远程模式可以通过Thrift连接到独立的HiveServer2进程上。
<配置>
vim /opt/module/hive/conf/hive-site.xml
一、NONE模式
<property>
<name>hive.server2.authentication</name>
<value>NONE</value>
<description>
Expects one of [nosasl, none, ldap, kerberos, pam, custom].
Client authentication types.
NONE: no authentication check
LDAP: LDAP/AD based authentication
KERBEROS: Kerberos/GSSAPI authentication
CUSTOM: Custom authentication provider
(Use with property hive.server2.custom.authentication.class)
PAM: Pluggable authentication module
NOSASL: Raw transport
</description>
</property>
此处若缺省,则默认为NONE模式
二、密码访问
<!--设置用户名和密码-->
<property>
<!--用户名为最后一个:root-->
<name>hive.jdbc_passwd.auth.root</name>
<!--密码-->
<value>pwd</value>
</property>
<常用操作>
Beeline 要与 HiveServer2 配合使用
||▶ 启动hiveserver2服务
M1.前台启动
/opt/module/hive/bin/hiveserver2
M2.后台启动:
创建脚本:vim /opt/module/hive/stratHiveserver2.sh
# 创建日志目录
mkdir -p /opt/module/hive/logs
# 后台启动hiveserver2
nohup /opt/module/hive/bin/hiveserver2 >> /opt/module/hive/logs/hiveserver2.log 2>&1 &
# 查看日志
tail -f /opt/module/hive/logs/hiveserver2.log
▪ 执行脚本:bash /opt/module/hive/stratHiveserver2.sh
,查看日志后可Ctrl + C直接退出,不会应hiveserver2运行
▪ jps查看发现RunJar进程,说明启动成功,可通过kill -9 pid
关闭
||▶ 另起窗口,启动beeline:/opt/module/hive/bin/beeline
||▶ 连接hiveserver2:!connect jdbc:hive2://iZwz94euuu9omin7e32ysnZ:10000
若为NONE模式,则用户名root
、密码随便输或不输都可
也可直接键入/opt/module/hive/bin/beeline -u "jdbc:hive2://iZwz94euuu9omin7e32ysnZ:10000" -n root -p
||▶ 显示全部命令:
!help
||▶ 退出shel:
!exit