百度智能云

All Product Document

          MapReduce

          Export Data

          Data Export by Sqoop

          After BMR is used to analyze the data, the result data is saved under the specified directory of BOS, and you can go to BOS to export the result data. For more information, please see BOS Downloads Object.

          You can use Sqoop to export data in BOS or HDFS to Relational Database Service (RDS). The specific operation steps are as follows:

          Export Data from BOS to Relational Database Service (RDS)

          1. Create a data table in the Relational Database Service (RDS). Please be noted that the data table has the same field type as the data to export; otherwise, the exception can occur during the export. The data is connected to RDS before creation. For more information, please see Connect RDS Instance.
          2. Use SSH to connect to the master node. For more information, please see SSH Connection to Cluster.
          3. Enter command: su hdfs. Switch to HDFS user.
          4. Execute the command: sqoop export --connect jdbc:mysql://address:port/db_name --table export_table_name --username XX --password XX --export-dir XX Example: sqoop export --connect jdbc:mysql://mysql56.rdsmiy5q77jfaqp.rds.bj.baidubce.com:3306/sqoop --table test --username sqoop --password sqoop_123 --export-dir bos://abc/sqooptest
          5. You can view the execution outcome in PHP Admin interface of RDS.

          Export Data from HDFS to Relational Database Service (RDS)

          1. Execute steps 1 to 3 in Export Data from BOS to Relational Database Service (RDS).
          2. Execute the command:

            sqoop export --connect jdbc:mysql://address:port/db_name --table export_table_name --username XX --password XX --export-dir XX

            Example: sqoop import --connect jdbc:mysql://mysql56.rdsmiy5q77jfaqp.rds.bj.baidubce.com:3306/sqoop --table test --username sqoop --password sqoop_123 --export-dir /user/hdfs/sqooptest

          3. Execute step 5 in Export Data from BOS to Relational Database Service (RDS).
          Parameters Parameter Description
          address and port Address and port number of RDS instance. Obtain it from the basic information of the RDS instance. For more information, please see Connect RDS Instance.
          db_name Name of database which contains data to export. For how to create Relational Database Service (RDS) instance, please see Create Database.
          table_name Name of the data table, which contains data to export. If you need to create a data table, please log in to the RDS instance. For more information, please see Connect RDS Instance.
          --username and --password Account, and password of database which contains data to export. Obtain information from the RDS instance. For more information, please see Administer Database Accounts.
          --export-dir Target address of data export, which is the path of BOS or HDFS.
          Previous
          Import Data
          Next
          Store Data to HBase