beeline 连接hive
HiveServer2是一个能使客户端针对hive执行查询的一种服务,与HiverServer1比较,它能够支持多个客户端的并发请求和授权的;HiveCLI 和 hive –e的方式比较单一,HS2允许远程客户端使用多种语言诸如Java,Python等向Hive提交请求,然后取回结果.
$HIVE_HOME/bin目录下面的hiveserver2
由于配置了环境变量因此可以直接使用
nohup hiveserver2 1>/hiveserver2log/log.txt 2>/hiveserver2log/log.err &
命令中的 1 和 2 的意义分别是:
1:表示标准日志输出
2:表示错误日志输出 如果我没有配置日志的输出路径,日志会生成在当前工作目录,默认的日志名称叫做: nohup.xxx
作为数据仓库的工具,hive提供了两种ETL运行方式,分别是通过Hive 命令行和beeline客户端;
命令行方式即通过hive进入命令模式后通过执行不同的HQL命令得到对应的结果;相当于胖客户端模式,即客户机中需要安装JRE环境和Hive程序。
beeline客户端方式相当于瘦客户端模式,采用JDBC方式借助于Hive Thrift服务访问Hive数据仓库。
$HIVE_HOME/bin目录下面的beeline
由于配置了环境变量因此可以直接使用,使用过程中要指定hive的链接信息,用户名,密码
测试环境无密码
[root@host ~]# beeline
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/root/hive/apache-hive-2.1.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/spark/spark-2.2.0-bin-hadoop2.7/jars/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/hadoop/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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 2.1.1 by Apache Hive
beeline> !connect jdbc:hive2://192.168.53.122:10000/default
Connecting to jdbc:hive2://192.168.53.122:10000/default
Enter username for jdbc:hive2://192.168.53.122:10000/default: root
Enter password for jdbc:hive2://192.168.53.122:10000/default:
Connected to: Apache Hive (version 2.1.1)
Driver: Hive JDBC (version 2.1.1)
18/09/06 16:08:26 [main]: WARN jdbc.HiveConnection: Request to set autoCommit to false; Hive does not support autoCommit=false.
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://192.168.53.122:10000/default> show databases;
+----------------+--+
| database_name |
+----------------+--+
| default |
| gamedw |
| hive_hbase |
| sqoopdb |
| testdb |
| userdb |
+----------------+--+
6 rows selected (0.335 seconds)
0: jdbc:hive2://192.168.53.122:10000/default>
也可以用下面方式:
[root@host ~]# beeline -u jdbc:hive2://192.168.53.122:10000/default -n root
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/root/hive/apache-hive-2.1.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/spark/spark-2.2.0-bin-hadoop2.7/jars/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/hadoop/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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]
Connecting to jdbc:hive2://192.168.53.122:10000/default
Connected to: Apache Hive (version 2.1.1)
Driver: Hive JDBC (version 2.1.1)
18/09/06 16:16:38 [main]: WARN jdbc.HiveConnection: Request to set autoCommit to false; Hive does not support autoCommit=false.
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 2.1.1 by Apache Hive
0: jdbc:hive2://192.168.53.122:10000/default> show databases;
+----------------+--+
| database_name |
+----------------+--+
| default |
| gamedw |
| hive_hbase |
| sqoopdb |
| testdb |
| userdb |
+----------------+--+
6 rows selected (0.178 seconds)
0: jdbc:hive2://192.168.53.122:10000/default>
可以直接通过-u -n-p -e等参数让其执行我们的操作,参数选项:
-u<database URL> 要连接的数据库的URL
-n<username> 指定要连接数据库的用户名
-p<password> 指定要连接数据库的密码
-d<driver class> 使用的驱动名字
-i<init file> 初始化的脚本文件
-e<query> 要执行的查询
-f<exec file> 要执行的脚本文件
-w/--password-file<password file> 从文件读取密码
--hiveconf<key=value> 指定hive配置文件
--hivevarname=value 设置hive变量
--showHeader=[true/false]控制是否在查询结果显示列名
--autoCommit=[true/false]是否自动提交事务
--force=[true/false]运行脚本出错是否继续
--outputformat=[table/vertical/csv2/tsv2/dsv] 指定结果展示的格式
beeline 连接hive的更多相关文章
- beeline连接hive server遭遇MapRedTask (state=08S01,code=1)错误
采用beeline连接hive server是遭遇到如下错误: 5: jdbc:hive2://bluejoe0/default> select * from hive_triples wher ...
- 使用 beeline 连接 hive 数据库报错处理
一.beeline连接hive报错 1. User: root is not allowed to impersonate root (state=08S01,code=0) 在初次搭建完hadoop ...
- 设置beeline连接hive的数据展示格式
问题描述:beeline -u 方式导出数据,结果文件中含有"|"(竖杠). 执行的sql为:beeline -u jdbc:hive2://hadoop1:10000/defau ...
- beeline连接hive
beeline -u jdbc:hive2://192.168.1.77:10000 zeppelin default jdbc: jdbc:hive2://nn01.ooccpp.com:2181/ ...
- 由“Beeline连接HiveServer2后如何使用指定的队列(Yarn)运行Hive SQL语句”引发的一系列思考
背景 我们使用的HiveServer2的版本为0.13.1-cdh5.3.2,目前的任务使用Hive SQL构建,分为两种类型:手动任务(临时分析需求).调度任务(常规分析需求),两者均通过我们的 ...
- sparkSQL元数据缓存不同步 beeline连接的表结构与hive不一致
之前遇到过的坑,通过beeline连接spark thirft server,当在Hive进行表结构修改,如replace/add/change columns后,表结构没有变化,还是旧的表结构,导致 ...
- java使用JDBC连接hive(使用beeline与hiveserver2)
首先虚拟机上已经安装好hive. 下面是连接hive需要的操作. 一.配置. 1.查找虚拟机的ip 输入 ifconfig 2.配置文件 (1)配置hadoop目录下的core-site.xml和hd ...
- Hive 8、Hive2 beeline 和 Hive jdbc
1.Hive2 beeline Beeline 要与HiveServer2配合使用,支持嵌入模式和远程模式 启动beeline 打开两个Shell窗口,一个启动Hive2 一个beeline连接hi ...
- 【原创】大叔问题定位分享(18)beeline连接spark thrift有时会卡住
spark 2.1.1 beeline连接spark thrift之后,执行use database有时会卡住,而use database 在server端对应的是 setCurrentDatabas ...
随机推荐
- webGL之three.js入门4--ThreeJS Editor入门篇
因为工作需要,要看threejs editor的源码,顺便记录过程. github下载的源码目录是这样的 但是editor和其他文件夹内的内容的关联的,我需要将其独立出来并且编辑editor. 进入e ...
- 【nosql】之ehcache.xml文件属性描述
<ehcache updateCheck="false" name="shiroCache"> <defaultCache <!--最大 ...
- 【Maven】从Maven中导出项目依赖的Jar包
从SVN上下载源代码 svn export https://10.200.1.201/xxxx/PLATFORM code/ --force --username xxx --password xxx ...
- AS3面试题 个人理解
现在as3面试 感觉就那几个题目来回考.有了题库,大家都看了 都答上来了 题目本身也就失去了考核的意义.而且题目本身也有很多偏的(不常用的)在考. 真正的面试官现在肯定也不会把笔试成绩当作标准.所谓: ...
- docker entrypoint入口文件详解
docker entrypoint入口文件详解 pasting Dockerfile创建自定义Docker镜像以及CMD与ENTRYPOINT指令的比较 [k8s]args指令案例-彻底理解docke ...
- php的方法
字符串: strlen(): 字符串的个数: . : 通过.来进行字符串的拼接: 数组: count(): 数组的 个数: is_array(): 判断是不是一个数组: 实参的方法: func_num ...
- acl的基本知识点
#ACL acl number 3001 rule 1 deny udp destination-port eq 445 rule 2 deny tcp destination-por ...
- Jmeter(四十二)Jmeter工作原理
“千举万变,其道一也.不离于宗,谓之天人” ----<荀子·儒效>和<庄子·天下> 作为接口测试工具 Jmeter只是作为发起请求的客户端(可以理解为前端),Jmeter是作为 ...
- MySQL 删除重复数据实例
如何删除重复数据 业务场景:删除评论表中对同一订单同一商品的重复评论,只保留最早的一条. 查看是否存在对于同一订单同一商品的重复评论. SELECT order_id,product_id,COUNT ...
- IDEA配置打可运行jar包
IDEA打包可以运行的jar包大体有两种方式:一种是比较方便的配置maven:一种是直接配置IDEA采用Build Artifacts打包. 配置maven打包,在pom.xml里面配置build插件 ...