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 ...
随机推荐
- Azure PowerShell (15) 批量导出Azure ASM/ARM VM信息
<Windows Azure Platform 系列文章目录> 客户又提出新的需求,需要知道所有订阅下的虚拟机数量.运行情况等信息. 我花了点时间,写了一个PowerShell脚本,发布到 ...
- CheckFail设计很垃圾
function checkFail(node, onError, fuckIE) { var id = node.src;//检测是否死链 node.onlo ...
- QT建立简单的计时器程序
1.创建一个窗口项目 2.拖一个lcd控件命名lcdNumber,两个pushbutton,分别命名pbStart与pbEnd 3.mainWindow.h添加以下代码 private slots: ...
- 黄聪:VS2017调试时提示“运行时无法计算表达式的值”
具体操作: 工具-选项-调试-常规,选中“使用托管兼容模式”,问题解决
- IDEA运行tomcat8.5.35源代码
前提环境,安装和配置好java1.8+环境,maven,IDEA 1.下载Tomcat源代码:https://tomcat.apache.org/download-80.cgi#8.5.35 2.创建 ...
- SpringSecurity-ChannelProcessingFilter的作用
ChannelProcessingFilter决定的是web请求的通道,即http或https. 在springsecurity配置文件中添加这样一行 <intercept-url patter ...
- PyQt—QTableWidget中的checkBox状态判断
一.QTableWidget实现checkBox效果 利用QTableWidgetItem对象的CheckState属性,既能显示QCheckBox,又能读取状态 table = QtGui.QTab ...
- code block自动生成makefile
安装插件 http://developer.berlios.de/projects/cbmakegen/ 然后会在project菜单下面有一个Generate Makefile的选项 点击就行了 如 ...
- [转]SuperSocket
public class SocketServer : AppServer<AppSession> { public SocketServer() : base(new DefaultRe ...
- 非ECS阿里云安装插件,给阿里云云监控平台
linux的init学习: https://blog.csdn.net/kunkliu/article/details/80942279 阿里云官方文档: https://help.aliyun.co ...