java mysql 导入hbase_使用sqoop将MySQL数据库中的数据导入Hbase

-------------------------------------------------------------------------------------------------

MySQL导入HBase的日志:

[root@gd02 hadoop]#sqoop import --connect

jdbc:mysql://10.10.97.116:3306/rsearch --table researchers --hbase-table A --column-family person --hbase-row-key id --hbase-create-table --username 'root' -P

Enter password:

11/06/29 19:08:00 INFO tool.CodeGenTool: Beginning code generation

11/06/29 19:08:00 INFO manager.MySQLManager: Executing SQL statement: SELECT t.* FROM `researchers` AS t LIMIT 1

11/06/29 19:08:00 INFO manager.MySQLManager: Executing SQL statement: SELECT t.* FROM `researchers` AS t LIMIT 1

11/06/29 19:08:00 INFO orm.CompilationManager: HADOOP_HOME is /usr/lib/hadoop

11/06/29 19:08:00 INFO orm.CompilationManager: Found hadoop core jar at: /usr/lib/hadoop/hadoop-core.jar

Note: /tmp/sqoop-root/compile/d4dd4cb4e1e325fce31ca72c00a5589c/researchers.java uses or overrides a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

11/06/29 19:08:02 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-root/compile/d4dd4cb4e1e325fce31ca72c00a5589c/researchers.jar

11/06/29 19:08:02 WARN manager.MySQLManager: It looks like you are importing from mysql.

11/06/29 19:08:02 WARN manager.MySQLManager: This transfer can be faster! Use the --direct

11/06/29 19:08:02 WARN manager.MySQLManager: option to exercise a MySQL-specific fast path.

11/06/29 19:08:02 INFO manager.MySQLManager: Setting zero DATETIME behavior to convertToNull (mysql)

11/06/29 19:08:02 INFO mapreduce.ImportJobBase: Beginning import of researchers

11/06/29 19:08:02 INFO manager.MySQLManager: Executing SQL statement: SELECT t.* FROM `researchers` AS t LIMIT 1

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:zookeeper.version=3.3.3-cdh3u0--1, built on 03/26/2011 00:21 GMT

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:host.name=gd02

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:java.version=1.6.0_13

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:java.vendor=Sun Microsystems Inc.

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:java.home=/usr/java/jdk1.6.0_13/jre

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:java.class.path=/usr/lib/hadoop/conf:/usr/java/jdk1.6.0_13/lib/tools.jar:/usr/lib/hadoop:/usr/lib/hadoop/hadoop-core-0.20.2-cdh3u0.jar:/usr/lib/hadoop/lib/ant-contrib-1.0b3.jar:/usr/lib/hadoop/lib/aspectjrt-1.6.5.jar:/usr/lib/hadoop/lib/aspectjtools-1.6.5.jar:/usr/lib/hadoop/lib/commons-cli-1.2.jar:/usr/lib/hadoop/lib/commons-codec-1.4.jar:/usr/lib/hadoop/lib/commons-daemon-1.0.1.jar:/usr/lib/hadoop/lib/commons-el-1.0.jar:/usr/lib/hadoop/lib/commons-httpclient-3.0.1.jar:/usr/lib/hadoop/lib/commons-logging-1.0.4.jar:/usr/lib/hadoop/lib/commons-logging-api-1.0.4.jar:/usr/lib/hadoop/lib/commons-net-1.4.1.jar:/usr/lib/hadoop/lib/core-3.1.1.jar:/usr/lib/hadoop/lib/hadoop-fairscheduler-0.20.2-cdh3u0.jar:/usr/lib/hadoop/lib/hsqldb-1.8.0.10.jar:/usr/lib/hadoop/lib/jackson-core-asl-1.5.2.jar:/usr/lib/hadoop/lib/jackson-mapper-asl-1.5.2.jar:/usr/lib/hadoop/lib/jasper-compiler-5.5.12.jar:/usr/lib/hadoop/lib/jasper-runtime-5.5.12.jar:/usr/lib/hadoop/lib/jets3t-0.6.1.jar:/usr/lib/hadoop/lib/jetty-6.1.26.jar:/usr/lib/hadoop/lib/jetty-servlet-tester-6.1.26.jar:/usr/lib/hadoop/lib/jetty-util-6.1.26.jar:/usr/lib/hadoop/lib/jsch-0.1.42.jar:/usr/lib/hadoop/lib/junit-4.5.jar:/usr/lib/hadoop/lib/kfs-0.2.2.jar:/usr/lib/hadoop/lib/log4j-1.2.15.jar:/usr/lib/hadoop/lib/mockito-all-1.8.2.jar:/usr/lib/hadoop/lib/oro-2.0.8.jar:/usr/lib/hadoop/lib/servlet-api-2.5-20081211.jar:/usr/lib/hadoop/lib/servlet-api-2.5-6.1.14.jar:/usr/lib/hadoop/lib/slf4j-api-1.4.3.jar:/usr/lib/hadoop/lib/slf4j-log4j12-1.4.3.jar:/usr/lib/hadoop/lib/xmlenc-0.52.jar:/usr/lib/hadoop/lib/jsp-2.1/jsp-2.1.jar:/usr/lib/hadoop/lib/jsp-2.1/jsp-api-2.1.jar:/usr/lib/sqoop/conf:/usr/lib/hbase/conf::/usr/lib/sqoop/lib/ant-contrib-1.0b3.jar:/usr/lib/sqoop/lib/ant-eclipse-1.0-jvm1.2.jar:/usr/lib/sqoop/lib/commons-io-1.4.jar:/usr/lib/sqoop/lib/hadoop-mrunit-0.20.2-CDH3b2-SNAPSHOT.jar:/usr/lib/sqoop/lib/ivy-2.0.0-rc2.jar:/usr/lib/sqoop/lib/mysql-connector-java-5.1.10.jar:/usr/lib/hbase/hbase-0.90.1-cdh3u0.jar:/usr/lib/hbase/hbase-0.90.1-cdh3u0-tests.jar:/usr/lib/hbase/lib/activation-1.1.jar:/usr/lib/hbase/lib/asm-3.1.jar:/usr/lib/hbase/lib/avro-1.3.3.jar:/usr/lib/hbase/lib/commons-cli-1.2.jar:/usr/lib/hbase/lib/commons-codec-1.4.jar:/usr/lib/hbase/lib/commons-el-1.0.jar:/usr/lib/hbase/lib/commons-httpclient-3.1.jar:/usr/lib/hbase/lib/commons-lang-2.5.jar:/usr/lib/hbase/lib/commons-logging-1.1.1.jar:/usr/lib/hbase/lib/commons-net-1.4.1.jar:/usr/lib/hbase/lib/core-3.1.1.jar:/usr/lib/hbase/lib/guava-r06.jar:/usr/lib/hbase/lib/hadoop-core.jar:/usr/lib/hbase/lib/hbase-0.90.1-cdh3u0.jar:/usr/lib/hbase/lib/jackson-core-asl-1.5.2.jar:/usr/lib/hbase/lib/jackson-jaxrs-1.5.5.jar:/usr/lib/hbase/lib/jackson-mapper-asl-1.5.2.jar:/usr/lib/hbase/lib/jackson-xc-1.5.5.jar:/usr/lib/hbase/lib/jasper-compiler-5.5.23.jar:/usr/lib/hbase/lib/jasper-runtime-5.5.23.jar:/usr/lib/hbase/lib/jaxb-api-2.1.jar:/usr/lib/hbase/lib/jaxb-impl-2.1.12.jar:/usr/lib/hbase/lib/jersey-core-1.4.jar:/usr/lib/hbase/lib/jersey-json-1.4.jar:/usr/lib/hbase/lib/jersey-server-1.4.jar:/usr/lib/hbase/lib/jettison-1.1.jar:/usr/lib/hbase/lib/jetty-6.1.26.jar:/usr/lib/hbase/lib/jetty-util-6.1.26.jar:/usr/lib/hbase/lib/jruby-complete-1.0.3.jar:/usr/lib/hbase/lib/jsp-2.1-6.1.14.jar:/usr/lib/hbase/lib/jsp-api-2.1-6.1.14.jar:/usr/lib/hbase/lib/jsp-api-2.1.jar:/usr/lib/hbase/lib/jsr311-api-1.1.1.jar:/usr/lib/hbase/lib/log4j-1.2.16.jar:/usr/lib/hbase/lib/protobuf-java-2.3.0.jar:/usr/lib/hbase/lib/servlet-api-2.5-6.1.14.jar:/usr/lib/hbase/lib/servlet-api-2.5.jar:/usr/lib/hbase/lib/slf4j-api-1.5.8.jar:/usr/lib/hbase/lib/slf4j-log4j12-1.5.8.jar:/usr/lib/hbase/lib/stax-api-1.0.1.jar:/usr/lib/hbase/lib/thrift-0.2.0.jar:/usr/lib/hbase/lib/xmlenc-0.52.jar:/usr/lib/hbase/lib/zookeeper.jar:/usr/lib/zookeeper/zookeeper-3.3.3-cdh3u0.jar:/usr/lib/zookeeper/zookeeper.jar:/usr/lib/zookeeper/lib/jline-0.9.94.jar:/usr/lib/zookeeper/lib/log4j-1.2.15.jar:/usr/lib/sqoop/sqoop-1.2.0-cdh3u0.jar:/usr/lib/sqoop/sqoop-test-1.2.0-cdh3u0.jar:

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:java.library.path=/usr/java/jdk1.6.0_13/jre/lib/amd64/server:/usr/java/jdk1.6.0_13/jre/lib/amd64:/usr/java/jdk1.6.0_13/jre/../lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/lib

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:java.io.tmpdir=/tmp

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:java.compiler=

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:os.name=Linux

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:os.arch=amd64

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:os.version=2.6.18-164.el5

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:user.name=root

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:user.home=/root

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Client environment:user.dir=/home/hadoop

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=gd05:2181,gd03:2181,gd02:2181 sessionTimeout=180000 watcher=hconnection

11/06/29 19:08:02 INFO zookeeper.ClientCnxn: Opening socket connection to server gd03/10.10.104.3:2181

11/06/29 19:08:02 INFO zookeeper.ClientCnxn: Socket connection established to gd03/10.10.104.3:2181, initiating session

11/06/29 19:08:02 INFO zookeeper.ClientCnxn: Session establishment complete on server gd03/10.10.104.3:2181, sessionid = 0x130b2e901cd0012, negotiated timeout = 180000

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=gd05:2181,gd03:2181,gd02:2181 sessionTimeout=180000 watcher=hconnection

11/06/29 19:08:02 INFO zookeeper.ClientCnxn: Opening socket connection to server gd03/10.10.104.3:2181

11/06/29 19:08:02 INFO zookeeper.ClientCnxn: Socket connection established to gd03/10.10.104.3:2181, initiating session

11/06/29 19:08:02 INFO zookeeper.ClientCnxn: Session establishment complete on server gd03/10.10.104.3:2181, sessionid = 0x130b2e901cd0013, negotiated timeout = 180000

11/06/29 19:08:02 INFO client.HConnectionManager$HConnectionImplementation: Closed zookeeper sessionid=0x130b2e901cd0013

11/06/29 19:08:02 INFO zookeeper.ZooKeeper: Session: 0x130b2e901cd0013 closed

11/06/29 19:08:02 INFO zookeeper.ClientCnxn: EventThread shut down

11/06/29 19:08:02 INFO mapreduce.HBaseImportJob: Creating missing column family person

11/06/29 19:08:02 INFO client.HBaseAdmin: Started disable of A

11/06/29 19:08:03 INFO client.HBaseAdmin: Disabled A

11/06/29 19:08:03 INFO client.HBaseAdmin: Started enable of A

11/06/29 19:08:06 INFO client.HBaseAdmin: Enabled table A

11/06/29 19:08:07 INFO mapred.JobClient: Running job: job_201106212352_0010

11/06/29 19:08:08 INFO mapred.JobClient:  map 0% reduce 0%

11/06/29 19:08:19 INFO mapred.JobClient:  map 40% reduce 0%

11/06/29 19:08:20 INFO mapred.JobClient:  map 80% reduce 0%

11/06/29 19:08:34 INFO mapred.JobClient:  map 100% reduce 0%

11/06/29 19:08:34 INFO mapred.JobClient: Job complete: job_201106212352_0010

11/06/29 19:08:34 INFO mapred.JobClient: Counters: 11

11/06/29 19:08:34 INFO mapred.JobClient:   Job Counters

11/06/29 19:08:34 INFO mapred.JobClient:     SLOTS_MILLIS_MAPS=82848

11/06/29 19:08:34 INFO mapred.JobClient:     Total time spent by all reduces waiting after reserving slots (ms)=0

11/06/29 19:08:34 INFO mapred.JobClient:     Total time spent by all maps waiting after reserving slots (ms)=0

11/06/29 19:08:34 INFO mapred.JobClient:     Launched map tasks=5

11/06/29 19:08:34 INFO mapred.JobClient:     SLOTS_MILLIS_REDUCES=0

11/06/29 19:08:34 INFO mapred.JobClient:   FileSystemCounters

11/06/29 19:08:34 INFO mapred.JobClient:     HDFS_BYTES_READ=527

11/06/29 19:08:34 INFO mapred.JobClient:     FILE_BYTES_WRITTEN=310685

11/06/29 19:08:34 INFO mapred.JobClient:   Map-Reduce Framework

11/06/29 19:08:34 INFO mapred.JobClient:     Map input records=81868

11/06/29 19:08:34 INFO mapred.JobClient:     Spilled Records=0

11/06/29 19:08:34 INFO mapred.JobClient:     Map output records=81868

11/06/29 19:08:34 INFO mapred.JobClient:     SPLIT_RAW_BYTES=527

11/06/29 19:08:34 INFO mapreduce.ImportJobBase: Transferred 0 bytes in 28.108 seconds (0 bytes/sec)

11/06/29 19:08:34 INFO mapreduce.ImportJobBase: Retrieved 81868 records.

參考资料:

利用sqoop将mysql数据同步到hive手记

http://www.54chen.com/java-ee/sqoop-mysql-to-hive.html

利用Sqoop将数据从数据库导入到HDFS

http://www.cnblogs.com/gpcuster/archive/2011/03/01/1968027.html

Sqoop

http://www.duyifan.com/

MySQL向Hive/HBase的迁移工具

http://www.javabloger.com/article/hadoop-hive-mysql-sqoop.html

官方手冊

  • 0
    点赞
  • 0
    收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:1024 设计师:我叫白小胖 返回首页
评论

打赏作者

weixin_39928667

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值