Alex's Hadoop cainiao Tutorial: 7th Sqoop2 export tutorial, hadoopsqoop2
Take over the previous lesson. Now let's talk about the export tutorial.
Check connection
First, check whether there are available connection connections. If not, create a connection based on the method of the previous lesson.
sqoop:000> show connector --all1 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:
I will not post a long output later. If so, I will continue to do so.
Prepare the data mysql Data Table prepare to create a table "employee" in mysql
CREATE TABLE `employee` ( `id` int(11) NOT NULL, `name` varchar(20) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Hadoop files are ready to create data files in hadoop first create a file part-m-00000 content is
1,'michael'
Put them in hadoop
# hdfs dfs -mkdir /user/alex# hdfs dfs -put part-m-00000 /user/alex/# hdfs dfs -ls /user/alexFound 1 items-rw-r--r-- 2 root supergroup 20 2014-11-27 18:26 /user/alex/part-m-00000
Export
create job --xid 1 --type export
Follow the prompts to enter
sqoop:000> create job --xid 1 --type exportCreating job for connection with id 1Please fill following values to create new job objectName: export to employeeDatabase configurationSchema name: Table name: employeeTable SQL statement: Table column names: Stage table name: Clear stage table: Input configurationInput directory: /user/alexThrottling resourcesExtractors: Loaders: New job was successfully created with validation status FINE and persistent id 3
Execute this task
sqoop:000> start job --jid 3Submission detailsJob ID: 3Server URL: http://localhost:12000/sqoop/Created by: rootCreation date: 2014-11-27 18:29:27 CSTLastly updated by: rootExternal ID: job_1406097234796_0008http://xmseapp01:8088/proxy/application_1406097234796_0008/2014-11-27 18:29:27 CST: BOOTING - Progress is not available
Then wait a moment and check the mysql employee table and there will be a michael record.
Communication between sqoop and Hbase in the next lesson
I will not post a long output later. If so, I will continue to do so.