尚硅谷大數據技術之Hive(新)第1章 Hive入門
第2章?Hive安裝
2.1?Hive安裝地址
1.Hive官網地址
http://hive.apache.org/
2.文檔查看地址
https://cwiki.apache.org/confluence/display/Hive/GettingStarted
3.下載地址
http://archive.apache.org/dist/hive/
4.github地址
https://github.com/apache/hive
2.2 Hive安裝部署
1.Hive安裝及配置
(1)把apache-hive-1.2.1-bin.tar.gz上傳到linux的/opt/software目錄下
(2)解壓apache-hive-1.2.1-bin.tar.gz到/opt/module/目錄下面
[atguigu@hadoop102 software]$ tar -zxvf apache-hive-1.2.1-bin.tar.gz -C /opt/module/
(3)修改apache-hive-1.2.1-bin.tar.gz的名稱為hive
[atguigu@hadoop102 module]$ mv apache-hive-1.2.1-bin/ hive
(4)修改/opt/module/hive/conf目錄下的hive-env.sh.template名稱為hive-env.sh
[atguigu@hadoop102 conf]$ mv hive-env.sh.template hive-env.sh
(5)配置hive-env.sh文件
(a)配置HADOOP_HOME路徑
export HADOOP_HOME=/opt/module/hadoop-2.7.2
(b)配置HIVE_CONF_DIR路徑
export HIVE_CONF_DIR=/opt/module/hive/conf
2.Hadoop集群配置
(1)必須啟動hdfs和yarn
[atguigu@hadoop102 hadoop-2.7.2]$ sbin/start-dfs.sh
[atguigu@hadoop103 hadoop-2.7.2]$ sbin/start-yarn.sh
(2)在HDFS上創建/tmp和/user/hive/warehouse兩個目錄并修改他們的同組權限可寫
[atguigu@hadoop102 hadoop-2.7.2]$ bin/hadoop fs -mkdir /tmp
[atguigu@hadoop102 hadoop-2.7.2]$ bin/hadoop fs -mkdir -p /user/hive/warehouse
[atguigu@hadoop102 hadoop-2.7.2]$ bin/hadoop fs -chmod g+w /tmp
[atguigu@hadoop102 hadoop-2.7.2]$ bin/hadoop fs -chmod g+w /user/hive/warehouse
3.Hive基本操作
(1)啟動hive
[atguigu@hadoop102 hive]$ bin/hive
(2)查看數據庫
hive>?show databases;
(3)打開默認數據庫
hive>?use default;
(4)顯示default數據庫中的表
hive>?show tables;
(5)創建一張表
hive> create table student(id int, name string);
(6)顯示數據庫中有幾張表
hive>?show tables;
(7)查看表的結構
hive>?desc student;
(8)向表中插入數據
hive> insert into student values(1000,"ss");
(9)查詢表中數據
hive> select * from student;
(10)退出hive
hive> quit;