[关闭]
@awsekfozc 2016-01-06T10:50:41.000000Z 字数 3161 阅读 1561

Sqoop Action

Oozie

command

workflow.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <workflow-app xmlns="uri:oozie:workflow:0.5" name="sqoop-wf">
  3. <start to="sqoop-node"/>
  4. <action name="sqoop-node">
  5. <sqoop xmlns="uri:oozie:sqoop-action:0.3">
  6. <job-tracker>${jobTracker}</job-tracker>
  7. <name-node>${nameNode}</name-node>
  8. <configuration>
  9. <property>
  10. <name>mapred.job.queue.name</name>
  11. <value>${queueName}</value>
  12. </property>
  13. </configuration>
  14. <command>export --connect jdbc:mysql://hadoop.zc.com:3306/test --username root --password 123456 --table my_user --num-mappers 1 --input-fields-terminated-by "\t" --export-dir /user/zc/oozie/datas/sqoop-data</command>
  15. </sqoop>
  16. <ok to="end"/>
  17. <error to="fail"/>
  18. </action>
  19. <kill name="fail">
  20. <message>Sqoop failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
  21. </kill>
  22. <end name="end"/>
  23. </workflow-app>

job.properties

  1. nameNode=hdfs://hadoop.zc.com:8020
  2. jobTracker=hadoop.zc.com:8032
  3. queueName=default
  4. oozieAppsRoot=user/zc/oozie-apps
  5. oozieDataRoot=/user/zc/oozie/datas/sqoop-data
  6. oozie.use.system.libpath=true
  7. oozie.wf.application.path=${nameNode}/${oozieAppsRoot}/sqoop-cmd

run

  1. $ export OOZIE_URL=http://hadoop.zc.com:11000/oozie/
  2. $ bin/oozie job -config oozie-apps/sqoop-cmd/job.properties -run

arg

workflow.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <workflow-app xmlns="uri:oozie:workflow:0.5" name="sqoop-wf">
  3. <start to="sqoop-node"/>
  4. <action name="sqoop-node">
  5. <sqoop xmlns="uri:oozie:sqoop-action:0.3">
  6. <job-tracker>${jobTracker}</job-tracker>
  7. <name-node>${nameNode}</name-node>
  8. <configuration>
  9. <property>
  10. <name>mapred.job.queue.name</name>
  11. <value>${queueName}</value>
  12. </property>
  13. </configuration>
  14. <arg>export</arg>
  15. <arg>--connect</arg>
  16. <arg>jdbc:mysql://hadoop.zc.com:3306/test</arg>
  17. <arg>--username</arg>
  18. <arg>root</arg>
  19. <arg>--password</arg>
  20. <arg>123456</arg>
  21. <arg>--table</arg>
  22. <arg>my_user</arg>
  23. <arg>--num-mappers</arg>
  24. <arg>1</arg>
  25. <arg>--input-fields-terminated-by</arg>
  26. <arg>"\t"</arg>
  27. <arg>--export-dir</arg>
  28. <arg>${oozieDataRoot}</arg>
  29. </sqoop>
  30. <ok to="end"/>
  31. <error to="fail"/>
  32. </action>
  33. <kill name="fail">
  34. <message>Sqoop failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
  35. </kill>
  36. <end name="end"/>
  37. </workflow-app>

NOTE

command和arg只能有一个,arg里面不能带有空格。

file

workflow.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <workflow-app xmlns="uri:oozie:workflow:0.5" name="sqoop-wf">
  3. <start to="sqoop-node"/>
  4. <action name="sqoop-node">
  5. <sqoop xmlns="uri:oozie:sqoop-action:0.3">
  6. <job-tracker>${jobTracker}</job-tracker>
  7. <name-node>${nameNode}</name-node>
  8. <configuration>
  9. <property>
  10. <name>mapred.job.queue.name</name>
  11. <value>${queueName}</value>
  12. </property>
  13. </configuration>
  14. <command>--options-file script.txt</command>
  15. <file>${sqoopScriptPath}</file>
  16. </sqoop>
  17. <ok to="end"/>
  18. <error to="fail"/>
  19. </action>
  20. <kill name="fail">
  21. <message>Sqoop failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
  22. </kill>
  23. <end name="end"/>
  24. </workflow-app>

job.properties

  1. nameNode=hdfs://hadoop.zc.com:8020
  2. jobTracker=hadoop.zc.com:8032
  3. queueName=default
  4. oozieAppsRoot=user/zc/oozie-apps
  5. oozieDataRoot=/user/zc/oozie/datas/sqoop-data
  6. sqoopScriptPath=${nameNode}/${oozieAppsRoot}/sqoop-file/script.txt
  7. oozie.use.system.libpath=true
  8. oozie.wf.application.path=${nameNode}/${oozieAppsRoot}/sqoop-file

NOTE

--options-file xxx.txt。文件必须在HDFS上。
导入mysql表中,如果发现乱码,则修改mysql字符集 为UTF8

在此输入正文

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注