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. LNMP安装及配置

    LNMP官方网站:http://lnmp.org http://oneinstack.com/install/ 安装详细介绍:http://lnmp.org/install.html 1,安装LNMP ...

  2. CodeForces - 687D: Dividing Kingdom II (二分图&带权并查集)

    Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great ...

  3. WPF之X名称空间学习

    WPF的X名称空间都有什么呢?首先,盗用张图来说明: 我将就图表中的内容进行总结: 1.x:Array具有一个Iteams属性,它能暴漏一个ArratList实例,ArratList实例的内部成员类型 ...

  4. 《Javascript高级程序设计》阅读记录(四):第五章 下

    这个系列,我会把阅读<Javascript高级程序设计>之后,感觉讲的比较深入,而且实际使用价值较大的内容记录下来,并且注释上我的一些想法.做这个一方面是提升了我的阅读效果以及方便我以后阅 ...

  5. Unity3D for Android 纹理压缩支持

    http://blog.csdn.net/asd237241291/article/details/48548557 首先附图:Unity3D for Android支持的纹理压缩格式 纹理压缩可以通 ...

  6. 【转】深入剖析Java中的装箱和拆箱

    深入剖析Java中的装箱和拆箱 自动装箱和拆箱问题是Java中一个老生常谈的问题了,今天我们就来一些看一下装箱和拆箱中的若干问题.本文先讲述装箱和拆箱最基本的东西,再来看一下面试笔试中经常遇到的与装箱 ...

  7. [转]A记录和CNAME记录的区别

    1.什么是域名解析? 域名解析就是国际域名或者国内域名以及中文域名等域名申请后做的到IP地址的转换过程.IP地址是网路上标识您站点的数字地址,为了简单好记,采用域名来代替ip地址标识站点地址.域名的解 ...

  8. centos下wget: command not found的解决方法

    今天给服务器安装新LNMP环境时,wget 时提示 -bash:wget command not found,很明显没有安装wget软件包.一般linux最小化安装时,wget不会默认被安装,这里是C ...

  9. navicat链接远程数据库

    1.之前使用的是常规的连接方式 学习源头: https://jingyan.baidu.com/article/0aa2237573c1e688cc0d6427.html 这里的ip地址是服务器的ip ...

  10. Spring 与 MyBatis 的整合

    本文讨论 Spring 与 MyBatis 的整合. 在 beans.xml 中我们定义了两个 bean: SqlSessionFactoryBean.SqlSessionTemplate. 1.Sq ...