《ProgrammingHive》阅读笔记-第二章
书本第二章的一些知识点,在cloudera-quickstart-vm-5.8.0-0上进行操作。
- 配置文件
配置在/etc/hive/conf/hive-site.xml文件里面,采用mysql作为metastore。"hive.metastore.warehouse.dir"这个属性没有在文件中进行配置,因此采用默认值/user/hive/warehouse作为Hive的默认路径。
[cloudera@quickstart ~]$ hdfs dfs -ls /user/hive/warehouse
Found 9 items
drwxrwxrwx - cloudera supergroup 0 2016-08-27 02:34 /user/hive/warehouse/categories
drwxrwxrwx - cloudera supergroup 0 2016-08-27 02:37 /user/hive/warehouse/customers
drwxrwxrwx - cloudera supergroup 0 2016-08-27 02:39 /user/hive/warehouse/departments
drwxrwxrwx - cloudera supergroup 0 2016-08-27 02:42 /user/hive/warehouse/order_items
drwxrwxrwx - cloudera supergroup 0 2016-08-27 02:44 /user/hive/warehouse/orders
drwxr-xr-x - hdfs supergroup 0 2016-12-27 00:34 /user/hive/warehouse/original_access_logs
drwxrwxrwx - cloudera supergroup 0 2016-08-27 02:46 /user/hive/warehouse/products
drwxrwxrwx - cloudera supergroup 0 2016-12-27 05:52 /user/hive/warehouse/tokenized_access_logs
drwxrwxrwx - cloudera supergroup 0 2016-09-04 02:09 /user/hive/warehouse/userinfo
进入CLI
$ hive
使用set可以查看配置信息hive> set;临时变量赋值和查看
hive> set foo;
foo=bar
hive> set hivevar:foo
> ;
hivevar:foo=bar
define的变量只在当前会话有效,define中赋值的变量在hivevar命名空间。
- hiveconf命名空间变量
[cloudera@quickstart ~]$ hive --hiveconf hive.cli.print.current.db=true
Logging initialized using configuration in file:/etc/hive/conf.dist/hive-log4j.properties
WARNING: Hive CLI is deprecated and migration to Beeline is recommended.
hive (default)> set hiveconf:hive.cli.print.current.db=false;
hive> set hiveconf:hive.cli.print.current.db=true;
hive (default)>
同时,我们也可以在hiveconf中增加新的变量。
[cloudera@quickstart ~]$ hive --hiveconf y=5
Logging initialized using configuration in file:/etc/hive/conf.dist/hive-log4j.properties
WARNING: Hive CLI is deprecated and migration to Beeline is recommended.
hive> set y;
y=5
- system命名空间
用于访问Java系统属性,system命名空间下的变量也可以读写。
hive> set system:user.name;
system:user.name=cloudera
hive> set system:user.name=camash
> ;
hive> set system:user.name;
system:user.name=camash
hive> set env:HOMJE;
env:HOME=/home/cloudera
- 获得所有定义的表
hive> show tables like '*';
OK
categories
customers
departments
intermediate_access_logs
order_items
orders
products
tokenized_access_logs
userinfo
Time taken: 0.065 seconds, Fetched: 9 row(s)
- 单次执行hive命令
在shell中单次执行,打印结果在shell窗口。
[cloudera@quickstart ~]$ hive -e "select * from userinfo limit 3";
Logging initialized using configuration in file:/etc/hive/conf.dist/hive-log4j.properties
OK
root x 0 0 root /root /bin/bash
bin x 1 1 bin /bin /sbin/nologin
daemon x 2 2 daemon /sbin /sbin/nologin
Time taken: 2.049 seconds, Fetched: 3 row(s)
使用-S命令减少查询过程信息,从而可以将查询结果放至文件。
[cloudera@quickstart ~]$ hive -S -e "select * from userinfo limit 3"; > /tmp/myquery
[cloudera@quickstart ~]$ cat /tmp/myquery
同时方便执行set命令
[cloudera@quickstart ~]$ hive -S -e "set" | grep warehouse
hive.metastore.warehouse.dir=/user/hive/warehouse
hive.warehouse.subdir.inherit.perms=true
- 从文件中执行
第一种方式使用hive -f命令,第二种方式hive对话框中使用source命令。
[cloudera@quickstart ~]$ hive -f filequery.hql
Logging initialized using configuration in file:/etc/hive/conf.dist/hive-log4j.properties
OK
root x 0 0 root /root /bin/bash
bin x 1 1 bin /bin /sbin/nologin
daemon x 2 2 daemon /sbin /sbin/nologin
Time taken: 2.504 seconds, Fetched: 3 row(s)
[cloudera@quickstart ~]$ cat filequery.hql
select * from userinfo limit 3;
hive> source /home/cloudera/filequery.shql
> ;
OK
root x 0 0 root /root /bin/bash
bin x 1 1 bin /bin /sbin/nologin
daemon x 2 2 daemon /sbin /sbin/nologin
Time taken: 1.648 seconds, Fetched: 3 row(s)
- 在hive会话中执行shell命令
hive> ! pwd
> ;
/home/cloudera
《ProgrammingHive》阅读笔记-第二章的更多相关文章
- 深入理解 C 指针阅读笔记 -- 第二章
Chapter2.h #ifndef __CHAPTER_2_ #define __CHAPTER_2_ /*<深入理解C指针>学习笔记 -- 第二章*/ /* 内存泄露的两种形式 1.忘 ...
- 《图解HTTP》阅读笔记--第二章 简单的HTTP协议--第三章 HTTP报文信息
第二章.简单的HTTP协议HTTP协议:HTTP协议用于客户端(请求资源的一端)和服务器端(响应回复提供资源的一端)的通信,是一种无状态协议HTTP1.1默认TCP持久连接,管线化发送(并行发送多个 ...
- 《Interest Rate Risk Modeling》阅读笔记——第二章:债券价格、久期与凸性
目录 第二章:债券价格.久期与凸性 思维导图 瞬时回报率-收益率的例子 第二章:债券价格.久期与凸性 思维导图 瞬时回报率-收益率的例子
- Redis实战阅读笔记——第二章
在性能的要求下,如何获取重构之前的构件
- Redis实战阅读笔记——第二章(redis重构web)
在性能的要求下,如何用redis重构已有的已有的部分,其实整个例子背后的思路挺好的.在应用缓存的过程中,还有一指标个需要考虑,读写比.
- Android群英传笔记——第二章:Android开发工具新接触
Android群英传笔记--第二章:Android开发工具新接触 其实这一章并没什么可讲的,前面的安装Android studio的我们可以直接跳过,如果有兴趣的,可以去看看Google主推-Andr ...
- 《DOM Scripting》学习笔记-——第二章 js语法
<Dom Scripting>学习笔记 第二章 Javascript语法 本章内容: 1.语句. 2.变量和数组. 3.运算符. 4.条件语句和循环语句. 5.函数和对象. 语句(stat ...
- The Road to learn React书籍学习笔记(第二章)
The Road to learn React书籍学习笔记(第二章) 组件的内部状态 组件的内部状态也称为局部状态,允许保存.修改和删除在组件内部的属性,使用ES6类组件可以在构造函数中初始化组件的状 ...
- [HeadFrist-HTMLCSS学习笔记]第二章深入了解超文本:认识HTML中的“HT”
[HeadFrist-HTMLCSS学习笔记]第二章深入了解超文本:认识HTML中的"HT" 敲黑板!!! 创建HTML超链接 <a>链接文本(此处会有下划线,可以单击 ...
随机推荐
- Linux 默认线程栈大小 调优
Linux 线程栈介绍 栈,就是那些由编译器在需要的时候分配,在不需要的时候自动清除的变量的存储区.里面的变量通常是局部变量.函数参数等:和堆相比,栈通常很小. Linux 查询线程栈 1.查看默认的 ...
- 使用docker部署ambari的若干要点
ambari部署各个组件 使用ambari进行部署时主要需要的组件包括: ambari-server: 主要部署的控制节点,负责控制agent进行部署. mysql: server存储的数据库.也支持 ...
- Servlet运行原理以及生命周期
一.Servlet生命周期: Servlet加载.实例化.初始化.服务.销毁. 1.初始化init(): 当服务启动时,Servlet被装入tomcat或者其他服务器容器时执行(服务器容器从启动到停止 ...
- FSMC_LCD
1. TFT-LCD(Thin Film Transistor Liquid Crystal Display)[薄膜晶体管液晶显示器] 2. 液晶 物质在熔融状态或在溶液状态下虽然获得了液体物质的流动 ...
- 如何恢复IIS出厂默认设置
How to restore IIS settings and Default Web Site? http://superuser.com/questions/704850/how-to-resto ...
- Git,Github和Gitlab简介和使用方法
什么是Git Git是一个版本控制系统(Version Control System,VCS). 版本控制是一种记录一个或若干文件内容变化,以便将来查阅特定版本修订情况的系统. 多年前,我在法国做第一 ...
- MapReduce :基于 FileInputFormat 的 mapper 数量控制
本篇分两部分,第一部分分析使用 java 提交 mapreduce 任务时对 mapper 数量的控制,第二部分分析使用 streaming 形式提交 mapreduce 任务时对 mapper 数量 ...
- vue--实例化对象
根目录下的文件,这些是创建vue项目时生成的配置文件 node_modules=> 里面的文件是项目开发过种中的各种依赖,我们暂且不用去深入了解: public=> 主要放的是一些公用的文 ...
- GoEasy的使用
GoEasy介绍 http请求短连接,一次请求响应后关闭,而GoEasy建立了客户端与服务器之间的长连接. goeasy支持服务器到客户端的消息发布,客户端到客户端的消息发布 GoEasy用来做什么 ...
- python画箱线图
# -*- coding: utf-8 -*- """ Created on Wed Jun 14 13:00:11 2017 @author: Miao "& ...