Oozie执行Sqoop,传入参数(注意,在使用--query时,参数中一定不要带有空格,否则出错)
1. 新建一个workflow
2. 拖入一个sqoop
3. sqoop抽取命令如下(建议先在命令行试下,因为oozie的错误提示很委婉,基本看不出错误原因)
sqoop import --connect jdbc:mysql://localhost:3306/spider_new --username root --password 1234qwer --target-dir /user/fengz/brand/spider_data/amac/amac_fund_${date} --delete-target-dir --fields-terminated-by '`' --query select * from amac_fund where update_time between '${start_time}' and '${end_time}' and \$CONDITIONS -m 1
import --connect jdbc:mysql://localhost:3306/spider_new --username root --password 1234qwer --target-dir /user/fengz/brand/spider_data/amac/amac_fund_${date} --delete-target-dir --fields-terminated-by ` --query select * from amac_fund where update_time between '${start_time}' and '${end_time}' and \$CONDITIONS -m 1
注意:指定分隔符时,要把单引号去掉,下边还有一个大坑
5. 添加参数
6. 启动,填入参数
7. 那么问题来了,报错是必须的
oozie在解析sqoop语句的时候,是根据空格来分割的,那就恶心了,日期字段中间带有空格,就像这样Setting up log4j2log4j2 configuration file created at /data1/yarn/nm/usercache/fengz/appcache/application_1552354446915_0759/container_1552354446915_0759_01_000001/sqoop-log4j2.xmlSqoop command arguments :import--connectjdbc:mysql://localhost:3306/spider_new--usernameroot--password********--target-dir/user/fengz/brand/spider_data/amac/amac_fund_20190315--delete-target-dir--fields-terminated-by`--query"select*fromamac_fundwhereupdate_timebetween'2019-03-1410:57:08'and'2019-03-1414:08:45'and\$CONDITIONS"-m1Fetching child yarn jobstag id : oozie-3e829587c1f3a050998935d2c2ac3ed4
再看下oozie的错误提示,呵呵呵....发现一点鸟用都没有
No child hadoop job is executed.java.lang.reflect.InvocationTargetExceptionat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.apache.oozie.action.hadoop.LauncherAM.runActionMain(LauncherAM.java:410)at org.apache.oozie.action.hadoop.LauncherAM.access$300(LauncherAM.java:55)at org.apache.oozie.action.hadoop.LauncherAM$2.run(LauncherAM.java:223)at java.security.AccessController.doPrivileged(Native Method)at javax.security.auth.Subject.doAs(Subject.java:422)at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1685)at org.apache.oozie.action.hadoop.LauncherAM.run(LauncherAM.java:217)at org.apache.oozie.action.hadoop.LauncherAM$1.run(LauncherAM.java:153)at java.security.AccessController.doPrivileged(Native Method)at javax.security.auth.Subject.doAs(Subject.java:422)at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1685)at org.apache.oozie.action.hadoop.LauncherAM.main(LauncherAM.java:141)Caused by: java.lang.SecurityException: Intercepted System.exit(1)at org.apache.oozie.action.hadoop.security.LauncherSecurityManager.checkExit(LauncherSecurityManager.java:57)at java.lang.Runtime.exit(Runtime.java:107)at java.lang.System.exit(System.java:971)at org.apache.sqoop.Sqoop.main(Sqoop.java:251)at org.apache.oozie.action.hadoop.SqoopMain.runSqoopJob(SqoopMain.java:214)at org.apache.oozie.action.hadoop.SqoopMain.run(SqoopMain.java:199)at org.apache.oozie.action.hadoop.LauncherMain.run(LauncherMain.java:101)at org.apache.oozie.action.hadoop.SqoopMain.main(SqoopMain.java:51)... 16 moreIntercepting System.exit(1)Failing Oozie Launcher, Main Class [org.apache.oozie.action.hadoop.SqoopMain], exit code [1]
以后用的时候注意下就好了。那这个问题怎么解决?。