--- title: "Migrate CDB MySQL Data" slug: "hadoop-vpc-use-ex4" tags: ["Cloud Hadoop", "VPC", "Cloud DB for MySQL"] updated: 2026-09-17T09:18:03Z published: 2026-09-17T09:18:03Z canonical: "guide.ncloud-docs.com/hadoop-vpc-use-ex4" stale: true --- > ## Documentation Index > Fetch the complete documentation index at: https://guide.ncloud-docs.com/llms.txt > Use this file to discover all available pages before exploring further. # Migrate CDB MySQL Data Available in VPC SQL to Hadoop (Sqoop) is a tool that supports efficient data transfer between relational databases and Hadoop. You can import data stored in RDBMS to HDFS for analysis. Conversely, you can export analysis results to RDBMS, and you can also transfer data to HDFS, Hive, HBase, and Accumulo. This guide introduces how to migrate data from NAVER Cloud Platform's Cloud DB for MySQL to Cloud Hadoop using Sqoop. For information on using Sqoop and its commands, see [Sqoop user guides](/docs/en/hadoop-vpc-15). ## Preliminary task 1. Create Object Storage. - For more information on how to create Object Storage, see [Object Storage user guide](/docs/en/storage-storage-6-1). 2. Create a Cloud Hadoop cluster. - For more information about how to create a Cloud Hadoop cluster, see [Getting started](/docs/en/hadoop-vpc-2) guide. 3. Create Cloud DB for MySQL. - For more information on how to create Cloud DB for MySQL, see [Getting started](/docs/en/clouddbformysql-start). ## Data migration using Sqoop Sqoop clients are installed by default on master node and data node servers, but not on edge node servers. You can proceed with migration without any separate installation. After accessing the server using the [Access a cluster node with SSH](/docs/en/hadoop-vpc-5) guide, follow these steps in order: - [1. Create a Sqoop account to access Cloud DB for MySQL](/docs/en/hadoop-vpc-use-ex4#1CloudDBforMySQL%EB%A1%9C%EC%A0%91%EC%86%8D%ED%95%A0Sqoop%EA%B3%84%EC%A0%95%EC%83%9D%EC%84%B1) - [2. Set ACG](/docs/en/hadoop-vpc-use-ex4#2ACG%EC%84%A4%EC%A0%95) - [3. Create a sample table and data](/docs/en/hadoop-vpc-use-ex4#3%EC%83%98%ED%94%8C%ED%85%8C%EC%9D%B4%EB%B8%94%EB%B0%8F%EB%8D%B0%EC%9D%B4%ED%84%B0%EC%83%9D%EC%84%B1) - [4. Migrate data with the Sqoop command](/docs/en/hadoop-vpc-use-ex4#4Sqoop%EB%AA%85%EB%A0%B9%EC%96%B4%EB%A1%9C%EB%8D%B0%EC%9D%B4%ED%84%B0%EB%A7%88%EC%9D%B4%EA%B7%B8%EB%A0%88%EC%9D%B4%EC%85%98) ### 1. Create a Sqoop account to access Cloud DB for MySQL Use the [Manage DB user](/docs/en/database-database-5-2#db-user-%EA%B4%80%EB%A6%AC) menu in Cloud DB for MySQL console to create an account for Cloud DB for MySQL by entering the configuration information. You can view the private IP of Cloud Hadoop servers in the **Hosts** menu of [Ambari UI](/docs/en/hadoop-vpc-7#web-ui-%EC%A0%91%EC%86%8D). Example: DB configuration information - User_ID: mig_acct - Host (IP): IP range of the Cloud Hadoop server. - Example: 10.10.10.% - Password: Set as desired. ![hadoop-chadoop-use-ex4_1-1_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/hadoop-chadoop-use-ex4_1-1_en.png?sv=2026-02-06&spr=https&st=2026-11-17T06%3A09%3A31Z&se=2026-11-17T07%3A09%3A31Z&sr=b&sp=r&sig=p5YNW0fdi%2FAYtVSjQjyKDSu7vxllCDnpoLyLuXmN9vM%3D) ### 2. Set ACG [Set ACG](/docs/en/server-acg-classic) so that the Cloud Hadoop Master Node 2 server can access Cloud DB for MySQL. - Add the Cloud Hadoop Master Node 2 server IP to the access source in the Cloud DB ACG settings. ![cloudhadoop-set-acg1_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/cloudhadoop-set-acg1_en.png?sv=2026-02-06&spr=https&st=2026-11-17T06%3A09%3A31Z&se=2026-11-17T07%3A09%3A31Z&sr=b&sp=r&sig=HV1TK1j9UNEFLyh2AyB6SnanBrJnSlIQSQNs587%2FsnA%3D) ### 3. Create a sample table and data Enter the example sample table and data into the created Cloud DB for MySQL. - Create a database for testing in the Cloud DB for MySQL console. ![cloudhadoop-set-createdb1](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/cloudhadoop-set-createdb1.png?sv=2026-02-06&spr=https&st=2026-11-17T06%3A09%3A31Z&se=2026-11-17T07%3A09%3A31Z&sr=b&sp=r&sig=%2F9dz24SfmUVkeVs%2BSnHTNNuXl1JQfHhGKDdflVAAQQ8%3D){height="" width="70%"} ![cloudhadoop-set-createdb2](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/cloudhadoop-set-createdb2.png?sv=2026-02-06&spr=https&st=2026-11-17T06%3A09%3A31Z&se=2026-11-17T07%3A09%3A31Z&sr=b&sp=r&sig=J%2BLh5QFNmTQSE5lDtDI%2Fet2aIHix3ogw3xAogOPgMAM%3D){height="" width="70%"} Note - The MySQL access commands are as follows: - If you get a syntax error when creating the table, check the parts with the single quotes (' '). ``` mysql -h [CDB MySQL domain] -u [Cluster admin account name] -p ``` ``` mysql> show databases; mysql> use migdb; CREATE TABLE `mig_test_tb` ( `col1` int(11) NOT NULL, `col2` char(2) NOT NULL, `col3` char(15) DEFAULT NULL, `col4` char(4) DEFAULT NULL, `col5` char(1) DEFAULT NULL, PRIMARY KEY (`col1`,`col2`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; insert into mig_test_tb values (1,'a','mig-test1','run','y'),(2,'a','mig-test1','init','n'), (3,'b','mig-test1','run','y'),(4,'b','mig-test1','run','y'), (5,'c','test-mysql','init','n'),(6,'c','test-mysql','run','n'), (7,'d','test-mysql','init','n'),(8,'d','test-mysql','run','y'), (9,'e','sqoop-test','run','n'),(10,'e','sqoop-test','run','y'), (11,'f','sqoop-test','run','n'),(12,'f','sqoop-test','init','y'), (13,'g','mysql-sqoop','run','n'),(14,'g','mysql-sqoop','init','y'), (15,'h','mysql-sqoop','run','y'),(16,'h','mysql-sqoop','init','n'), (17,'i','sqp-to-my','run','n'),(18,'i','sqp-to-my','init','n'), (19,'j','sqp-to-my','init','y'),(20,'j','sqp-to-my','init','y'), (21,'k','my-mig-sq','run','n'),(22,'k','my-mig-sq','run','y'), (23,'i','my-mig-sq','run','y'),(24,'i','my-mig-sq','run','n'); ``` ### 4. Migrate data with the Sqoop command 1. Create a database for migration in Hive. ``` CREATE DATABASE migdb; ``` - You can also create it in the Hue UI. For more information on using Hive, see [Hive user guides](/docs/en/hadoop-vpc-17). 2. Use the `import-all-tables` option in Sqoop CLI to migrate data to Hive. For the jdbc information, use the private domain and port of Cloud DB for MySQL. ``` sudo su - test sqoop import-all-tables --connect jdbc:mysql://test-db.mysql.domain.com:3306/migdb --username mig_acct -P --hive-import ``` ``` sudo su - hive kinit -kt /etc/security/keytabs/hive.service.keytab hive/@USER.GUIDE sqoop import-all-tables --connect jdbc:mysql://test-db.mysql.domain.com:3306/migdb --username mig_acct -P --hive-import ``` Note If an error occurs, check that there is a Primary Key. ``` 20/11/30 16:27:10 INFO mapreduce.Job: Job job_1606446027726_0007 completed successfully 20/11/30 16:27:10 INFO mapreduce.Job: Counters: 30 File System Counters FILE: Number of bytes read=0 FILE: Number of bytes written=685116 FILE: Number of read operations=0 FILE: Number of large read operations=0 FILE: Number of write operations=0 HDFS: Number of bytes read=414 HDFS: Number of bytes written=520 HDFS: Number of read operations=16 HDFS: Number of large read operations=0 HDFS: Number of write operations=8 Job Counters Launched map tasks=4 Other local map tasks=4 Total time spent by all maps in occupied slots (ms)=13269 Total time spent by all reduces in occupied slots (ms)=0 Total time spent by all map tasks (ms)=13269 Total vcore-milliseconds taken by all map tasks=13269 Total megabyte-milliseconds taken by all map tasks=9049458 Map-Reduce Framework Map input records=24 Map output records=24 Input split bytes=414 Spilled Records=0 Failed Shuffles=0 Merged Map outputs=0 GC time elapsed (ms)=393 CPU time spent (ms)=4780 Physical memory (bytes) snapshot=813985792 Virtual memory (bytes) snapshot=10053660672 Total committed heap usage (bytes)=341311488 File Input Format Counters Bytes Read=0 File Output Format Counters Bytes Written=520 20/11/30 16:27:10 INFO mapreduce.ImportJobBase: Transferred 520 bytes in 15.7176 seconds (33.084 bytes/sec) 20/11/30 16:27:10 INFO mapreduce.ImportJobBase: Retrieved 24 records. 20/11/30 16:27:10 INFO mapreduce.ImportJobBase: Publishing Hive/Hcat import job data to Listeners 20/11/30 16:27:10 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `mig_test_tb` AS t LIMIT 1 20/11/30 16:27:10 INFO hive.HiveImport: Loading uploaded data into Hive 20/11/30 16:27:10 WARN conf.HiveConf: HiveConf of name hive.server2.enable.doAs.property does not exist 20/11/30 16:27:10 WARN conf.HiveConf: HiveConf of name hive.server2.enable.doAs.property does not exist Logging initialized using configuration in jar:file:/home1/cdp/usr/hdp/2.6.5.0–292/hive/lib/hive-common-1.2.1000.2.6.5.0–292.jar!/hive-log4j.properties OK Time taken: 1.796 seconds Loading data to table default.mig_test_tb Table default.mig_test_tb stats: [numFiles=4, numRows=0, totalSize=520, rawDataSize=0] OK Time taken: 0.418 seconds ``` - Insecure Hadoop - sudo su - run the [user account] commands to switch to the user account. - Secure Hadoop - Run the sudo su - hive command to switch to a user account and perform Kerberos authentication. - The migration task is performed when registered as a Resource Manager Job. 3. Check if the migration task completes normally with the `OK` message. ``` SELECT * FROM mig_test_tb; ``` ![cloudhadoop-mysql-hive_ko](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/cloudhadoop-mysql-hive_en.png?sv=2026-02-06&spr=https&st=2026-11-17T06%3A09%3A31Z&se=2026-11-17T07%3A09%3A31Z&sr=b&sp=r&sig=HJI856iy2OnyT0HPkgqYWjITCtSDzLEfffI8W80fRAI%3D) - You can view the tables and data migrated to Hive in Hive Viewer 2.0 or Hue UI. - For more information on using Hive, see [Hive user guides](/docs/en/hadoop-vpc-17).