阅读576 返回首页    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_大数据计算服务-阿里云