馭象者之Apache Oozie
(1)Apache Oozie是什麼?
Oozie在英語中的釋義指的是:馴象人,馭象者(多指緬甸那邊的俗稱),這個比喻相對與它的功能來講,仍是很恰當的。
Apache Oozie是一個用來管理Hadoop任務的工做流調度系統,是基於有向無環圖的模型(DAG)。Oozie支持大多數的Hadoop任務的組合,常見的有Java MapReduce,Streaming map-reduce,Pig,Hive, Sqoop , Distcp,也能夠結合一些腳本如Shell,Python,Java來很靈活的完成一些事情。同時,它也是一個可伸縮的,可擴展,高可靠的的系統
(2)Apache Oozie能用來幹什麼?
其實,上面的這張圖,已經足夠回答這個問題了,工做流嘛,顧名思義,就是我要幹一件事,須要不少步驟,而後有序組合,最終達到可以完成這件事的目的。
舉個例子,就拿作飯這件事吧。
1,買菜
2,洗菜
3,切菜
4,炒菜
5,上菜
這是一個簡單的流程,固然這裏面會有不少其餘的小細節,好比我買菜,去了不一樣的菜市場,炒菜時候,又臨時去買了一些調料,等等。
仔細分析這裏面的道道,有些是有依賴關係的,有些沒依賴關係的,好比菜是核心,全部很菜有關的都有前後順序,其餘的輔助步驟,好比說燒水,跟這是沒有依賴關係的。反應到實際工做中的一些任務也是如此,因此採用oozie來管理調度,仍是很方便的一件事。
(3)Oozie的組成
Readme, license, notice & Release log files.(一個項目的,版權,介紹,log等)
Oozie server: oozie-server directory.(oozie的服務端目錄)
Scripts: bin/ directory, client and server scripts.(bin下面有一些經常使用的命令,來管理oozie的)
Binaries: lib/ directory, client JAR files.(存放oozie的依賴包)
Configuration: conf/ server configuration directory.(oozie的配置文件)
Archives:(歸檔包目錄)
oozie-client-*.tar.gz : Client tools.(oozie的客戶端包)
oozie.war : Oozie WAR file.(web的服務工程)
docs.zip : Documentation.(文檔)
oozie-examples-*.tar.gz : Examples.(例子)
oozie-sharelib-*.tar.gz : Share libraries (with Streaming, Pig JARs).(一些工做流支持的框架共享包)
(4)oozie支持調度的應用
1,Email任務
2,Shell任務
3,Hive任務
4,Sqoop任務
5,SSH任務
6,Distcp任務
7,自定義的任務
(5)oozie的下載,安裝,編譯
oozie目前最新的版本是oozie4.1.0,
下載地址1
,若是連接不上,可點擊這個
下載地址2
,
在linux上,能夠直接wget http://archive.apache.org/dist/oozie/4.1.0/oozie-4.1.0.tar.gz下載
下載完,能夠解壓出來根據本身的一些環境編譯。
散仙這裏的一些環境以下:
Hadoop2.2
JDK1.7
Maven3.0.5
Ant1.9.4
Hive0.13.1
Pig0.12.1
因此,須要修改在oozie的根目錄下的pom文件:
1,修改JDK版本
2,若有必要可修改各個組件的版本,在跟目錄下執行
grep -l "2.3.0" `find . -name "pom.xml"`
Java代碼
./pom.xml
./hadooplibs/hadoop-distcp-2 /pom.xml
./hadooplibs/hadoop-test-2 /pom.xml
./hadooplibs/hadoop-utils-2 /pom.xml
./hadooplibs/hadoop-2 /pom.xml
將查出來的pom文件,修改對應hadoop版本,hive,hbase,pig等組件版本
注意使用(sed -e 's/2.3.0/2.2.0/g' pom.xml 替換可能更快,可是建議本身去修改,由於改的地方並非太多!)
注意,在4.1.0裏,須要把下面這個保持成2.3.0,hadoop的版本能夠是2.2.0若是,不改的話,編譯Zookeeper-Scurity-Test時候,會報錯
Java代碼
[INFO] Apache Oozie ZooKeeper Security Tests ............. FAILURE [2 .204s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 :27 .818s
[INFO] Finished at: Fri May 15 12 :50 :50 CST 2015
[INFO] Final Memory: 132M/237M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project oozie-zookeeper-security-tests: Could not resolve dependencies for project org.apache.oozie:oozie-zookeeper-security-tests:jar:4.1 .0 : Failed to collect dependencies for [org.apache.curator:curator-test:jar:2.5 .0 (test), org.apache.hadoop:hadoop-minikdc:jar:2.2 .0 (test), org.apache.oozie:oozie-core:jar:4.1 .0 (test), org.apache.oozie:oozie-core:jar:tests:4.1 .0 (test), org.apache.oozie:oozie-hadoop:jar:2.2 .0 .oozie-4.1 .0 (provided), org.apache.oozie:oozie-hadoop-test:jar:2.2 .0 .oozie-4.1 .0 (test)]: Failed to read artifact descriptor for org.apache.hadoop:hadoop-minikdc:jar:2.2 .0 : Could not transfer artifact org.apache.hadoop:hadoop-minikdc:pom:2.2 .0 from/to Codehaus repository (http://repository.codehaus.org/): peer not authenticated -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch .
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1 ] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :oozie-zookeeper-security-tests
改回2.3.0便可
Java代碼
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-minikdc</artifactId>
<version>2.3 .0 </version>
</dependency>
3,修改完成後,執行下面命令進行編譯:
bin/mkdistro.sh -DskipTests -Dhadoop.version=2.2.0
4,中間若是出現錯誤,沒關係,從新執行上面命令,會增量的編譯,原來編譯成功的,不會重複編譯,編譯成功以下:
Java代碼
[INFO] Reactor Summary:
[INFO]
[INFO] Apache Oozie Main .................................. SUCCESS [ 1.440 s]
[INFO] Apache Oozie Client ................................ SUCCESS [ 22.217 s]
[INFO] Apache Oozie Hadoop 1.1 .1 .oozie-4.1 .0 .............. SUCCESS [ 0.836 s]
[INFO] Apache Oozie Hadoop Distcp 1.1 .1 .oozie-4.1 .0 ....... SUCCESS [ 0.065 s]
[INFO] Apache Oozie Hadoop 1.1 .1 .oozie-4.1 .0 Test ......... SUCCESS [ 0.182 s]
[INFO] Apache Oozie Hadoop Utils 1.1 .1 .oozie-4.1 .0 ........ SUCCESS [ 0.784 s]
[INFO] Apache Oozie Hadoop 2.3 .0 .oozie-4.1 .0 .............. SUCCESS [ 4.803 s]
[INFO] Apache Oozie Hadoop 2.3 .0 .oozie-4.1 .0 Test ......... SUCCESS [ 0.254 s]
[INFO] Apache Oozie Hadoop Distcp 2.3 .0 .oozie-4.1 .0 ....... SUCCESS [ 0.066 s]
[INFO] Apache Oozie Hadoop Utils 2.3 .0 .oozie-4.1 .0 ........ SUCCESS [ 1.033 s]
[INFO] Apache Oozie Hadoop 0.23 .5 .oozie-4.1 .0 ............. SUCCESS [ 3.231 s]
[INFO] Apache Oozie Hadoop 0.23 .5 .oozie-4.1 .0 Test ........ SUCCESS [ 0.336 s]
[INFO] Apache Oozie Hadoop Distcp 0.23 .5 .oozie-4.1 .0 ...... SUCCESS [ 0.062 s]
[INFO] Apache Oozie Hadoop Utils 0.23 .5 .oozie-4.1 .0 ....... SUCCESS [ 0.878 s]
[INFO] Apache Oozie Hadoop Libs ........................... SUCCESS [ 3.780 s]
[INFO] Apache Oozie Hbase 0.94 .2 .oozie-4.1 .0 .............. SUCCESS [ 0.338 s]
[INFO] Apache Oozie Hbase Libs ............................ SUCCESS [ 0.692 s]
[INFO] Apache Oozie HCatalog 0.13 .1 .oozie-4.1 .0 ........... SUCCESS [ 0.919 s]
[INFO] Apache Oozie HCatalog Libs ......................... SUCCESS [ 1.735 s]
[INFO] Apache Oozie Share Lib Oozie ....................... SUCCESS [ 13.552 s]
[INFO] Apache Oozie Share Lib HCatalog .................... SUCCESS [ 40.232 s]
[INFO] Apache Oozie Core .................................. SUCCESS [05 :03 min]
[INFO] Apache Oozie Docs .................................. SUCCESS [01 :07 min]
[INFO] Apache Oozie Share Lib Pig ......................... SUCCESS [01 :38 min]
[INFO] Apache Oozie Share Lib Hive ........................ SUCCESS [ 12.927 s]
[INFO] Apache Oozie Share Lib Sqoop ....................... SUCCESS [ 5.655 s]
[INFO] Apache Oozie Share Lib Streaming ................... SUCCESS [ 4.577 s]
[INFO] Apache Oozie Share Lib Distcp ...................... SUCCESS [ 1.900 s]
[INFO] Apache Oozie WebApp ................................ SUCCESS [02 :26 min]
[INFO] Apache Oozie Examples .............................. SUCCESS [ 3.762 s]
[INFO] Apache Oozie Share Lib ............................. SUCCESS [ 11.415 s]
[INFO] Apache Oozie Tools ................................. SUCCESS [ 10.718 s]
[INFO] Apache Oozie MiniOozie ............................. SUCCESS [ 9.647 s]
[INFO] Apache Oozie Distro ................................ SUCCESS [ 27.966 s]
[INFO] Apache Oozie ZooKeeper Security Tests .............. SUCCESS [ 7.040 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
5,編譯成功後在oozie-release-4.1.0/distro/target目錄下,會生成以下的幾個文件:
Java代碼
drwxr-xr-x 2 root root 4096 5 月 15 13 :45 antrun
drwxr-xr-x 2 root root 4096 5 月 15 13 :45 archive-tmp
drwxr-xr-x 2 root root 4096 5 月 15 13 :45 maven-archiver
drwxr-xr-x 3 root root 4096 5 月 15 13 :46 oozie-4.1 .0 -distro
-rw-r--r-- 1 root root 201469924 5 月 15 13 :46 oozie-4.1 .0 -distro.tar.gz
-rw-r--r-- 1 root root 2875 5 月 15 13 :45 oozie-distro-4.1 .0 .jar
drwxr-xr-x 3 root root 4096 5 月 15 13 :45 tomcat
6,拷貝oozie-4.1.0-distro.tar.gz壓縮包,至你須要安裝的地方並解壓,而後進入根目錄下,
執行mkdir libext命令,建立libext目錄
接着執行
cp ${HADOOP_HOME}/share/hadoop/*/*.jar libext/
cp ${HADOOP_HOME}/share/hadoop/*/lib/*.jar libext/
命令,將hadoop的相關的jar包拷貝至改目錄
下載一個ext-2.2.zip包,也放入libext目錄,因爲oozie的js可能會依賴這個包,最新的版本應該不須要了,待驗證?這個包,散仙在文末會上傳到附件中,
7,刪除libext下這幾個包,由於會和hadoop的中的一些包衝突,形成類加載器沒法識別重複的jsp,servlet或el解析器:
jasper-compiler-5.5.23.jar
jasper-runtime-5.5.23.jar
jsp-api-2.1.jar
8,修改conf/oozie-site.xml文件,更改如下幾個地方:
Xml代碼
<!-- 修改對應的hadoop的安裝用戶,散仙這裏是search -->
< property >
< name > oozie.system.id</ name >
< value > oozie-search</ value >
< description >
The Oozie system ID.
</ description >
</ property >
<!-- 修改hadoop的conf的文件目錄 -->
< property >
< name > oozie.service.HadoopAccessorService.hadoop.configurations</ name >
< value > *=/home/search/hadoop/etc/hadoop</ value >
< description >
Comma separated AUTHORITY =HADOOP_CONF_DIR , where AUTHORITY is the HOST:PORT of
the Hadoop service (JobTracker, HDFS). The wildcard '*' configuration is
used when there is no exact match for an authority. The HADOOP_CONF_DIR contains
the relevant Hadoop *-site.xml files. If the path is relative is looked within
the Oozie configuration directory; though the path can be absolute (i.e. to point
to Hadoop client conf/ directories in the local filesystem.
</ description >
</ property >
<!-- 修改oozie的share lib的HDFS目錄 -->
< property >
< name > oozie.service.WorkflowAppService.system.libpath</ name >
< value > /user/search/share/lib</ value >
< description >
System library path to use for workflow applications.
This path is added to workflow application if their job properties sets
the property 'oozie.use.system.libpath' to true.
</ description >
</ property >
<!-- 修改代理用戶Hue須要用到,下面這兩個配置,在Hadoop的core-site.xml中,一樣須要添加,代理用戶提交做業功能 -->
< property >
< name > oozie.service.ProxyUserService.proxyuser.search.hosts</ name >
< value > *</ value >
</ property >
< property >
< name > oozie.service.ProxyUserService.proxyuser.search.groups</ name >
< value > *</ value >
</ property >
9,刪除/home/search/oozie-4.1.0/conf/hadoop-conf下的core-site.xml文件,將/home/search/hadoop/etc/hadoop/下的全部配置文件,拷貝到此處
(6)執行bin/oozie-setup.sh prepare-war命令,從新生成war包
(7)執行bin/oozie-setup.sh sharelib create -fs hdfs://<namenode-hostname>:8020命令,將share下面的共享jar拷貝至HDFS中,
此處,也能夠本身使用hadoop fs -copyFromLocal share/ /hdfs/xxx拷貝
(8)執行bin/oozie-setup.sh db create -run初始化oozie數據庫
(9)執行bin/oozied.sh start啓動oozie server
(10) 執行bin/oozie admin -oozie http://localhost:11000/oozie -status)返回Normal,即表明安裝成功
Java代碼
[search@h1 oozie-4.1 .0 ]$ bin/oozie admin -oozie http://localhost:11000/oozie -status
System mode: NORMAL
[search@h1 oozie-4.1 .0 ]$
(11)在win上訪問測試
(12)看到上圖,說明你已經成功安裝了,關係服務的命令
bin/oozied.sh stop,若是說不能中止,須要手動去刪掉pid文件,而後在關閉。
oozie安裝成功,很重要,由於Hue須要依賴它,作任務調度,下一篇文章,散仙就總結下hue安裝筆記。
歡迎關注本站公眾號,獲取更多信息