Hive系列 二 Hive基本環境安裝

2021-08-20 08:21:06 字數 2233 閱讀 9368

由於之前的hadoop集群是用docker搭建的,所以後面整個大資料環境,本人都會採用docker構建,hive環境安裝需在之前的hadoop基礎上構建,參考文章如下:

hadoop系列(一)docker部署hadoop集群

啟動docker,執行之前儲存的hadoop映象,進入容器內部,再按下面操作部署hive環境。

注意:docker容器重啟時,預設的網路模式bridge會給容器重新分配ip,所以容器ip和/etc/hosts都被重置了,需要重新繫結ip,重新配置hosts。

(1)把apache-hive-1.2.2-bin.tar.gz上傳到linux的/opt/software目錄下

(2)解壓apache-hive-1.2.2-bin.tar.gz到/opt/module/目錄下面

tar -zxvf apache-hive

-1.2

.2-bin

.tar.gz -c /opt/module/

(3)修改apache-hive-1.2.2-bin/的名稱為hive(非必要)

mv apache-hive

-1.2

.2-bin

/ hive

(4)修改/opt/module/hive/conf目錄下的hive-env.sh.template名稱為hive-env.sh

mv hive-env.sh

.template hive-env.sh

(5)配置hive-env.sh檔案

(a)配置hadoop_home路徑

export hadoop_home=/opt/module/hadoop-2.7.3
(b)配置hive_conf_dir路徑

export hive_conf_dir=/opt/module

/hive/conf

(1)必須啟動hdfs和yarn

start-dfs.sh

start-yarn.sh

(2)在hdfs上建立/tmp和/user/hive/warehouse兩個目錄並修改他們的同組許可權可寫(非必要)

hadoop fs -mkdir /tmp

hadoop fs -mkdir

-p /user/hive/warehouse

(1)啟動hive

bin/hive
(2)檢視資料庫

hive>show databases;
(3)開啟預設資料庫

hive>use

default;

(4)顯示default資料庫中的表

hive>show tables;
(5)建立一張表

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;
以上就是乙個基本的hive環境安裝,不過這裡hive環境中的metastore預設儲存在自帶的derby資料庫中,推薦使用mysql儲存metastore,後面會繼續介紹安裝mysql來儲存metastore;

Hive基本操作(二)

alter table table name add if not exists partition spec location location1 partition spec location location2 partition spec partition partition col pa...

Hive學習系列 二 Hive的查詢流程詳解

此文為翻譯的文件,英文連線為 hive 查詢流程圖如下 圖中可以看出查詢主要元件包含 執行流程詳細解析 1 step 1 ui user inte ce 呼叫的 driver 的execute介面 2 step 2 driver為查詢建立會話控制代碼,並將查詢傳送給 compiler以生成執行計畫,...

搭建hive環境

搭建好hadoop環境後開始搭建hive環境。搭建hive過程中也遇到了很多坑,所以記錄下來。上傳hive到伺服器之後,要配置環境變數,需要涉及到三個地方。由於照著搭建的教程中只讓改了兩個,導致沒有啟動成功。需要配置的檔案分別是 hive conf hive env.sh hive conf hiv...