hiveserver2客户端+服务端配置教程

首先是GUI客户端:

1、参考 几个连接HiveServer的客户端界面工具 – thy822的专栏 – CSDN博客 第一个SQuirrel SQL Client客户端:https://pan.baidu.com/s/1miSLSt6 ,下载下来,那几个jar包我已经去服务器上找好了打包直接下载:https://pan.baidu.com/s/1bzJGYE

2、hql基本上和mysql是兼容的,如果有不懂的地方可以先去学学sql的语法,查询where组好带分区字段,否则hive会扫表查询所有记录。

3、如果遇到了“ submitted by user root to unknown queue root.??”的话,请在jdbc中指定queue为default也就是:`jdbc:hive2://:/default;sess_var_list?mapred.job.queue.name=default`,或者连上hiveserver2之后先查询一下`set mapred.job.queue.name=default`应该也行。

4、关注到pythoner在使用hive客户端:dropbox/PyHive 遇到问题,这里我把py的客户端下载配置了一遍,简略教程如下(我系统centos7):

a、按照github的repo推荐安装方法安装好
b、根据错误提示安装一些第三方的库
c、打开py的shell
[code]
from pyhive import hive
c=hive.connect(host=’192.168.1.109′, username=’gc’, password=’gcpasswd’).cursor();
c.execute("set mapred.job.queue.name=default")
c.execute("select count(*) from person where create_date_partition=’2017-08-02’")
print c.fetchall();
//[(12345,)]
[/code]
注意在connect这一步有2个坑:第一个是官方的库写的有bug,我改了一下见:if auth is "NONE", username and password can be provided by gouchaoer · Pull Request #147 · dropbox/PyHive ,现在你改的话需要在系统的python库安装的地方找到pyhive自己修改,我这里是`/usr/lib/python2.7/site-packages/pyhive/hive.py`,注意把hive.pyc的缓存删了。第二是如果你遇到了:`thrift.transport.TTransport.TTransportException: Could not start SASL: Error in sasl_client_start (-4) SASL(-4): no mechanism`的错误就安装对应的依赖库,我这里是`yum install cyrus-sasl-plain cyrus-sasl-devel cyrus-sasl-gssapi`

服务器端:
密码验证方式选择的CUSTOM,主要参考这个答案来的:Simple User/Password authentication for HiveServer2 (without Kerberos/LDAP)
不过这个答案有几个bug,现在修改如下:

vim SampleAuthenticator.java
[code]
package ick.SampleAuth;

import java.util.Hashtable;
import javax.security.sasl.AuthenticationException;
import org.apache.hive.service.auth.PasswdAuthenticationProvider;

public class SampleAuthenticator implements PasswdAuthenticationProvider {

Hashtable<String, String> store = null;

public SampleAuthenticator () {
store = new Hashtable<String, String>();
store.put("user1", "passwd1");
store.put("user2", "passwd1");
}

@Override
public void Authenticate(String user, String password)
throws AuthenticationException {

String storedPasswd = store.get(user);

if (storedPasswd != null && storedPasswd.equals(password))
return;

throw new AuthenticationException("SampleAuthenticator: Error validating user");
}
“`
打包命令为:
“`
javac -cp /icksys/apache-hive-2.1.1-bin/lib/hive-service-2.1.1.jar SampleAuthenticator.java -d .
jar cf ick.jar ick
cp ick.jar /icksys/apache-hive-2.1.1-bin/lib
“`
在hive-site.xml配置如下:
“`
<code>
<property>
<name>hive.server2.authentication</name>
<value>CUSTOM</value>
</property>

<property>
<name>hive.server2.custom.authentication.class</name>
<value>ick.SampleAuth.SampleAuthenticator</value>
</property>

<property>
<name>hive.server2.enable.doAs</name>
<description>Enable user impersonation for HiveServer2</description>
<value>false</value>
</property>
[/code]

然后重启hiveserver2,让账号+用户名生效。

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇