本workflow位於oozie目錄下新創建的一個oozie-apps文件夾下的sqoop文件夾中。
sqoop:
1、job.properties
2、lib文件夾(其中包含了一個mysql的驅動包)
2、workflow.xml
將整個oozie-apps文件夾上傳到hdfs的對應用戶目錄下
然後運行程序
bin/oozie job -config oozie-apps/sqoop/job.properties -run
job.properties
nameNode=hdfs://127.0.0.1:9000
jobTracker=127.0.0.1:8032
queueName=default
oozieappsRoot=user/bpf/oozie-apps
DataRoot=user/bpf/oozie/datas
oozie.use.system.libpath=true
oozie.wf.application.path=${nameNode}/${oozieappsRoot}/sqoop/workflow.xml
outputDir=sqoop/output
workflow.xml
<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>
<prepare>
<delete path="${nameNode}/${DataRoot}/${outputDir}"/>
</prepare>
<configuration>
<property>
<name>mapreduce.job.queuename</name>
<value>${queueName}</value>
</property>
</configuration>
<command>import --connect jdbc:mysql://127.0.0.1:3306/bpf --username root --password 1234 --table user --target-dir ${nameNode}/${DataRoot}/${outputDir} --num-mappers 1</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>
也可以編寫一個腳本 如test.txt
--connect
jdbc:mysql://127.0.0.1:3306/bpf
--username
root
--password
1234
--table
user
--target-dir
${nameNode}/${DataRoot}/${outputDir}
--num-mappers
1
然後再workflow的command標籤中使用<command>import --options-file test.txt</command>