This topic describes how to use an exclusive resource group for Data Integration to migrate data from a user-created MySQL database on an Elastic Compute Service (ECS) instance to MaxCompute.
Prerequisites
- An ECS instance is purchased and bound to a virtual private cloud (VPC) but not the classic network. A MySQL database that stores test data is deployed on the ECS instance. An account used to connect to the database is created. In this example, use the following statements to create a table in the MySQL database and insert test data to the table:
CREATE TABLE IF NOT EXISTS good_sale( create_time timestamp, category varchar(20), brand varchar(20), buyer_id varchar(20), trans_num varchar(20), trans_amount DOUBLE, click_cnt varchar(20) ); insert into good_sale values('2018-08-21','coat','brandA','lilei',3,500.6,7), ('2018-08-22','food','brandB','lilei',1,303,8), ('2018-08-22','coat','brandC','hanmeimei',2,510,2), ('2018-08-22','bath','brandA','hanmeimei',1,442.5,1), ('2018-08-22','food','brandD','hanmeimei',2,234,3), ('2018-08-23','coat','brandB','jimmy',9,2000,7), ('2018-08-23','food','brandA','jimmy',5,45.1,5), ('2018-08-23','coat','brandE','jimmy',5,100.2,4), ('2018-08-24','food','brandG','peiqi',10,5560,7), ('2018-08-24','bath','brandF','peiqi',1,445.6,2), ('2018-08-24','coat','brandA','ray',3,777,3), ('2018-08-24','bath','brandG','ray',3,122,3), ('2018-08-24','coat','brandC','ray',1,62,7) ;
- The private IP address, VPC, and vSwitch of your ECS instance are noted.
- A security group rule is added for the ECS instance to allow access requests on the port used by the MySQL database. By default, the MySQL database uses port 3306. For more information, see Add a security group rule. The name of the security group is noted.
- A DataWorks workspace is created. In this example, create a DataWorks workspace that is in basic mode and uses a MaxCompute compute engine. Make sure that the created DataWorks workspace belongs to the same region as the ECS instance. For more information about how to create a workspace, see Create a workspace.
- An exclusive resource group for Data Integration is purchased and bound to the VPC where the ECS instance resides. The exclusive resource group and the ECS instance are in the same zone. For more information, see Create and use an exclusive resource group for Data Integration. After the exclusive resource group is bound to the VPC, you can view information about the exclusive resource group on the Resource Groups page.
- Check Network Settings, vSwitch, and security group of the exclusive resource group are the same as those of the ECS instance.
Background information
An exclusive resource group can transmit your data in a fast and stable manner. Make sure that the exclusive resource group for Data Integration belongs to the same zone in the same region as the data store that needs to be accessed. Make sure that the exclusive resource group for Data Integration belongs to the same region as the DataWorks workspace. In this example, the data store that needs to be accessed is a user-created MySQL database on an ECS instance.Procedure
- Create a connection to the MySQL database in the DataWorks console.
- Create a MaxCompute table.You must create a table in DataWorks to receive test data from the MySQL database.
- Configure a data integration node.
Result
To query data in the MaxCompute table, create an ODPS SQL node.Enter the statementselect * from good_sale ;
, and click the Run icon. If the test data appears, it is synchronized to the MaxCompute table.