Sqoop testing the use of MySQL database

Source: Internet
Author: User
Tags sqoop

Test The use of Mysql database Prerequisite: Import the MySQL jdbc jar package ① Testing the database connection
Sqoop list-databases–connect jdbc:mysql://192.168.10.63–username Root–password 123456

use of ②sqoop
All of the following commands have a space after each line, and do not forget
(None of the following 6 commands have been successfully tested) <1>mysql–>hdfs
Sqoop Export–connect
Jdbc:mysql://192.168.10.63/ipj
–username Root
–password 123456
–table Ipj_flow_user
–export-dir hdfs://192.168.10.63:8020/user/flow/part-m-00000
Premise:
(1) The directory/user/flow/part-m-00000 in HDFs must exist
(2) If the cluster set compression mode Lzo, then the machine must be installed and configured successfully Lzo
(3) Each node in the Hadoop cluster must have operation rights to MySQL <2>hdfs–>mysql
Sqoop Import–connect
Jdbc:mysql://192.168.10.63/ipj
–table Ipj_flow_user<3>mysql–>hbase
Sqoop Import–connect
Jdbc:mysql://192.168.10.63/ipj
–table Ipj_flow_user
–hbase-table Ipj_statics_test
–hbase-create-table
–hbase-row-key ID
–column-family Imei<4>hbase–>mysql
About importing hbase data into MySQL, Sqoop is not directly supported, generally using the following 3 ways:
The first: Flatten HBase data into an HDFs file and then import it by Sqoop.
The second is to import hbase data into the hive table before importing MySQL.
Third: Read the table data directly using HBase's Java API and import it directly to MySQL
No need to use Sqoop. <5>mysql–>hive
Sqoop Import–connect
Jdbc:mysql://192.168.10.63/ipj
–table Hive_table_test
–hive-import
–hive-table hive_test_table or –create-hive-tablehive_test_table<6>hive–>mysql
Sqoop Export–connect
Jdbc:mysql://192.168.10.63/ipj
–username Hive
–password 123456
–table target_table
–export-dir/user/hive/warehouse/uv/dt=mytable
Prerequisite: The table in MySQL must exist
③ Sqoop Other operations
<1>ListMySQLall databases in
Sqoop List-databases–connect Jdbc:mysql://192.168.10.63:3306/–usernameroot–password 123456
<2>ListMySQLall tables under one of the libraries
Sqoop List-tables–connect Jdbc:mysql://192.168.10.63:3306/ipj–usernameroot–password 123456
For more highlights, please follow: http://bbs.superwu.cn
Focus on the two-dimensional code of Superman Academy:

Sqoop testing the use of MySQL database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.