Alex的Hadoop菜鸟教程:第7课Sqoop2导出教程
Jun 07, 2016 pm 04:10 PM承接上节课,现在说说导出教程 检查连接 先看看有没有可用的connection 连接,如果没有就要根据上节课的方法创建一个 sqoop:000 show connector --all1 connector(s) to show: Connector with id 1: Name: generic-jdbc-connector Class: org.apache.sqoop.c
承接上节课,现在说说导出教程
检查连接
先看看有没有可用的connection 连接,如果没有就要根据上节课的方法创建一个
sqoop:000> show connector --all 1 connector(s) to show: Connector with id 1: Name: generic-jdbc-connector Class: org.apache.sqoop.connector.jdbc.GenericJdbcConnector Version: 1.99.3-cdh5.0.1 Supported job types: [EXPORT, IMPORT] Connection form 1:
后面还有很长的输出我就不贴了,如果有就继续往下做
准备数据
mysql数据表准备
先在mysql 里面建立一个表 employeeCREATE TABLE `employee` ( `id` int(11) NOT NULL, `name` varchar(20) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
hadoop文件准备
在hadoop里面建立数据文件 先建立一个文件 part-m-00000 内容是1,'michael'
把他们放到hadoop里面
# hdfs dfs -mkdir /user/alex # hdfs dfs -put part-m-00000 /user/alex/ # hdfs dfs -ls /user/alex Found 1 items -rw-r--r-- 2 root supergroup 20 2014-11-27 18:26 /user/alex/part-m-00000
导出
create job --xid 1 --type export
接下来按照提示输入
sqoop:000> create job --xid 1 --type export Creating job for connection with id 1 Please fill following values to create new job object Name: export to employee Database configuration Schema name: Table name: employee Table SQL statement: Table column names: Stage table name: Clear stage table: Input configuration Input directory: /user/alex Throttling resources Extractors: Loaders: New job was successfully created with validation status FINE and persistent id 3
sqoop:000> start job --jid 3 Submission details Job ID: 3 Server URL: http://localhost:12000/sqoop/ Created by: root Creation date: 2014-11-27 18:29:27 CST Lastly updated by: root External ID: job_1406097234796_0008 http://xmseapp01:8088/proxy/application_1406097234796_0008/ 2014-11-27 18:29:27 CST: BOOTING - Progress is not available
然后等一会儿,再去看mysql的employee表就有一条michael 的记录了
下节课说下sqoop跟Hbase之间的通讯

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to get Douyin private message emoticons on WeChat? How to export the private message emoticon package?

How to export xmind files to pdf files

Tutorial on how to turn off the payment sound on WeChat

How to export the cross-section diagram in Kujiale_How to export the cross-section diagram in Kujiale

What software is photoshopcs5? -photoshopcs5 usage tutorial

Experts teach you! The Correct Way to Cut Long Pictures on Huawei Mobile Phones

In summer, you must try shooting a rainbow
