HiveServer2的配置使用

php中文网
发布: 2016-06-07 15:37:46
原创
1627人浏览过

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 /

hiveserver2的配置和使用

hive-site.xml配置

hiveserver2的配置

property>

    name>hive.support.concurrencyname>

    description>Enable Hive's TableLock Manager Servicedescription>

    value>truevalue>

property>

property>

    name>hive.zookeeper.quorumname>

    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.hostname>

    value>172.21.3.170value>

    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.urisname>

  value>thrift://172.21.1.56:9083value>

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

property>

property>

  name>hive.metastore.localname>

  value>falsevalue>

  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&

 

Gnomic智能体平台
Gnomic智能体平台

国内首家无需魔法免费无限制使用的ChatGPT4.0,网站内设置了大量智能体供大家免费使用,还有五款语言大模型供大家免费使用~

Gnomic智能体平台 156
查看详情 Gnomic智能体平台

启动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();

   }

 

}

 

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号