1.
hive
(1) 資料倉儲
hive的本質其實就相當於將hdfs中已經儲存的檔案在mysql中做了乙個雙射關係,以方便使用hql去管理查詢。
(2) 用於資料分析、清洗
hive適用於離線的資料分析和清洗,延遲較高。
(3) 基於hdfs、mapreduce
hive儲存的資料依舊在datanode上,編寫的hql語句終將是轉換為mapreduce**執行。
2.
hbase
(1) 資料庫
是一種面向列族儲存的非關係型資料庫。
(2) 用於儲存結構化和非結構化的資料
適用於單錶非關係型資料的儲存,不適合做關聯查詢,類似join等操作。
(3) 基於hdfs
資料持久化儲存的體現形式是hfile,存放於datanode中,被resionserver以region的形式進行管理。
面對大量的企業資料,hbase可以直線單錶大量資料的儲存,同時提供了高效的資料訪問速度。
環境準備
因為我們後續可能會在操作hive的同時對hbase也會產生影響,所以hive需要持有操作hbase的jar,那麼接下來拷貝hive所依賴的jar包(或者使用軟連線的形式)。
export hbase_home=/opt/module/hbase
export hive_home
=/opt/module/
hive
ln -s $hbase_home/lib/hbase-common-
1.3.1.jar $hive_home/lib/hbase-common-
1.3.1
.jar
ln -s $hbase_home/lib/hbase-server-
1.3.1.jar $hive_home/lib/hbase-server-
1.3.1
.jar
ln -s $hbase_home/lib/hbase-client-
1.3.1.jar $hive_home/lib/hbase-client-
1.3.1
.jar
ln -s $hbase_home/lib/hbase-protocol-
1.3.1.jar $hive_home/lib/hbase-protocol-
1.3.1
.jar
ln -s $hbase_home/lib/hbase-it-
1.3.1.jar $hive_home/lib/hbase-it-
1.3.1
.jar
ln -s $hbase_home/lib/htrace-core-
3.1.0
-incubating.jar $hive_home/lib/htrace-core-
3.1.0
-incubating.jar
ln -s $hbase_home/lib/hbase-hadoop2-compat-
1.3.1.jar $hive_home/lib/hbase-hadoop2-compat-
1.3.1
.jar
ln -s $hbase_home/lib/hbase-hadoop-compat-
1.3.1.jar $hive_home/lib/hbase-hadoop-compat-
1.3.1.jar
同時在hive-site.xml中修改zookeeper的屬性,如下:
<property
>
<
name
>hive.zookeeper.quorum
name
>
<
value
>hadoop102,hadoop103,hadoop104
value
>
<
description
>the list of zookeeper servers to talk to. this is only needed for read/write locks.
description
>
property
>
<
property
>
<
name
>hive.zookeeper.client.port
name
>
<
value
>2181
value
>
<
description
>the port of zookeeper servers to talk to. this is only needed for read/write locks.
description
>
property
>
1.案例一
目標:建立hive表,關聯hbase表,插入資料到hive表的同時能夠影響hbase表。
分步實現:
(1) 在hive中建立表同時關聯hbase
createtable
hive_hbase_emp_table(
empno
int,
ename string,
job string,
mgr
int,
hiredate string,
sal
double
,comm
double
,deptno
int)
stored by'
org.apache.hadoop.hive.hbase.hbasestoragehandler
',info:ename,info:job,info:mgr,info:hiredate,info:sal,info:comm,info:deptno")
tblproperties ("hbase.
table.name" = "hbase_emp_table");
完成之後,可以分別進入hive和hbase檢視,都生成了對應的表
(2) 在hive中建立臨時中間表,用於load檔案中的資料
createtable
emp(
empno
int,
ename string,
job string,
mgr
int,
hiredate string,
sal
double
,comm
double
,deptno
int)
row format delimited fields terminated by'
\t';
(3) 向hive中間表中load資料
hive>load data local inpath '
/home/admin/softwares/data/emp.txt
'into
table emp;
(4) 通過insert命令將中間表中的資料匯入到hive關聯hbase的那張表中
hive>insert
into
table hive_hbase_emp_table select
*from emp;
(5) 檢視hive以及關聯的hbase表中是否已經成功的同步插入了資料
hive:
hive>select
*from hive_hbase_emp_table;
hbase:
hbase> scan 『hbase_emp_table』
2.案例二
目標:在hbase中已經儲存了某一張表hbase_emp_table,然後在hive中建立乙個外部表來關聯hbase中的hbase_emp_table這張表,使之可以借助hive來分析hbase這張表中的資料。
注:該案例2緊跟案例1的腳步,所以完成此案例前,請先完成案例1。
分步實現:
(1) 在hive中建立外部表
create external tablerelevance_hbase_emp(
empno
int,
ename string,
job string,
mgr
int,
hiredate string,
sal
double
,comm
double
,deptno
int)
stored by'
org.apache.hadoop.hive.hbase.hbasestoragehandler'":
key,info:ename,info:job,info:mgr,info:hiredate,info:sal,info:comm,info:deptno")
tblproperties ("hbase.
table.name" = "hbase_emp_table");
(2) 關聯後就可以使用hive函式進行一些分析操作了
hive (default)>select
*from relevance_hbase_emp;
實驗6 整合測試
1 掌握整合測試的原理和方法。2 掌握樁和驅動程式的編寫方法。3 能夠對軟體進行整合測試。1 自編軟體的整合測試 1 由給定軟體規格說明書寫出源程式並執行。見附錄 2 任選一種整合測試方法產生測試用例 對每個測試會話設計乙個正常值測試用例即可 3 執行軟體,輸入測試用例並記錄結果。4 分析結果,除錯...
Lua5整合指南 1
第一章先開個頭 看不明白的話也不要緊,下一章將從怎麼編譯介紹起。源 閱讀貴在堅持,當然有乙個好工具也是必要的。推薦大家使用source insight 這是乙個非常好用的東西。不管是閱讀還是寫c c c 的 使用它都會感覺非常爽!今天開始閱讀,因為是開頭,所以選擇乙個簡單的檔案 etc min.c ...
struts1整合ajax技術
1.寫乙個繼承actionservlet的類a。在該類a中重寫httpservlet的service方法,然後呼叫actionservlet中的process方法,然後從requst中得到要返回給前台的值value,如果不為空,則用response.getwriter print value 2.修...