最近使用Sqoop从Hive导出数据到MySQL中,出现了一系列的问题,下面将这个问题记录一下,避免再度踩坑!java
sqoop export --connect jdbc:mysql://192.168.1.78:3306/data \ --username root \ -P \ --export-dir '/user/hive/warehouse/personas.db/user_attribute/000000_0' \ --table dm_user_attribute \ --input-fields-terminated-by '|' \ --input-null-non-string '\\N' \ --input-null-string '\\N' \ --lines-terminated-by '\n' \ -m 1
centOS7+CDH5.7.2+其中集成的Sqoopmysql
如下是我输入命令到服务器中,控制台打印的信息。web
Warning: /opt/cloudera/parcels/CDH-5.7.2-1.cdh5.7.2.p0.18/bin/../lib/sqoop/../accumulo does not exist! Accumulo imports will fail. Please set $ACCUMULO_HOME to the root of your Accumulo installation. 18/07/23 11:54:45 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6-cdh5.7.2 18/07/23 11:54:45 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead. 18/07/23 11:54:45 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset. 18/07/23 11:54:45 INFO tool.CodeGenTool: Beginning code generation 18/07/23 11:54:45 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `dm_user_attribute` AS t LIMIT 1 18/07/23 11:54:45 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `dm_user_attribute` AS t LIMIT 1 18/07/23 11:54:45 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /opt/cloudera/parcels/CDH/lib/hadoop-mapreduce Note: /tmp/sqoop-root/compile/2322b82e8ef7190a66357528d5fbddae/dm_user_attribute.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 18/07/23 11:54:47 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-root/compile/2322b82e8ef7190a66357528d5fbddae/dm_user_attribute.jar 18/07/23 11:54:47 INFO mapreduce.ExportJobBase: Beginning export of dm_user_attribute 18/07/23 11:54:47 INFO Configuration.deprecation: mapred.jar is deprecated. Instead, use mapreduce.job.jar 18/07/23 11:54:47 INFO Configuration.deprecation: mapred.map.max.attempts is deprecated. Instead, use mapreduce.map.maxattempts 18/07/23 11:54:48 INFO Configuration.deprecation: mapred.reduce.tasks.speculative.execution is deprecated. Instead, use mapreduce.reduce.speculative 18/07/23 11:54:48 INFO Configuration.deprecation: mapred.map.tasks.speculative.execution is deprecated. Instead, use mapreduce.map.speculative 18/07/23 11:54:48 INFO Configuration.deprecation: mapred.map.tasks is deprecated. Instead, use mapreduce.job.maps 18/07/23 11:54:48 INFO client.RMProxy: Connecting to ResourceManager at 192.168.1.152:8032 18/07/23 11:54:49 INFO input.FileInputFormat: Total input paths to process : 1 18/07/23 11:54:49 INFO input.FileInputFormat: Total input paths to process : 1 18/07/23 11:54:49 INFO mapreduce.JobSubmitter: number of splits:1 18/07/23 11:54:49 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1528444677205_1338 18/07/23 11:54:50 INFO impl.YarnClientImpl: Submitted application application_1528444677205_1338 18/07/23 11:54:50 INFO mapreduce.Job: The url to track the job: http://daojia02:8088/proxy/application_1528444677205_1338/ 18/07/23 11:54:50 INFO mapreduce.Job: Running job: job_1528444677205_1338 18/07/23 11:54:55 INFO mapreduce.Job: Job job_1528444677205_1338 running in uber mode : false 18/07/23 11:54:55 INFO mapreduce.Job: map 0% reduce 0% 18/07/23 11:55:00 INFO mapreduce.Job: map 100% reduce 0% 18/07/23 11:55:01 INFO mapreduce.Job: Job job_1528444677205_1338 failed with state FAILED due to: Task failed task_1528444677205_1338_m_000000 Job failed as tasks failed. failedMaps:1 failedReduces:0 18/07/23 11:55:01 INFO mapreduce.Job: Counters: 8 Job Counters Failed map tasks=1 Launched map tasks=1 Data-local map tasks=1 Total time spent by all maps in occupied slots (ms)=2855 Total time spent by all reduces in occupied slots (ms)=0 Total time spent by all map tasks (ms)=2855 Total vcore-seconds taken by all map tasks=2855 Total megabyte-seconds taken by all map tasks=2923520 18/07/23 11:55:01 WARN mapreduce.Counters: Group FileSystemCounters is deprecated. Use org.apache.hadoop.mapreduce.FileSystemCounter instead 18/07/23 11:55:01 INFO mapreduce.ExportJobBase: Transferred 0 bytes in 13.576 seconds (0 bytes/sec) 18/07/23 11:55:01 WARN mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead 18/07/23 11:55:01 INFO mapreduce.ExportJobBase: Exported 0 records. 18/07/23 11:55:01 ERROR tool.ExportTool: Error during export: Export job failed!
当我看到这个控制台打印的信息时,犹如一万只草泥马狂奔而过,这是什么鬼?只告诉你导出失败,任务中断了,错误信息呢?你看到是否是也是同样的感受呢?这该如何解决?从何入手呢?sql
通过两天的各类搞头,最后终于知道了如何解决这个问题,这个问题不是具体的问题,可是想要知道具体的错误信息,在控制台是看不到的,只能到CDH的web管理界面去看,以下就告诉你们CDH的管理界面怎么找到Sqoop的这个任务日志。apache
以下图:点击YAEN进入YARN的详情界面。有人会问,为何不是Sqoop的界面,Sqoop最终会转化为MR进行任务的执行,因此这里要看Sqoop的任务执行状况,仍是要到YARN的详情界面去看。bash
以下图为YARN的详情界面,须要点击应用程序目录,进入任务的执行结果列表中,能够看到各个执行的任务,以及执行的结果,下图明显看到有一个错误。根据以下的操做进入下一个页面。服务器
这个界面展现了单个任务的还算详细的任务信息,不过这不是咱们最终要找的界面,看到以下图框起来的logs超连接字段,点击进入下一个页面。app
看到这个界面,好像是找到了日志的界面,对不起,尚未,向下拉,你会看到如图的字样,这个页面只是展现了任务执行的流程,具体的错误信息还在另一个页面。点击如图here超连接的字样,进入下一个页面。ide
通过前面的几个页面,咱们终于进入了咱们想要看到的页面,咱们亲爱的错误页面,在这里,就能够看到这个任务的错误缘由,这样就能够根据错误信息解决问题了。这个页面展现的错误信息的解决方法,网上基本都有,能够根据错误信息自行查找了。oop
本人这里展示的问题,是由于Hive和MySQL的时间字段不匹配致使的,这里更改MySQL或者Hive的时间字段类型,让两边的类型保持一致,便可解决问题。
真的没想到,CDH会这么坑,这个问题,整整折磨了我两天,不过还好,最终仍是解决了,之后再遇到以后,就会能够当即解决了。