Hadoop的相關(guān)資料

1 HDFS

創(chuàng)新互聯(lián)建站專業(yè)為企業(yè)提供信宜網(wǎng)站建設(shè)、信宜做網(wǎng)站、信宜網(wǎng)站設(shè)計、信宜網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、信宜企業(yè)網(wǎng)站模板建站服務(wù),十年信宜做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。

1.1 概念

Hadoop分布式文件系統(tǒng)(HDFS)被設(shè)計成適合運行在通用硬件(commodity hardware)上的分布式文件系統(tǒng)

1.2 特點

- 高度容錯性

- 硬件要求低

- 能提供高吞吐量的數(shù)據(jù)訪問

1.3 文件系統(tǒng)命令行

1.3.1 獲取幫助

hadoop fs -help

1.3.2 ls命令

hadoop fs -ls /
hadoop fs -ls -R /user

1.3.3 getconf命令

 hdfs getconf -help
hdfs getconf -namenodes

1.3.4 版本信息

hdfs version

注:由于與linux系統(tǒng)指令用法接近,詳細(xì)請參閱文后的官方鏈接。

2 MapReduce

2.1 MapReduce的簡介

MapReduce是一種編程模型,用于大規(guī)模數(shù)據(jù)集(大于1TB)的并行運算。

2.2 工作原理

假若一個盤子中有黑豆、黃豆、綠豆、紅豆,你現(xiàn)在想挑出其中的紅豆。

MapReduce方法則是:

step1 找一個團隊來處理(相當(dāng)于一群服務(wù)器組成的集群)

step2 把豆子平均分配給團隊里的每成員(相當(dāng)于給群集中的服務(wù)器分配數(shù)據(jù))

step3 讓團隊的成員開始挑選出其中的紅豆(相當(dāng)于群集的計算機并行地處理數(shù)據(jù))

step4 把團隊成員挑出來的豆子匯聚(相當(dāng)于群集匯總并輸出結(jié)果)

3 Hive

3.1 Hive的簡介

3.1.1 概念

Hive是一個基于Hadoop的數(shù)據(jù)倉庫平臺。

3.1.2 Hive的作用

通過hive,我們可以方便地進行ETL的工作

hive定義了一個類似于SQL的查詢語言

HQL能夠?qū)⒂脩艟帉懙腝L轉(zhuǎn)化為相應(yīng)的Mapreduce程序基于Hadoop執(zhí)行

3.1.3 Hive項目的歷史

Hive是Facebook 2008年8月剛開源的一個數(shù)據(jù)倉庫框架,其系統(tǒng)目標(biāo)與Pig有相似之處,但它有一些Pig目前還不支持的機制。

比如:更豐富的類型系統(tǒng)、更類似SQL的查詢語言、Table/Partition元數(shù)據(jù)的持久化等。

4 impala

4.1 Impala的簡介

Impala 是 Cloudera 在受到 Google 的 Dremel 啟發(fā)下開發(fā)的實時交互 SQL 大數(shù)據(jù)查詢工具,Impala 沒有再使用緩慢的 Hive+MapReduce 批處理,而是通過使用與商用并行關(guān)系數(shù)據(jù)庫中類似的分布式查詢引擎(由 Query Planner、Query Coordinator 和 Query Exec Engine 三部分組成),可以直接從 HDFS 或 HBase 中用 SELECT、JOIN 和統(tǒng)計函數(shù)查詢數(shù)據(jù),從而大大降低了延遲。

4.2 Impala的shell

4.2.1 啟動shell

impala-shell

4.2.2 版本查詢

select version();

4.3 庫的操作

4.3.1 查詢數(shù)據(jù)庫

show databases;

4.3.2 創(chuàng)建數(shù)據(jù)庫

create database testdb;
create database testdb2;

數(shù)據(jù)庫存儲路徑:

hdfs dfs -ls /user/hive/warehouse/

4.3.3 使用數(shù)據(jù)庫

use testdb;

4.3.4 顯示當(dāng)前數(shù)據(jù)庫

select current_database();

4.3.5 刪除數(shù)據(jù)庫

drop database testdb;

4.4 表操

4.4.1 創(chuàng)建表

create table t1 (x int);
create table t3 (id int, word string);
create table city (id int,name string,countrycode string,district string,population int);

4.4.2 顯示數(shù)據(jù)庫中的表

show tables;
show tables in testdb;
show tables in testdb like 't*';

4.4.3 表結(jié)構(gòu)描述

 describe city;

4.4.4 修改表名稱

alter table t3 rename to t2;

4.4.5 插入數(shù)據(jù)

insert into t1 values (1),(3),(2),(4);
insert into t2 values (1, "one"), (3, "three"), (5, 'five');

4.4.6 數(shù)據(jù)查詢

select min(x), max(x), sum(x), avg(x) from t1;
select word from t1 join t2 on (t1.x = t2.id);

5 sentry

5.1 開啟權(quán)限

5.1.1 開啟權(quán)限

Hive/Impala > Configuration > Service-Wide > Sentry Service > 選擇“sentry”

5.1.2 指定認(rèn)證服務(wù)器

Hive > Configuration > Service-Wide > Advanced > Server Name for Sentry Authorization(hive.sentry.server) > 填寫sentry服務(wù)器名稱或IP地址

5.1.3 設(shè)置特權(quán)用戶

Hive > Configuration > Service-Wide > Security > Bypass Sentry Authorization Users(sentry.metastore.service.users) > 填寫繞過的linux用戶名(hive,impala,hue,hdfs等)

5.1.4 配置Hive的代理用戶

HDFS > Configuration > Service-Wide > Proxy > Hive Proxy User Groups(hadoop.proxyuser.hive.groups) > 填寫代理的linux用戶名(hive,impala,hue,hdfs等)

5.1.5 重啟服務(wù)

重啟Hive/Impala的服務(wù)

5.2 授權(quán)

5.2.1 創(chuàng)建數(shù)據(jù)庫用戶和組

groupadd gp1
useradd user1 -G gp1
useradd user2 -G gp1

5.2.2 切換執(zhí)行用

su - impala

5.2.3 創(chuàng)建數(shù)據(jù)庫

切換到hive shell

hive

新建庫

create database testdb;

退出hive shell

quit;

5.2.4 創(chuàng)建角色

切換到impala shell

impala-shell

創(chuàng)建角色

create role ro1;

5.2.5 確認(rèn)創(chuàng)建的角色

show roles;

5.2.6 用戶組和角色的關(guān)聯(lián)

grant role ro1 to group gp1;

5.2.7 角色授權(quán)

grant all on database testdb to role ro1;

參閱資料:

==================================================

Docs:

----------------

http://hadoop.apache.org/docs/current/

Hadoop Common Guide:

---------------------

http://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HDFSCommands.html

File System Shell Guide:

http://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/FileSystemShell.html#Overview

MapReduce Common Guide:

------------------------

http://hadoop.apache.org/docs/current/hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapredCommands.html

Hive Docs

-------------------------

http://hive.apache.org

LanguageManual:

https://cwiki.apache.org/confluence/display/Hive/LanguageManual

GettingStarted:

https://cwiki.apache.org/confluence/display/Hive/GettingStarted

User Documentation:

https://cwiki.apache.org/confluence/display/Hive/Home#Home-UserDocumentation

Impala Docs

--------------------------

Impala SQL

http://www.cloudera.com/documentation/enterprise/5-6-x/topics/impala_langref_sql.html#langref_sql

Impala Tutorials

http://www.cloudera.com/documentation/enterprise/latest/topics/impala_tutorial.html

Impala Explore

http://www.cloudera.com/documentation/enterprise/latest/topics/impala_tutorial.html#tutorial_explore

Sentry Docs

----------------------------------

Overview of Impala Security

http://www.cloudera.com/documentation/enterprise/5-7-x/topics/impala_security.html#security

Enabling Sentry Authorization for Impala

http://www.cloudera.com/documentation/enterprise/5-7-x/topics/impala_authorization.html#authorization

Impala Grant

http://www.cloudera.com/documentation/enterprise/5-6-x/topics/impala_grant.html#grant

Hive Grant

http://www.cloudera.com/documentation/enterprise/5-6-x/topics/sg_hive_sql.html#concept_c2q_4qx_p4__col_level_auth_sentry

Disabling Hive CLI

http://www.cloudera.com/documentation/enterprise/5-6-x/topics/sg_sentry_overview.html

======================================

其他參考:

======================================

ETL的概念:

----------

http://www.cnblogs.com/elaron/archive/2012/04/09/2438372.html

Apache Sentry架構(gòu)介紹

http://blog.javachen.com/2015/04/29/apache-sentry-architecture.html

啟用Kerberos認(rèn)證

http://www.cloudera.com/documentation/enterprise/latest/topics/cm_sg_intro_kerb.html#xd_583c10bfdbd326ba--6eed2fb8-14349d04bee--76dd

Impala的架構(gòu)介紹

http://www.mutouxiaogui.cn/blog/?p=319

本文標(biāo)題:Hadoop的相關(guān)資料
網(wǎng)頁網(wǎng)址:http://bm7419.com/article22/igohjc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、網(wǎng)站設(shè)計、App開發(fā)網(wǎng)站策劃、網(wǎng)站制作、手機網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司