其中,本文實現了node
--connect jdbc:mysql://cen-ubuntu:3306/test --username root --password ubuntu --table user --hive-database default --hive-table import_from_mysql --hive-import --hive-overwrite --delete-target-dir
insert overwrite directory '/user/cen/oozie-apps/sqoop2hive2sqoop/output/' ROW format delimited fields terminated by ',' select id,name from default.import_from_mysql;
--connect jdbc:mysql://cen-ubuntu:3306/test --username root --password ubuntu --table export_from_hdfs --export-dir /user/cen/oozie-apps/sqoop2hive2sqoop/output/ --fields-terminated-by ','
nameNode=hdfs://cen-ubuntu.cenzhongman.com:8020 jobTracker=localhost:8032 queueName=default oozieAppsRoot=oozie-apps oozie.use.system.libpath=true oozie.wf.application.path=${nameNode}/user/cen/${oozieAppsRoot}/sqoop2hive2sqoop/ outputDir=sqoop2hive2sqoop/output
<workflow-app xmlns="uri:oozie:workflow:0.5" name="sqoop2hive2sqoop-wf"> <start to="hive-node"/> <action name="hive-node"> <hive xmlns="uri:oozie:hive-action:0.5"> <job-tracker>${jobTracker}</job-tracker> <name-node>${nameNode}</name-node> <prepare> <delete path="${nameNode}/user/cen/${oozieAppsRoot}/${outputDir}"/> </prepare> <job-xml>${nameNode}/user/cen/${oozieAppsRoot}/sqoop2hive2sqoop/hive-site.xml</job-xml> <configuration> <property> <name>mapred.job.queue.name</name> <value>${queueName}</value> </property> </configuration> <script>select.sql</script> </hive> <ok to="sqoop-export-node"/> <error to="hive-fail"/> </action> <action name="sqoop-export-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 --options-file sqoop-export.sql</command> <file>${nameNode}/user/cen/${oozieAppsRoot}/sqoop2hive2sqoop/sqoop-export.sql#sqoop-export.sql</file> </sqoop> <ok to="end"/> <error to="sqoop-export-fail"/> </action> <kill name="hive-fail"> <message>hive failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message> </kill> <kill name="sqoop-export-fail"> <message>Sqoop export failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message> </kill> <end name="end"/> </workflow-app>
bin/sqoop import --options-file /opt/cdh5.3.6/oozie-4.1.0-cdh5.12.0/oozie-apps/sqoop2hive2sqoop/sqoop-import.sql
export OOZIE_URL=http://cen-ubuntu:11000/oozie/ bin/oozie job --config /opt/cdh5.3.6/oozie-4.1.0-cdh5.12.0/oozie-apps/sqoop2hive2sqoop/job.properties -run
<workflow-app xmlns="uri:oozie:workflow:0.5" name="sqoop2hive2sqoop-wf"> <start to="sqoop-import-node"/> <action name="sqoop-import-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>import --options-file sqoop-import.sql</command> <file>${nameNode}/user/cen/${oozieAppsRoot}/sqoop2hive2sqoop/sqoop-import.sql#sqoop-import.sql</file> </sqoop> <ok to="hive-node"/> <error to="sqoop-import-fail"/> </action> <action name="hive-node"> <hive xmlns="uri:oozie:hive-action:0.5"> <job-tracker>${jobTracker}</job-tracker> <name-node>${nameNode}</name-node> <prepare> <delete path="${nameNode}/user/cen/${oozieAppsRoot}/${outputDir}"/> </prepare> <job-xml>${nameNode}/user/cen/${oozieAppsRoot}/sqoop2hive2sqoop/hive-site.xml</job-xml> <configuration> <property> <name>mapred.job.queue.name</name> <value>${queueName}</value> </property> </configuration> <script>select.sql</script> </hive> <ok to="sqoop-export-node"/> <error to="hive-fail"/> </action> <action name="sqoop-export-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 --options-file sqoop-export.sql</command> <file>${nameNode}/user/cen/${oozieAppsRoot}/sqoop2hive2sqoop/sqoop-export.sql#sqoop-export.sql</file> </sqoop> <ok to="end"/> <error to="sqoop-export-fail"/> </action> <kill name="sqoop-import-fail"> <message>Sqoop import failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message> </kill> <kill name="hive-fail"> <message>hive failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message> </kill> <kill name="sqoop-export-fail"> <message>Sqoop export failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message> </kill> <end name="end"/> </workflow-app>
緣由剖析:錯誤出如今 sqoop-import-nodemysql
解決:增長用戶環境變量~/.bash_profilesql
export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/opt/cdh5.3.6/hive-1.1.0-cdh5.12.0/lib/*apache
詳情請參考ubuntu