More Related Content
Similar to HDInsight for Hadoopers (20)
HDInsight for Hadoopers
- 2. Agenda
HDInsight 是 Microsoft 在 Azure 上頭提供的 Hadoop 服務,讓以往繁瑣的 Hadoop
Cluster 設定,變成只是幾個簡單的精靈頁面操作。Hadoop 的 HDFS 分散式檔案系
統,跟 Azure 的 Storage 整合在一起,MapReduce 應用程式則是直接丟到 Cluster 內的
各個 Windows Server 虛擬機器上面執行。這個 Session 主要就是帶領大家在 Microsoft
Azure 上頭從無到有,建置自己的 Hadoop Cluster,進行基本的 Hadoop 應用操作。
1. Hadoop 介紹
2. HDInsight 介紹
3. HDInsight 操作
2 / 30
- 3. Bio
在 Java SE 與 Java EE 領域有十多年的講師教學經驗,熟悉 XML/Web Services、
Design Patterns、EJB/JPA 等 Java EE 規格,Struts/Spring Framework/Hibernate 等
Open Source Framework,與 JBoss AS、GlassFish 等 Application Server。
自認為會的技術不多,但是學不會的也不多,最擅長把老闆交代的工作,以及找
不到老師教的技術,想辦法變成自己的專長。
目前負責 Java 與 .NET 雲端運算相關技術的推廣,主要包括 Hadoop Platform 與
NoSQL 等 Big Data 相關應用,Microsoft Azure、Google App Engine、與 CloudBees
等雲端平台的運用,以及 iOS、Android、Windows Phone 等 Smart Phone 的應用程
式開發。
3 / 30
- 6. 由創建 Lucene 與 Nutch 的 Doug Cutting 所建立
Lucene 是 Full-Featured Text Indexing and Searching Library
Nutch 是 Web Search Engine
依循著 Google 在 2003/2004 年發表的論文來開發
2006 年從 Nutch 計劃獨立出來,稱之為 Hadoop
2008 年 1 月變成 Apache 的 Top-Level Project
2009 年 7 月 Yahoo! 與 Microsoft 在 Search 達成合作協議
2009 年 9 月 Doug Cutting 加入 Cloudera 公司擔任 Architect
2011 年 6 月 Yahoo! 內部的 Hadoop 團隊 Spin Off 出去,成
立 Hortonworks 公司
Hadoop 簡史
6 / 30
- 7. Hadoop
的特色
Hadoop
的使用
情境
Accessible:普通 PC 或 VM 組成的 Cluster 就可以跑
Robust:所以要特別處理普通 PC 比較容易掛掉的問題
Scalable:隨著資料量增加,加入新機器就可以
Simple:透過 MapReduce 可以輕易寫出平行處理的程式
具備幾千個 Node 的 Scalability
把軟硬體發生 Failure 當成家常便飯
要處理的檔案多少不是重點,但是每個最好都很大
適合只會寫入一次/只有一人寫入,但是會讀取很多次
7 / 30
- 8. Hadoop 平台
兩大部份:Hadoop Distributed File System 與 MapReduce Programming Paradigm
以 Java 開發,但是不支援 Java SE 6 之前的 JDK 版本
原則上 Linux 平台是一個 Hadoop 有支援的 Development 與 Production Platform
Win32 可以是個 Development Platform,但是 Distributed Operation 沒有在 Win32
上面詳細測試過,所以不建議把 Win32 當成 Production Platform
不過,這件事因為 Hortonworks 把 Hadoop 移植到 Windows 平台,然後 Microsoft
又與 Hortonworks 合作,開始在 Azure 上支援 Hadoop 之後,有了改變
8 / 30
- 10. 什麼是 MapReduce
一個 Computing Model
把一個處理大量資料的 Job,拆解成許多可以在一堆 Server 平行處理的 Task
把 Code 往 Data 所在的 Server 搬移,減少 Network Traffic
各個 Task 執行的結果,會整合在一起,得到最終的結果
10 / 30
- 14. 什麼是 HDInsight
2012 年 10 月發佈
以 Hortonworks Data Platform (HDP) 平台為基礎
結合 Microsoft Windows 簡易操作與 Hortonworks HDP 的穩定與威力
14 / 30
- 16. Demo
1. 建立 Azure Blob Storage
2. 在 Azure Blob Storgae 裡頭建立 Container
3. 建立 HDInsight Cluster
4. 透過 Windows Azure PowerShell 操作
5. MapReduce 示範
6. Hive 示範
7. Power Query for Excel 示範
16 / 30
- 23. 透過 PowerShell 執行 MapReduce 範例
$subscription = "Azure 訂閱名稱"
$cluster = "剛剛建立的 HDInsight Cluster 名稱"
$jarFile = "wasb:///example/jars/hadoop-mapreduce-examples.jar"
$className = "wordcount"
$arguments1 = "wasb:///example/data/gutenberg/davinci.txt"
$arguments2 = "wasb:///example/data/WordCountOutput"
$waitTimeoutInSeconds = 3600
$jobDefinition = New-AzureHDInsightMapReduceJobDefinition
-JarFile $jarFile -ClassName $className -Arguments $arguments1, $arguments2
Select-AzureSubscription $subscription
$job = Start-AzureHDInsightJob -Cluster $cluster -JobDefinition $jobDefinition
Wait-AzureHDInsightJob -Job $job -WaitTimeoutInSeconds $waitTimeoutInSeconds
Get-AzureHDInsightJobOutput -Cluster $cluster -JobId $job.JobId -StandardError
23 / 30
- 24. 透過 PowerShell 上傳 Hive 測試資料
ggplot R package 裡頭提供了測試資料,下載網址是 http://had.co.nz/data/movies/,
解壓縮之後放在 C:。
$subscription = "Azure 訂閱名稱"
$cluster = "剛剛建立的 HDInsight Cluster 名稱"
Select-AzureSubscription $subscription
Use-AzureHDInsightCluster $cluster
$storageAccountName = "剛剛建立的 Storage 名稱"
$container = "剛剛建立的 Container 名稱"
$file = "C:movies.tab"
$blob = "movies/movies.tab"
$storageAccountKey = Get-AzureStorageKey –StorageAccountName $storageAccountName
$context = New-AzureStorageContext
–StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey.Primary
Set-AzureStorageBlobContent -Container $container -File $file -Blob $blob -Context $context
24 / 30
- 25. 透過 PowerShell 執行 Hive 範例
$response = Invoke-Hive -Query @"
create external table movies(title string, year string, length int, budget float, rating float, votes int,
r1 float, r2 float, r3 float, r4 float, r5 float, r6 float, r7 float, r8 float, r9 float, r10 float, mpaa string,
Action boolean, Animation boolean, Comedy boolean, Drama boolean, Documentary boolean,
Romance boolean,Short boolean)
row format delimited fields terminated by 't' lines terminated by 'n';
"@
Write-Host $response
$response = Invoke-Hive -Query @"
load data inpath '/movies/movies.tab' overwrite into table movies;
"@
Invoke-Hive "select count(*) from movies"
Invoke-Hive "select year, count(*) from movies group by year;"
Invoke-Hive -Query @"
insert overwrite directory 'moviesoutput'
select concat_ws(',', cast(size(split(title, ' ')) as string), cast(count(*) as string))
from movies
group by size(split(title, ' '));
"@
25 / 30
- 26. Microsoft 商業智慧工具
Hadoop 運算的結果可以透過 ODBC 匯入 Excel,無痛使用 PowerPivot 與 Power
Query/Power View 等 BI 工具分析資料
Hadoop 運算的結果可以透過 Sqoop 匯入 SQL Server,跟 SQL Server Analysis
Service、Reporting Service 等 BI 工具無縫整合
26 / 30
- 28. POWER QUERY -> 取得外部資料 -> 從其他來源 -> 從 Windows Azure HDInsight
28 / 30