Crontab定时器执行shell脚本结束后发现sqoop语句执行失败,手动执行shell脚本sqoop语句执行正常。
于是 tail -f /var/spool/mail/root 查看sqoop日志发现错误。
INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /opt/cloudera/parcels/CDH/lib/hadoop-mapreduce
ERROR orm.CompilationManager: It seems as though you are running sqoop with a JRE.
ERROR orm.CompilationManager: Sqoop requires a JDK that can compile Java code.
ERROR orm.CompilationManager: Please install a JDK and set $JAVA_HOME to use it.
ERROR tool.ExportTool: Encountered IOException running export job: java.io.IOException: Could not start Java compiler.
原因是sqoop在shell表达式里执行时没有找到java环境变量,在shell脚本开头定义
export JAVA_HOME=jdk路径即可