13/07/29 02:33:03 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
13/07/29 02:33:03 INFO filecache.TrackerDistributedCacheManager: Creating mysql-connector-java-5.0.8-bin.jar in /tmp/hadoop-june/mapred/local/archive/-8943686319031389138_-1232673160_640840668/192.168.1.101/tmp-work--8372797484204470322 with rwxr-xr-x
13/07/29 02:33:03 INFO filecache.TrackerDistributedCacheManager: Cached hdfs://192.168.1.101:9000/tmp/mysql-connector-java-5.0.8-bin.jar as /tmp/hadoop-june/mapred/local/archive/-8943686319031389138_-1232673160_640840668/192.168.1.101/tmp/mysql-connector-java-5.0.8-bin.jar
13/07/29 02:33:03 INFO filecache.TrackerDistributedCacheManager: Cached hdfs://192.168.1.101:9000/tmp/mysql-connector-java-5.0.8-bin.jar as /tmp/hadoop-june/mapred/local/archive/-8943686319031389138_-1232673160_640840668/192.168.1.101/tmp/mysql-connector-java-5.0.8-bin.jar
13/07/29 02:33:03 INFO mapred.JobClient: Running job: job_local_0001
13/07/29 02:33:03 INFO mapred.MapTask: numReduceTasks: 1
13/07/29 02:33:03 INFO mapred.MapTask: io.sort.mb = 100
13/07/29 02:33:03 INFO mapred.MapTask: data buffer = 79691776/99614720
13/07/29 02:33:03 INFO mapred.MapTask: record buffer = 262144/327680
13/07/29 02:33:03 INFO mapred.MapTask: Starting flush of map output
13/07/29 02:33:03 INFO mapred.MapTask: Finished spill 0
13/07/29 02:33:03 INFO mapred.Task: Task:attempt_local_0001_m_000000_0 is done. And is in the process of commiting
13/07/29 02:33:04 INFO mapred.JobClient: map 0% reduce 0%
13/07/29 02:33:06 INFO mapred.LocalJobRunner:
13/07/29 02:33:06 INFO mapred.Task: Task 'attempt_local_0001_m_000000_0' done.
13/07/29 02:33:06 INFO mapred.LocalJobRunner:
13/07/29 02:33:06 INFO mapred.Merger: Merging 1 sorted segments
13/07/29 02:33:06 INFO mapred.Merger: Down to the last merge-pass, with 1 segments left of total size: 235 bytes
13/07/29 02:33:06 INFO mapred.LocalJobRunner:
13/07/29 02:33:06 INFO mapred.Task: Task:attempt_local_0001_r_000000_0 is done. And is in the process of commiting
13/07/29 02:33:07 INFO mapred.JobClient: map 100% reduce 0%
13/07/29 02:33:09 INFO mapred.LocalJobRunner: reduce > reduce
13/07/29 02:33:09 INFO mapred.Task: Task 'attempt_local_0001_r_000000_0' done.
13/07/29 02:33:09 WARN mapred.FileOutputCommitter: Output path is null in cleanup
13/07/29 02:33:10 INFO mapred.JobClient: map 100% reduce 100%
13/07/29 02:33:10 INFO mapred.JobClient: Job complete: job_local_0001
13/07/29 02:33:10 INFO mapred.JobClient: Counters: 18
13/07/29 02:33:10 INFO mapred.JobClient: File Input Format Counters
13/07/29 02:33:10 INFO mapred.JobClient: Bytes Read=0
13/07/29 02:33:10 INFO mapred.JobClient: File Output Format Counters
13/07/29 02:33:10 INFO mapred.JobClient: Bytes Written=0
13/07/29 02:33:10 INFO mapred.JobClient: FileSystemCounters
13/07/29 02:33:10 INFO mapred.JobClient: FILE_BYTES_READ=1211691
13/07/29 02:33:10 INFO mapred.JobClient: HDFS_BYTES_READ=1081704
13/07/29 02:33:10 INFO mapred.JobClient: FILE_BYTES_WRITTEN=2392844
13/07/29 02:33:10 INFO mapred.JobClient: Map-Reduce Framework
13/07/29 02:33:10 INFO mapred.JobClient: Map output materialized bytes=239
13/07/29 02:33:10 INFO mapred.JobClient: Map input records=13
13/07/29 02:33:10 INFO mapred.JobClient: Reduce shuffle bytes=0
13/07/29 02:33:10 INFO mapred.JobClient: Spilled Records=26
13/07/29 02:33:10 INFO mapred.JobClient: Map output bytes=207
13/07/29 02:33:10 INFO mapred.JobClient: Map input bytes=13
13/07/29 02:33:10 INFO mapred.JobClient: SPLIT_RAW_BYTES=75
13/07/29 02:33:10 INFO mapred.JobClient: Combine input records=0
13/07/29 02:33:10 INFO mapred.JobClient: Reduce input records=13
13/07/29 02:33:10 INFO mapred.JobClient: Reduce input groups=13
13/07/29 02:33:10 INFO mapred.JobClient: Combine output records=0
13/07/29 02:33:10 INFO mapred.JobClient: Reduce output records=13
13/07/29 02:33:10 INFO mapred.JobClient: Map output records=13
复制代码
MapReduce直接连接Mysql获取数据
Mysql中数据:
mysql> select * from lxw_tbls;
+---------------------+----------------+
| TBL_NAME | TBL_TYPE |
+---------------------+----------------+
| lxw_test_table | EXTERNAL_TABLE |
| lxw_t | MANAGED_TABLE |
| lxw_t1 | MANAGED_TABLE |
| tt | MANAGED_TABLE |
| tab_partition | MANAGED_TABLE |
| lxw_hbase_table_1 | MANAGED_TABLE |
| lxw_hbase_user_info | MANAGED_TABLE |
| t | EXTERNAL_TABLE |
| lxw_jobid | MANAGED_TABLE |
+---------------------+----------------+
9 rows in set (0.01 sec)
mysql> select * from lxw_tbls where TBL_NAME like 'lxw%' order by TBL_NAME;
在hadoop2.5中写的mapreducer,读取mysql数据库中数据,但是报错了,有没有遇到过的?:
15/08/06 09:05:08 INFO mapreduce.Job: map 0% reduce 0%
[sshexec] 15/08/06 09:05:18 INFO mapreduce.Job: Task Id : attempt_1438866193653_0001_m_000001_0, Status : FAILED
[sshexec] Error: java.io.IOException: SQLException in nextKeyValue
[sshexec] at org.apache.hadoop.mapreduce.lib.db.DBRecordReader.nextKeyValue(DBRecordReader.java:239)
[sshexec] at org.apache.hadoop.mapred.MapTask$NewTrackingRecordReader.nextKeyValue(MapTask.java:533)
[sshexec] at org.apache.hadoop.mapreduce.task.MapContextImpl.nextKeyValue(MapContextImpl.java:80)
[sshexec] at org.apache.hadoop.mapreduce.lib.map.WrappedMapper$Context.nextKeyValue(WrappedMapper.java:91)
[sshexec] at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144)
[sshexec] at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
[sshexec] at org.apache.hadoop.mapred.MapTask.run(MapTask.java:340)
[sshexec] at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168)
[sshexec] at java.security.AccessController.doPrivileged(Native Method)
[sshexec] at javax.security.auth.Subject.doAs(Subject.java:415)
[sshexec] at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1614)
[sshexec] at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:163)
[sshexec] Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 2 OFFSET 0' at line 1
[sshexec] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[sshexec] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
[sshexec] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[sshexec] at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
[sshexec] at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
[sshexec] at com.mysql.jdbc.Util.getInstance(Util.java:386)
[sshexec] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
[sshexec] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)