閱讀576 返回首頁    go 阿裏雲 go 技術社區[雲棲]


作業提交__功能介紹_MapReduce_大數據計算服務-阿裏雲

MaxCompute 客戶端提供一個jar命令用於運行MapReduce作業,具體語法:

  1. Usage: jar [<GENERIC_OPTIONS>] <MAIN_CLASS> [ARGS]
  2. -conf <configuration_file> Specify an application configuration file
  3. -classpath <local_file_list> classpaths used to run mainClass
  4. -D <name>=<value> Property value pair, which will be used to run mainClass
  5. -l Run job in local mode
  6. -resources <resource_name_list> file/table resources used in mapper or reducer, seperate by comma
  7. For example:
  8. jar -conf /home/admin/myconf -resources a.txt,example.jar -classpath ../lib/example.jar:./other_lib.jar -Djava.library.path=./native -Xmx512M mycompany.WordCount -m 10 -r 10 in out;

其中<GENERIC_OPTIONS>包括(均為可選參數):

  • -conf <configuration file> :指定JobConf配置文件;
  • -classpath <local_file_list>: 本地執行時的classpath,主要用於指定main函數所在的jar包的本地路徑(包含相對路徑和絕對路徑)。大多數情況下,用戶更習慣於將main函數與Map/Reduce函數編寫在一個包中,例如:WordCount代碼示例 ,因此,在執行示例程序時,-resources及-classpath的參數中都出現了mapreduce-examples.jar,但二者意義不同,-resources引用的是Map/Reduce函數,運行於分布式環境中,而-classpath引用的是main函數,運行於本地,指定的jar包路徑也是本地文件路徑。包名之間使用係統默認的文件分割符作分割(通常情況下,windows係統是分號”;”,linux係統是逗號”,”,如果用戶是在雲端使用mr任務,jar包之間的分隔是逗號”,”。);
  • -D <prop_name>=<prop_value> : 本地執行時,<mainClass>的java屬性,可以定義多個;
  • -l:以本地模式執行MapReduce作業,主要用於程序調試;
  • -resources <resource_name_list>: MapReduce作業運行時使用的資源聲明。一般情況下,resource_name_list中需要指定Map/Reduce函數所在的資源名稱。請特別注意,如果用戶在Map/Reduce函數中讀取了其他ODPS資源,那麼,這些資源名稱也需要被添加到resource_name_list中。資源之間使用逗號分隔,使用跨項目空間使用資源時,需要前麵加上:PROJECT/resources/,示例:-resources otherproject/resources/resfile。有關於如何在Map/Reduce函數中讀取資源的示例請查看資源使用示例 ;用戶可以通過-conf選項指定JobConf配置文件,該文件可以影響SDK中JobConf的設置。下麵將給出一個JobConf配置文件的示例:
  1. <configuration>
  2. <property>
  3. <name>import.filename</name>
  4. <value>resource.txt</value>
  5. </property>
  6. </configuration>

在上述示例中,通過JobConf配置文件定義一個名為import.filename的變量,該變量的值為resource.txt。用戶可以在MapReduce程序中通過JobConf接口獲取該變量的值。用戶通過SDK中JobConf接口可以達到相同的目的。具體使用方式可以參考 資源使用示例

示例:

  1. jar -resources mapreduce-examples.jar -classpath mapreduce-examples.jar
  2. org.alidata.odps.mr.examples.WordCount wc_in wc_out
  3. add file data/src.txt
  4. jar -resources src.txt,mapreduce-examples.jar -classpath mapreduce-examples.jar
  5. org.alidata.odps.mr.examples.WordCount wc_in wc_out
  6. add file data/a.txt
  7. add table wc_in as test_table
  8. add jar work.jar
  9. jar -conf odps-mapred.xml -resources a.txt,test_table,work.jar
  10. -classpath work.jar:otherlib.jar
  11. -D import.filename=resource.txt org.alidata.odps.mr.examples.WordCount args ...

最後更新:2016-10-17 14:56:11

  上一篇:go 開源兼容MapReduce__概要_MapReduce_大數據計算服務-阿裏雲
  下一篇:go 輸入與輸出__功能介紹_MapReduce_大數據計算服務-阿裏雲