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