Hive Beeline 的使用

Hive 使用 Beeline 连接配置 Hive 使用 Beeline 连接配置 及连接可视化工具 阅读详情

前言:官方文档这样来说HiveServer2HiveServer2 (introduced in Hive 0.11) has its own CLI called Beeline. HiveCLI is now deprecated in favor of Beeline, as it lacks the multi-user, security, and other capabilities of HiveServer2.。HiveServer是一种可选服务,允许远程客户端可以使用各种编程语言向Hive提交请求并检索结果。HiveServer是建立在Apache ThriftTM(http://thrift.apache.org/) 之上的,因此有时会被称为Thrift Server,这可能会导致混乱,因为新服务HiveServer2也是建立在Thrift之上的.自从引入HiveServer2后,HiveServer也被称为HiveServer1。HiveServer2(HS2)是一种能使客户端执行Hive查询的服务。 HiveServer2是HiveServer1的改进版,HiveServer1已经被废弃。HiveServer2可以支持多客户端并发和身份认证。旨在为开放API客户端(如JDBC和ODBC)提供更好的支持。HiveServer2单进程运行,提供组合服务,包括基于Thrift的Hive服务(TCP或HTTP)和用于Web UI的Jetty Web服务器

  1. HiveServer2 的配置

    1. hive-site.xml 中的配置

      <!-- 开启HiveServer2的认证模式 -->
      <property>
          <name>hive.server2.authentication</name>
          <value>CUSTOM</value>
      </property>
      <!-- 配置自定义验证类,需要自己编写,下面会给我具体的代码 -->
      <property>
          <name>hive.server2.custom.authentication.class</name>
          <value>com.allin.auth.CustomPasswdAuthenticator</value>
      </property>
      <!-- hive-site.xml中配置用户密码 -->
      <property>
          <name>hive.jdbc_passwd.auth.root</name>
          <value>123456</value>
      </property>
      <property>
          <name>hive.metastore.schema.verification</name>
          <value>false</value>
      </property>
          <!--HiveServer2 配置启动端口,默认是10000 -->
      <property>
              <name>hive.server2.thrift.http.port</name>
              <value>10086</value>
      </property>
      <!--HiveServer2 配置连接方式,Expects one of [binary, http].Transport mode of HiveServer2 -->
      <property>
              <name>hive.server2.transport.mode</name>
              <value>http</value>
      </property>
      <property>
          <name>hive.server2.thrift.http.path</name>
          <value>cliservice</value>
          <description>Path component of URL endpoint when in HTTP mode.</description>
       </property>
       <property>
              <name>hive.server2.thrift.max.worker.threads</name>
              <value>500</value>
       </property>
       <property>
              <name>hive.server2.thrift.min.worker.threads</name>
              <value>5</value>
       </property>
       <!--重要配置,默认情况下,HiveServer2以提交查询的用户执行查询。Setting this property to true will have HiveServer2 execute Hive operations as the user making the calls to it -->
       <property>
              <name>hive.server2.enable.doAs</name>
              <value>false</value>
       </property>
    2. 自定义验证类,实现PasswdAuthenticationProvider即可

      public class CustomPasswdAuthenticator implements PasswdAuthenticationProvider {
          private Logger LOG = LoggerFactory.getLogger(CustomPasswdAuthenticator.class);
          private Configuration conf = null;
      
          @Override
          public void Authenticate(String userName, String passwd) throws AuthenticationException {
              this.LOG.info("user: " + userName + " try login.");
              String passwdConf = getConf().get(String.format("hive.jdbc_passwd.auth.%s", new Object[]{userName}));
      
              if (passwdConf == null) {
                  String message = "user's ACL configration is not found. user:" + userName;
                  this.LOG.info(message);
                  throw new AuthenticationException(message);
              }
              if (!passwd.equals(passwdConf)) {
                  String message = "user name and password is mismatch. user:" + userName;
                  throw new AuthenticationException(message);
              }
          }
      
          public Configuration getConf() {
              if (this.conf == null) {
                  this.conf = new Configuration(new HiveConf());
              }
              return this.conf;
          }
      
          public void setConf(Configuration conf) {
              this.conf = conf;
          }
      }
  2. 命令行中使用HiveServer2

    1. 启动hiveserver2进程:hive --service hiveserver2 &
    2. 进入CLI命令行,即beeline:beeline
    3. 连接hiveserver2服务,对应的用户名和密码是在hive-site.xml中配置的认证用的用户名和密码:!connect jdbc:hive2://127.0.0.1:10001/default;transportMode=http;httpPath=cliservice root 后面跟着的root表示用户名,这里可以不写,回车后会有相应的提示
      进入命令行
    4. 使用,使用方法和Hive的CLI类似
      使用方法
  3. 使用JAVA客户端连接HiveServer2

    1. 下面展示一下我写的1.0 版本的连接池,后续使用了druid来维护这个连接池

      public class HiveUtils {
          @Value("${hive.jdbc}")
          private  String JDBC = "";
          @Value("${hive.user}")
          private  String USER = "";
          @Value("${hive.password}")
          private  String PASSWORD = "";
          private  Connection con = null;
          public synchronized Connection getConnection() {
              try {
                  if (con == null){
                      System.out.println(JDBC + "=======" + USER + "==========" + PASSWORD);
                      Class.forName("org.apache.hive.jdbc.HiveDriver");
                      con = DriverManager.getConnection(JDBC , USER, PASSWORD);
                  }
                  return con;
              } catch (Exception e) {
                  e.printStackTrace();
              }
              return null;
          }
      }
    2. 测试查询,对返回数据做了一下简单的封装

          Connection connection = hiveUtils.getConnection();
          java.sql.Statement statement = connection.createStatement();
          // 获取所有字段
          if (StringUtils.isNotBlank(database) && StringUtils.isNotBlank(tableName)) {
              List<String> columns = getColumns(map);
              // 执行sql查询数据
              ResultSet resultSet1 = statement.executeQuery(sql);
              int size = columns.size();
              List<Map<String, String>> resultList = new ArrayList<>();
              while (resultSet1.next()) {
                  Map<String, String> lineMap = new HashMap<>(size);
                  for (int i = 0; i < size; i++) {
                      lineMap.put(columns.get(i), resultSet1.getString(i + 1));
                  }
                  resultList.add(lineMap);
              }
              returnMap.put("num", resultList.size());
              returnMap.put("result", resultList);
          }

引用:
HiveServer2概述

【Hadoop】hive中beeline的使用方法 例子: 1.连接hive数据库,设置查询结果最大宽度20000 beeline -u jdbc:hive2://10.11.0.160:10000/edw -n uaedw -p uaedw123 --maxWidth=20000 2.连接hive数据库,执行release20190822.sql内容 beeline -u "${jdbc_conn_str}" -n ${user_name... 阅读详情

相关推荐

BigData之Hive beeline:beeline的简介、使用方法之详细攻略

BigData之Hive beeline:beeline的简介、使用方法之详细攻略 目录 beeline的简介 beeline的使用方法 1、命令行参数解释 2、beeline的输出格式 2.1、table 2.2、vertical 2.3、xmlsttr beeline的简介 Hadoop2的Hive采用了新的HiveServer2,而HiveServer2提供了一个新的命令行工具Beeline,它基于SQLLine CLI的JDBC客户端,因此SQLL...

头部AI社区如有邀博主AI主题演讲请私信—心比天高,仗剑走天涯,保持热爱,奔赴向梦想!低调,专注,谦虚,自律,反思,成长,还算比较正能量的博主,公益免费传播…内心特别想在AI界做出一些可以推进历史进程影响力的技术(兴趣使然,有点小情怀,也有点使命感呀 6719

Hive官方使用手册——新Hive CLI(Beeline CLI)

本文为自己翻译的译文,原文地址:https://cwiki.apache.org/confluence/display/Hive/HiveServer2+ClientsHive官方使用手册——新Hive CLI(Beeline CLI)这个页面描述了HiveServer2支持的不同客户端。其它的HiveServer2文档包含:HiveServer2 OverviewSetting Up HiveS...

三米学习笔记杂货铺 2万+

DDSP(Differentiable Digital Signal Processing) 开篇

文章目录DDSP可以用来做什么?下一步工作 工作中接触到了DDSP声码器,但非科班出声的我对这块知识非常陌生,甚至带有一些畏惧的心理,但是为了工作为了进步,必须硬下头皮去啃,相信只要耐心地坚持,没什么能难到我。于是从今天开始,就用这个博客专栏来记录我的学习历程,希望也能帮助到你~ DDSP对应的论文是:DDSP: Differentiable Digital Signal Processing 先翻译一篇来自DDSP论文作者的对DDSP的介绍的文章。 今天,我们很高兴地介绍可微数字信号处理(DDSP)库。

YeeKo的博客 9254

[一起学Hive]之二十-自定义HiveServer2的用户安全认证

HiveServer2提供了JDBC链接操作Hive的功能,非常实用,但如果在使用HiveServer2时候,不注意安全控制,将非常危险,因为任何人都可以作为超级用户来操作Hive及HDFS数据。 比如:在配置HiveServer2的时候,hive.server2.authentication=NONE,表示没有用户认证。 使用beeline,模拟成超级用户hadoop,成功连接到

tony的专栏 5323

【卫星语音通信】神经网络语音编解码算法:AudioDec

最新研究表明,通过深度学习模型对语音信号进行智能压缩与重建,可在12 kbps码率下实现48 kHz采样率的高保真语音还原,其主观音质评分(MOS)可达3.9分(满分4.27分),远超传统参数编码技术。这意味着未来卫星电话的通话质量有望达到CD级水准,而蜂窝网络的语音业务带宽需求可降低60%以上,为蜂窝和卫星网络中的大规模物联网语音交互铺平道路。它的诞生为神经音频编解码技术带来了一次重要升级,有助于让未来实时语音交互更流畅、更清晰,也让我们进一步体验到人工智能与音频信号处理结合所带来的创新可能性。

u011376987的博客 1478

Boost电路双闭环控制MATLAB仿真

通过电流内环控制,我们可以改变目标平均电流基准值的大小来闭环改变占空比,再改变输出电压与电路电流,直到电路电流达到基准电流才达到稳态。但是我们的基准电流依旧是外部提供的,下边的电压外环控制就是电路自己计算基准电流。

Fourglsl的博客 5859

Hive 从入门到精通 - CLI和Beeline命令行的基本使用 与 配置 ( 一 )

一、Hive CLI 1、使用 hive -H 或者 hive --help 命令可以查看所有命令的帮助。 usage: hive -d,--define <key=value> Variable subsitution to apply to hive commands. e.g. -d A=B or --define A=B --定义用户自定义变量 --database <databas

zholeiv5 487

并网逆变器学习笔记5---三电平DPWM

三电平DPWM

圆桌骑士的博客 1万+

hive CUSTOM authentication mode:通过用户名密码连接hiveserver

hive CUSTOM authentication mode:通过用户名密码连接hiveserver

hiliang521的博客 1649

zemax 如何编译用户自定义DLL(含VS下载教程)

zemax 如何编译用户自定义DLL(含VS下载教程)

weixin_72050316的博客 499

图解联合概率密度、边缘概率密度、条件概率密度之间的关系

简要图解联合概率密度、边缘概率密度、条件概率密度之间的关系

一个搬运知识的笨小孩 2万+

HiveServer2(Spark ThriftServer)自定义权限认证

Hive除了为我们提供一个 CLI 方式来查询数据之外,还给我们提供了基于 JDBC/ODBC 的方式来连接Hive,这就是HiveServer2(HiveServer)。但是默认情况下通过 JDBC 连接 HiveServer2 不需要任何的权限认证(hive.server2.authentication = NONE);这意味着任何知道 ThriftServer 地址的人都可以连接我们的...

微步的博客 6710

知识图谱(Knowledge Graph)原理与代码实战案例讲解

知识图谱(Knowledge Graph)原理与代码实战案例讲解 作者:禅与计算机程序设计艺术 / Zen and the Art of Computer Programming 1. 背景介绍 1.1 问题的由来

AI天才研究院 1087

hive的beeline使用

Hive CLI是一种重客户端,在新版本中已移除,推荐使用Hive beeline客户端,可以更好地实现安全控制,下面讲讲beeline的使用。 在hive1.1.0中使用Hive CLI会提示WARNING: Hive CLI is deprecated and migration to Beeline is recommended. 无kerberos的hive beeline !connect jdbc:hive2://centos:10000 username password 对于没有开启.

data2tech的博客 3547

Android Google 支付接入

1. 从 2023 年 8 月 2 日起,所有新应用都必须使用结算库版本 5 或更高版本。自 2023 年 11 月 1 日起,现有应用的所有新版本都必须使用结算库版本 5 或更高版本。 2. 如果您的应用以 Android 14 或更高版本为目标平台,您必须更新到 PBL 5.2.1 或 PBL 6.0.1 或更高版本。

帅次的博客 9408

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Beeline的使用和Hive JDBC

Hive JDBC

qq_51180928的博客 1942

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

【hive】hive的安装配置,beeline使用(1)

hive的安装配置,beeline使用

hx1156477702的博客 2745

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

hive beeline的使用

./beeline -u jdbc:hive2://hadoop03:10000 -n root -p root  不用每次都跟-u  ,可以编辑beeline修改 . "$bin"/hive --service beeline "$@" 为: . "$bin"/hive --service beeline -u jdbc:hive2://hadoop03:10000 "$@" 保存以后,每次直接...

weixin_42496757的博客 1821

beeline安装_hive使用beeline配置远程连接

hive以hadoop集群为基础,提供hdfs的SQL支持;hive一般可以以mysql为元数据存储,默认Derby;hadoop,hive安装自行百度吧;介绍hive的远程访问:未配置之前使用beeline的话,每次都要为连接输入用户名密码,较为麻烦;实现目标:在非集群节点上敲beeline命令,直接进入到hive的命令行1,在hive服务的安装节点的hive-site.xml配置文件中添加以下...

weixin_39606575的博客 859

Hive使用beeline(KERBEROS)

使用beeline连接hive两种方式 1、启动hiveserver2 #进入hive安装目录 cd /usr/local/hive目录 #启动hive2目录 bin/hive --service hiveserver2 2、克隆会话启动beeline #进入hive安装目录 cd /usr/local/hive目录 #启动beeline bin/beeline 3、使用全局 beeline -u beeline -u jdbc:hive2://localhost:10000/defa

weixin_42121574的博客 6926

使用beeline工具连接Hive

###使用beeline工具连接Hive ####第一步:修改hadoop的hdfs-site.xml文件 在该文件中添加以下内容,开启HDFS的REST接口功能: <property> <name>dfs.webhdfs.enabled</name> <value>true</value> </property&g...

KZZ‘s PDG的博客 850

Hive 系列(三)—— Hive CLI和Beeline命令行的基本使用

一、Hive CLI 1.1 Help 使用hive -H或者 hive --help命令可以查看所有命令的帮助,显示如下: usage: hive -d,--define <key=value> Variable subsitution to apply to hive commands. e....

黑白影的博客 1万+

hadoop 如何连beeline_hive使用beeline配置远程连接

hive以hadoop集群为基础,提供hdfs的SQL支持;hive一般可以以mysql为元数据存储,默认Derby;hadoop,hive安装自行百度吧;介绍hive的远程访问:未配置之前使用beeline的话,每次都要为连接输入用户名密码,较为麻烦;实现目标:在非集群节点上敲beeline命令,直接进入到hive的命令行1,在hive服务的安装节点的hive-site.xml配置文件中添加以下...

weixin_39930144的博客 452

Hive CLI和Beeline命令行的基本使用

Hive CLI和Beeline命令行的基本使用

mxk4869的博客 3281

Spark SQL 使用beeline访问hive仓库

一、添加hive-site.xml 在$SPARK_HOME/conf下添加hive-site.xml的配置文件,目的是能正常访问hive的元数据 vim hive-site.xml <configuration> <property> <name>javax.jdo.option.ConnectionURL</name> ...

weixin_33860722的博客 1691

beeline执行sql文件_Hive/Beeline 使用笔记

Hive:利用squirrel-sql 连接hiveadd driver -> name&example url(jdbc:hive2://xxx:10000)->extra class path ->Add{hive/lib/hive-common-*.jarhive/lib/hive-contrib-*.jarhive/lib/hive-jdbc-*.jarhive/...

weixin_39720662的博客 1934
上一篇: Spring security安全登录-当AJAX遇上Redirect
下一篇: 使用druid管理Hive的连接池
aubergines
博客等级 码龄15年 13粉丝 63原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址