@awsekfozc
2016-01-06T10:50:41.000000Z
字数 3161
阅读 1572
Oozie
workflow.xml
<?xml version="1.0" encoding="UTF-8"?>
<workflow-app xmlns="uri:oozie:workflow:0.5" name="sqoop-wf">
<start to="sqoop-node"/>
<action name="sqoop-node">
<sqoop xmlns="uri:oozie:sqoop-action:0.3">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<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>
</sqoop>
<ok to="end"/>
<error to="fail"/>
</action>
<kill name="fail">
<message>Sqoop failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>
</workflow-app>
job.properties
nameNode=hdfs://hadoop.zc.com:8020
jobTracker=hadoop.zc.com:8032
queueName=default
oozieAppsRoot=user/zc/oozie-apps
oozieDataRoot=/user/zc/oozie/datas/sqoop-data
oozie.use.system.libpath=true
oozie.wf.application.path=${nameNode}/${oozieAppsRoot}/sqoop-cmd
run
$ export OOZIE_URL=http://hadoop.zc.com:11000/oozie/
$ bin/oozie job -config oozie-apps/sqoop-cmd/job.properties -run
workflow.xml
<?xml version="1.0" encoding="UTF-8"?>
<workflow-app xmlns="uri:oozie:workflow:0.5" name="sqoop-wf">
<start to="sqoop-node"/>
<action name="sqoop-node">
<sqoop xmlns="uri:oozie:sqoop-action:0.3">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<arg>export</arg>
<arg>--connect</arg>
<arg>jdbc:mysql://hadoop.zc.com:3306/test</arg>
<arg>--username</arg>
<arg>root</arg>
<arg>--password</arg>
<arg>123456</arg>
<arg>--table</arg>
<arg>my_user</arg>
<arg>--num-mappers</arg>
<arg>1</arg>
<arg>--input-fields-terminated-by</arg>
<arg>"\t"</arg>
<arg>--export-dir</arg>
<arg>${oozieDataRoot}</arg>
</sqoop>
<ok to="end"/>
<error to="fail"/>
</action>
<kill name="fail">
<message>Sqoop failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>
</workflow-app>
NOTE
command和arg只能有一个,arg里面不能带有空格。
workflow.xml
<?xml version="1.0" encoding="UTF-8"?>
<workflow-app xmlns="uri:oozie:workflow:0.5" name="sqoop-wf">
<start to="sqoop-node"/>
<action name="sqoop-node">
<sqoop xmlns="uri:oozie:sqoop-action:0.3">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<command>--options-file script.txt</command>
<file>${sqoopScriptPath}</file>
</sqoop>
<ok to="end"/>
<error to="fail"/>
</action>
<kill name="fail">
<message>Sqoop failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>
</workflow-app>
job.properties
nameNode=hdfs://hadoop.zc.com:8020
jobTracker=hadoop.zc.com:8032
queueName=default
oozieAppsRoot=user/zc/oozie-apps
oozieDataRoot=/user/zc/oozie/datas/sqoop-data
sqoopScriptPath=${nameNode}/${oozieAppsRoot}/sqoop-file/script.txt
oozie.use.system.libpath=true
oozie.wf.application.path=${nameNode}/${oozieAppsRoot}/sqoop-file
NOTE
--options-file xxx.txt。文件必须在HDFS上。
导入mysql表中,如果发现乱码,则修改mysql字符集 为UTF8
在此输入正文