Alex的Hadoop菜鸟教程:第8课Sqoop1安装/导入/导出教程(四)

2015-02-03 11:59:17 · 作者: · 浏览: 269
p 100% reduce 0% 14/12/01 14:16:20 INFO mapreduce.Job: Job job_1406097234796_0019 completed successfully 14/12/01 14:16:21 INFO mapreduce.Job: Counters: 30 File System Counters FILE: Number of bytes read=0 FILE: Number of bytes written=99855 FILE: Number of read operations=0 FILE: Number of large read operations=0 FILE: Number of write operations=0 HDFS: Number of bytes read=87 HDFS: Number of bytes written=16 HDFS: Number of read operations=4 HDFS: Number of large read operations=0 HDFS: Number of write operations=2 Job Counters Launched map tasks=1 Other local map tasks=1 Total time spent by all maps in occupied slots (ms)=8714 Total time spent by all reduces in occupied slots (ms)=0 Total time spent by all map tasks (ms)=8714 Total vcore-seconds taken by all map tasks=8714 Total megabyte-seconds taken by all map tasks=8923136 Map-Reduce Framework Map input records=2 Map output records=2 Input split bytes=87 Spilled Records=0 Failed Shuffles=0 Merged Map outputs=0 GC time elapsed (ms)=58 CPU time spent (ms)=1560 Physical memory (bytes) snapshot=183005184 Virtual memory (bytes) snapshot=704577536 Total committed heap usage (bytes)=148897792 File Input Format Counters Bytes Read=0 File Output Format Counters Bytes Written=16 14/12/01 14:16:21 INFO mapreduce.ImportJobBase: Transferred 16 bytes in 33.6243 seconds (0.4758 bytes/sec) 14/12/01 14:16:21 INFO mapreduce.ImportJobBase: Retrieved 2 records.
查看一下结果
# hdfs dfs -ls /user/test
Found 2 items
-rw-r--r--   2 root supergroup          0 2014-12-01 14:16 /user/test/_SUCCESS
-rw-r--r--   2 root supergroup         16 2014-12-01 14:16 /user/test/part-m-00000
# hdfs dfs -cat /user/test/part-m-00000
1,michael
2,ted

我也不知道为什么mysql有3条数据,而导入了之后只有2条,有哪位懂的介绍下?

我遇到遇到的问题

如果你遇到以下问题
14/12/01 10:12:42 INFO mapreduce.Job: Task Id : attempt_1406097234796_0017_m_000000_0, Status : FAILED
Error: employee : Unsupported major.minor version 51.0
用ps aux| grep hadoop看下会发现hadoop用的是jdk1.6 。我的cdh是5.0.1 sqoop版本是 1.4.4 ,我遇到了这个问题。
原因:sqoop是使用jdk1.7编译的,所以如果你用 ps aux| grep hadoop 看到hadoop用的是1.6运行的,那sqoop不能正常工作 注意:CDH4.7以上已经兼容jdk1.7 ,但如果你是从4.5升级上来的会发现hadoop用的是jdk1.6,需要修改一下整个hadoop调用的jdk为1.7,而且这是官方推荐的搭配

关于改jdk的方法

官方提供了2个方法 http://www.cloudera.com/content/cloudera/en/documentation/cdh4/latest/CDH4-Requirements-and-Supported-Versions/cdhrsv_topic_3. html
这个是让你把 /usr/java/ 下建一个软链叫 default 指向你要的jdk,我这么做了,无效 http://www.cloudera.com/content/cloudera/en/documentation/archives/cloudera-manager-4/v4-5-3/Cloudera-Manager-Enterprise-Edition-Installation-Guide/cmeeig_topic_16_2.html
这个是叫你增加一个环境变量, 我这么做了,无效 最后我用了简单粗暴的办法:停掉所有相关服务,然后删掉那个该死的jdk1.6然后再重启,这回就用了 /usr/java/default 了
停掉所有hadoop相关服务的命令
for x in `cd /etc/init.d ; ls hive-*` ; do sudo service $x stop ; done
for x in `cd /etc/init.d ; ls hbase-*` ; do sudo service $x stop ; done
/etc/init.d/zookeeper-server stop
for x in `cd /etc/init.d ; ls hadoop-*` ; do sudo service $x stop ; done


zookeeper , hbase, hive 如果你们没装就跳过。建议你们用ps aux | grep jre1.6 去找找有什么服务,然后一个一个关掉,先关其他的,最后关hadoop
启动所有

for x in `cd /etc/init.d ; ls hadoop-*` ; do sudo service $x start ; done
/etc/init.d/zookeeper-server start
for x in `cd /etc/init.d ; ls hbase-*` ; do sudo service $x start ; done
for x in `cd /etc/init.d ; ls hive-*` ; do sudo service $x start ; done

从hdfs导出数据到mysql

接着这个例子做