HiveServer2的配置和使用

hive-site.xml配置

hiveserver2的配置

<property>

<name>hive.support.concurrency</name>

<description>Enable Hive's TableLock Manager Service</description>

<value>true</value>

</property>

<property>

<name>hive.zookeeper.quorum</name>

<description>

Zookeeper quorum used by Hive's Table Lock Manager

</description>

<value>

e3basestorage1:2181,e3basestorage2:2181,e3basestorage3:2181

</value>

</property>

<property>

<name>hive.server2.thrift.bind.host</name>

<value>172.21.3.170</value>

<description>

Bind host on which to run the HiveServer2 Thrift interface.Can

be overridden by setting $HIVE_SERVER2_THRIFT_BIND_HOST

</description>

</property>

远程访问元数据的配置

<property>

<name>hive.metastore.uris</name>

<value>thrift://172.21.1.56:9083</value>

<description>Thrift uri for the remote metastore. Used by metastoreclient to connect to remote metastore.</description>

</property>

<property>

<name>hive.metastore.local</name>

<value>false</value>

<description>this is local store .</description>

</property>

shell交互

bin/beeline

!connectjdbc:hive2://localhost:10000 e3base
e3base123 org.apache.hive.jdbc.HiveDriver  (红字为当前的用户名和密码

)

Jdbc连接

远程启动元数据服务:

nohup bin/hive --servicemetastore&

启动hiveserver2服务

nohup bin/hive --servicehiveserver2  &  以后台进程的方式启动

Java客户端访问

示例代码:

package com.sitech;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import org.apache.log4j.Logger;

public
class
T1 {

private
static
Logger log = Logger.getLogger(T1.class);

private
static
String driverName =
"org.apache.hive.jdbc.HiveDriver";

public
boolean
run() {

try {

Class.forName(driverName);

Connection con = null;

con = DriverManager.getConnection(

"jdbc:hive2://172.21.3.170:10000/hivedb",
"", "");

Statement stmt = con.createStatement();

ResultSet res = null;

String sql = "selectcount(*) from test";

System.out.println("Running:" + sql);

res = stmt.executeQuery(sql);

System.out.println("ok");

while (res.next()) {

System.out.println(res.getString(1));

}

return
true
;

} catch (Exception e) {

e.printStackTrace();

log.error("Connection:" + e.getMessage());

System.out.println("error");

return
false
;

}

}

public
static void
main(String[] args)
throws SQLException {

HiveJdbcClienthiveJdbcClient =
new
HiveJdbcClient();

hiveJdbcClient.run();

}

}

HiveServer2的配置使用的更多相关文章

  1. python 连接 hive 的 HiveServer2 的配置坑

    环境: hadoop 2.7.6 hive 2.3.4 Hive 的 thirft 启动: hadoop 单机或者集群需要: 启动 webhdfs 修改 hadoop 的代理用户 <proper ...

  2. hive metastore && hiveserver2 . jvm 配置调整优化

    hive-env.sh 添加如下,其中踩坑踩了不少. if [ "$SERVICE" = "metastore" ]; then if [ -z "$ ...

  3. hive metastore && hiveserver2 . 基本配置

    <?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-s ...

  4. hiveserver2启动成功但无法通过beeline连接

    可能是配置的问题. 我将hive.metastore.uris从配置文件中注释掉之后解决了hiveserver2启动成功但无法通过beeline连接的问题. [root@node03 conf]# v ...

  5. hive权限配置

    基于CDH5.x的Hive权限配置 1.打开权限控制,默认是没有限制的 set hive.security.authorization.enabled=true; 2.配置默认权限 hive.secu ...

  6. CDH6.3.0下Apache Atlas2.1.0安装与配置

    CDH6.3.0下Apache Atlas2.1.0安装与配置 0. 说明 文中的${ATLAS_HOME}, ${HIVE_HOME} 环境变更需要根据实际环境进行替换. 1. 依赖 A. 软件依赖 ...

  7. 为CDH 5.7集群添加Kerberos身份验证及Sentry权限控制

    转载请注明出处:http://www.cnblogs.com/xiaodf/ 4. 为CDH 5集群添加Kerberos身份验证 4.1 安装sentry1.点击“操作”,“添加服务”:2.选择sen ...

  8. 基于CDH5.x 下面使用eclipse 操作hive 。使用java通过jdbc连接HIVESERVICE 创建表

    基于CDH5.x 下面使用eclipse 操作hive .使用java通过jdbc连接HIVESERVICE 创建表 import java.sql.Connection; import java.s ...

  9. Hive基础(4)---Hive的内置服务

    版权声明:<—— 本文为作者呕心沥血打造,若要转载,请注明出处@http://blog.csdn.net/gamer_gyt <——   目录(?)[+]   一:Hive的几种内置服务 ...

随机推荐

  1. Java 模拟ATM(修正)

    ATM机的账户记录Account有账户的唯一性标识(11个长度的字符和数字的组合),用户的姓名,操作日期(Date),操作类型,账户密码(六位的数字,可以用0开头),当前的余额(可以为0). 模拟AT ...

  2. nodejs--vue

    nodejs--vue 基础知识认识: 前端工程化 最近才兴起,nodejs(包的管理更加方便),webpack 数据双向绑定 mvm 数据驱动vue,vue改变数据 组件化开发 vue 中的常见 概 ...

  3. uva11609(组合数学,快速幂)

    先选人,再从这些人里选一个队长,方案总数:C(i,1)*C(n,i)(其中i从1到n)的总和. 这个公式显然不能在时限内暴力算出来,需要变形和推导出更简单的来. 用到组合数里面这个公式:C(n,k)* ...

  4. QQ帐户的申请与登陆(25 分)

    实现QQ新帐户申请和老帐户登陆的简化版功能.最大挑战是:据说现在的QQ号码已经有10位数了. 输入格式: 输入首先给出一个正整数N(≤),随后给出N行指令.每行指令的格式为:“命令符(空格)QQ号码( ...

  5. Find The Multiple(DFS)

    Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal repr ...

  6. NSString *const 和 const NSString * 的区别

    1.变量存储的指针可变,变量存储的值不可变 //A modifiable pointer to a constant NSString (its value can't be modified) &q ...

  7. TexStudio 非常好用的Latex软件

    先大概写一下,免得忘了,等有时间详细补充. 跨平台.免费. 语法高亮 方便的公式.符号选择界面 可以配置Latex,pdflatex,xelatex等默认编译命令 集成了pdf阅读器,可在阅读器中浏览 ...

  8. 洛谷【P1886】滑动窗口

    浅谈队列:https://www.cnblogs.com/AKMer/p/10314965.html 题目传送门:https://www.luogu.org/problemnew/show/P1886 ...

  9. bzoj 3907 网格 bzoj2822 [AHOI2012]树屋阶梯——卡特兰数(阶乘高精度模板)

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3907 https://www.lydsy.com/JudgeOnline/problem.p ...

  10. Azure CLI脚本查看未挂载的ManagedDisk

    本文介绍如何用Azure CLI的脚本查看未挂载的Managed Disk,以及Managed Disk挂载到哪些资源. 具体的脚本如下: #!/bin/bash rm -rf noownerdisk ...