Table of Contents
检查连接
准备数据
mysql数据表准备
hadoop文件准备
导出
Home Database Mysql Tutorial Alex的Hadoop菜鸟教程:第7课Sqoop2导出教程

Alex的Hadoop菜鸟教程:第7课Sqoop2导出教程

Jun 07, 2016 pm 04:10 PM
hadoop Export Tutorial rookie

承接上节课,现在说说导出教程 检查连接 先看看有没有可用的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:
Copy after login


后面还有很长的输出我就不贴了,如果有就继续往下做

准备数据

mysql数据表准备

先在mysql 里面建立一个表 employee
CREATE TABLE `employee` (    
  `id` int(11) NOT NULL,    
  `name` varchar(20) NOT NULL,    
  PRIMARY KEY (`id`)    
) ENGINE=MyISAM  DEFAULT CHARSET=utf8; 
Copy after login

hadoop文件准备

在hadoop里面建立数据文件 先建立一个文件 part-m-00000 内容是
1,'michael'
Copy after login

把他们放到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
Copy after login

导出

create job --xid 1 --type export
Copy after login

接下来按照提示输入

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
Copy after login

执行这个任务

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
Copy after login

然后等一会儿,再去看mysql的employee表就有一条michael 的记录了

下节课说下sqoop跟Hbase之间的通讯



后面还有很长的输出我就不贴了,如果有就继续往下做
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Tutorial on how to use Dewu Tutorial on how to use Dewu Mar 21, 2024 pm 01:40 PM

Tutorial on how to use Dewu

How to get Douyin private message emoticons on WeChat? How to export the private message emoticon package? How to get Douyin private message emoticons on WeChat? How to export the private message emoticon package? Mar 21, 2024 pm 10:01 PM

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 How to export xmind files to pdf files Mar 20, 2024 am 10:30 AM

How to export xmind files to pdf files

Tutorial on how to turn off the payment sound on WeChat Tutorial on how to turn off the payment sound on WeChat Mar 26, 2024 am 08:30 AM

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 How to export the cross-section diagram in Kujiale_How to export the cross-section diagram in Kujiale Apr 02, 2024 pm 06:01 PM

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 What software is photoshopcs5? -photoshopcs5 usage tutorial Mar 19, 2024 am 09:04 AM

What software is photoshopcs5? -photoshopcs5 usage tutorial

Experts teach you! The Correct Way to Cut Long Pictures on Huawei Mobile Phones Experts teach you! The Correct Way to Cut Long Pictures on Huawei Mobile Phones Mar 22, 2024 pm 12:21 PM

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

In summer, you must try shooting a rainbow In summer, you must try shooting a rainbow Jul 21, 2024 pm 05:16 PM

In summer, you must try shooting a rainbow

See all articles