亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Hive命令操作的示例分析

發布時間:2021-11-08 14:57:48 來源:億速云 閱讀:127 作者:小新 欄目:云計算

這篇文章主要為大家展示了“Hive命令操作的示例分析”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“Hive命令操作的示例分析”這篇文章吧。

1、準備文本文件,啟動hadoop[root@hadoop0 ~]# cat /opt/test.txt
JieJie
MengMeng
NingNing
JingJing
FengJie
[root@hadoop0 ~]# start-all.sh
Warning: $HADOOP_HOME is deprecated.
starting namenode, logging to /opt/hadoop/libexec/../logs/hadoop-root-namenode-hadoop0.out
localhost: starting datanode, logging to /opt/hadoop/libexec/../logs/hadoop-root-datanode-hadoop0.out
localhost: starting secondarynamenode, logging to /opt/hadoop/libexec/../logs/hadoop-root-secondarynamenode-hadoop0.out
starting jobtracker, logging to /opt/hadoop/libexec/../logs/hadoop-root-jobtracker-hadoop0.out
localhost: starting tasktracker, logging to /opt/hadoop/libexec/../logs/hadoop-root-tasktracker-hadoop0.out
2、進入命令行[root@hadoop0 ~]# hive
WARNING: org.apache.hadoop.metrics.jvm.EventCounter is deprecated. Please use org.apache.hadoop.log.metrics.EventCounter in all the log4j.properties files.
Logging initialized using configuration in jar:file:/opt/hive/lib/hive-common-0.9.0.jar!/hive-log4j.properties
Hive history file=/tmp/root/hive_job_log_root_201509252001_1674268419.txt
3、查詢昨天的表hive> select * from stu;
OK
JieJie 26       NULL
MM 24   NULL
Time taken: 17.05 seconds
4、顯示數據庫hive> show databases; 
OK
default
Time taken: 0.237 seconds
5、創建數據庫hive> create database test; 
OK
Time taken: 0.259 seconds
hive> show databases;       
OK
default
test
6、使用數據庫Time taken: 0.119 seconds
hive> use test;
OK
Time taken: 0.03 seconds
7、創建表textfile 默認格式,數據不做壓縮,磁盤開銷大,數據解析開銷大。
可結合Gzip、Bzip2使用(系統自動檢查,執行查詢時自動解壓),但使用這種方式,hive不會對數據進行切分,從而無法對數據進行并行操作。
SequenceFile是Hadoop API提供的一種二進制文件支持,其具有使用方便、可分割、可壓縮的特點。
SequenceFile支持三種壓縮選擇:NONE, RECORD, BLOCK。 Record壓縮率低,一般建議使用BLOCK壓縮
rcfile是一種行列存儲相結合的存儲方式。首先,其將數據按行分塊,保證同一個record在一個塊上,避免讀一個記錄需要讀取多個block。其次,塊數據列式存儲,有利于數據壓縮和快速的列存取。
hive>  create table test1(str STRING)  STORED AS TEXTFILE; 
OK
Time taken: 0.598 seconds
--加載數據
hive> LOAD DATA LOCAL INPATH '/opt/test.txt' INTO TABLE test1; 
Copying data from file:/opt/test.txt
Copying file: file:/opt/test.txt
Loading data to table test.test1
OK
Time taken: 1.657 seconds
hive> select * from test1;
OK
JieJie
MengMeng
NingNing
JingJing
FengJie
Time taken: 0.388 seconds
hive> select count(*) from test1;
Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks determined at compile time: 1
In order to change the average load for a reducer (in bytes):
  set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
  set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
  set mapred.reduce.tasks=<number>
Starting Job = job_201509252000_0001, Tracking URL = http://hadoop0:50030/jobdetails.jsp?jobid=job_201509252000_0001
Kill Command = /opt/hadoop/libexec/../bin/hadoop job  -Dmapred.job.tracker=hadoop0:9001 -kill job_201509252000_0001
Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 1
2015-09-25 20:09:55,796 Stage-1 map = 0%,  reduce = 0%
2015-09-25 20:10:19,806 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 3.67 sec
2015-09-25 20:10:53,218 Stage-1 map = 100%,  reduce = 100%, Cumulative CPU 6.95 sec
2015-09-25 20:10:54,223 Stage-1 map = 100%,  reduce = 100%, Cumulative CPU 6.95 sec
MapReduce Total cumulative CPU time: 6 seconds 950 msec
Ended Job = job_201509252000_0001
MapReduce Jobs Launched:
Job 0: Map: 1  Reduce: 1   Cumulative CPU: 6.95 sec   HDFS Read: 258 HDFS Write: 2 SUCCESS
Total MapReduce CPU Time Spent: 6 seconds 950 msec
OK
5
Time taken: 77.515 seconds


create table test1(str STRING)  STORED AS TEXTFILE; 
create table test2(str STRING) ;
hive> create table test3(str STRING)  STORED AS SEQUENCEFILE;
OK
Time taken: 0.112 seconds
 
hive> create table test4(str STRING)  STORED AS RCFILE; 
OK
Time taken: 0.502 seconds
8、把舊表數據導入新表INSERT OVERWRITE TABLE test4 SELECT * FROM test1;
9、設置hive參數hive> SET hive.exec.compress.output=true; 
hive> SET io.seqfile.compression.type=BLOCK;
10、查看hive參數 hive> SET ; 

以上是“Hive命令操作的示例分析”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

通江县| 金门县| 商洛市| 彰武县| 勃利县| 桦甸市| 堆龙德庆县| 惠州市| 富源县| 辽阳市| 咸丰县| 玛多县| 宁都县| 雷波县| 长子县| 沙洋县| 平利县| 巴里| 渭南市| 万全县| 鲁山县| 贵州省| 康马县| 镇巴县| 平武县| 新宁县| 淳安县| 汪清县| 敖汉旗| 澄城县| 原阳县| 宁夏| 西乌珠穆沁旗| 辛集市| 奎屯市| 平定县| 信宜市| 南陵县| 时尚| 榆社县| 汉川市|