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

WBOY
풀어 주다: 2016-06-07 16:10:56
원래의
1338명이 탐색했습니다.

承接上节课,现在说说导出教程 检查连接 先看看有没有可用的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 里面建立一个表 employee
CREATE 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之间的通讯



后面还有很长的输出我就不贴了,如果有就继续往下做
관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!