zoukankan      html  css  js  c++  java
  • beeline 连接Hive

    Hive的连接方式:
    1.cli方式
    在bin目录下执行hive,相当于执行的hive --service cli
    2.通过客户端beeline访问hive
    3.还有一种是通过web ui访问
    这里记录的是通过beeline客户端访问

    1.修改hadoop配置文件hdfs-site.xml,表示启用webhdfs
    <property>
    <name>dfs.webhdfs.enabled</name>
    <value>true</value>
    </property>

    2.修改hadoop配置文件core-site.xml,表示设置可访问的用户及用户组
    <property>
    <name>hadoop.proxyuser.root.hosts</name>
    <value>*</value>
    </property>
    <property>
    <name>hadoop.proxyuser.root.groups</name>
    <value>*</value>
    </property>

    将配置文件同步到其他节点
    scp -r hdfs-site.xml node1:$PWD
    scp -r hdfs-site.xml node2:$PWD
    scp -r core-site.xml node1:$PWD
    scp -r core-site.xml node2:$PWD

    3.修改hive的配置文档hive-site.xml
    <property>
    <name>hive.server2.thrift.bind.host</name>
    <value>node1</value>
    <description>Bind host on which to run the HiveServer2 Thrift service.</description>
    </property>

    <property>
    <name>hive.server2.thrift.port</name>
    <value>11000</value>
    <description>Port number of HiveServer2 Thrift interface when hive.server2.transport.mode is 'binary'.</description>
    </property>

    4.重启hadoop
    stop-all.sh
    start-all.sh

    5.启动hiveserver2
    [root@node1 conf]# hiveserver2
    which: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:JAVA_HOME/bin:/home/hadoop-3.2.0/bin:/home/hadoop-3.2.0/sbin:/usr/local/hive-3.1.1/bin:/usr/local/mysql-5.7.26/bin:/root/bin)
    2019-05-24 03:36:40: Starting HiveServer2
    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/usr/local/hive-3.1.1/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/home/hadoop-3.2.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
    Hive Session ID = d64c0a40-4e99-4764-85ef-a1073e143249


    6.在客户端使用beeline访问hive
    [root@node1 conf]# beeline
    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/usr/local/hive-3.1.1/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/home/hadoop-3.2.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
    Beeline version 3.1.1 by Apache Hive


    beeline> !connect jdbc:hive2://node1:11000/testdb
    Connecting to jdbc:hive2://node1:11000/testdb
    Enter username for jdbc:hive2://node1:11000/testdb: root
    Enter password for jdbc:hive2://node1:11000/testdb: ********
    Connected to: Apache Hive (version 3.1.1)
    Driver: Hive JDBC (version 3.1.1)
    Transaction isolation: TRANSACTION_REPEATABLE_READ
    0: jdbc:hive2://node1:11000/testdb>

    查看端口(执行hiveserver2后可能需要等两分钟端口才能查看得到)
    ss -anop|grep 11000

    show tables;
    使用hive sql

  • 相关阅读:
    动词 + to do、动词 + doing
    图像直线检测——霍夫线变换
    x=min(x, y)
    x=min(x, y)
    算法 Tricks(三)—— 数组(序列)任意区间最小(大)值
    算法 Tricks(三)—— 数组(序列)任意区间最小(大)值
    分治法求解切割篱笆
    分治法求解切割篱笆
    GMM的EM算法实现
    秒杀多线程第二篇 多线程第一次亲热接触 CreateThread与_beginthreadex本质差别
  • 原文地址:https://www.cnblogs.com/pashanhu/p/10950303.html
Copyright © 2011-2022 走看看