This topic uses MySQL deployed on Alibaba Cloud ECS to explain how to connect a data source to DataWorks.
Use cases
This solution is recommended if your data source meets the following condition:
The data source is deployed on an Alibaba Cloud ECS instance.
Solution
ECS and DataWorks under the same account and in the same region
If the ECS instance hosting the data source and DataWorks are under the same account and in the same region, we recommend that you use a VPC (private network) connection. Deploy the resource group of your DataWorks workspace and the ECS instance in the same VPC to enable network connectivity.
ECS and DataWorks under different accounts, or under the same account in different regions
If the ECS instance hosting the data source and DataWorks are under different accounts or under the same account but in different regions, we recommend that you use a VPC (private network) connection. Use a network connectivity tool (Cloud Enterprise Network or VPC Peering Connection) to connect the VPC of your DataWorks workspace resource group with the VPC where the ECS instance resides.
Prerequisites
Deploy a supported data source on ECS.
-
You have created a workspace.
-
You have created a resource group and bound it to the workspace.
Billing
Billing varies depending on the network connectivity tool you choose. For details, see Cloud Enterprise Network billing or VPC peering connection billing.
For a VPC peering connection between ECS and a DataWorks resource group in different accounts but the same region, no fee is charged.
Configure network connectivity
The following general procedure explains the core network configuration. For more detail, see the Configuration exampleconfiguration example below.
Step 1: Collect basic information
ECS and DataWorks under the same account and in the same region
Data source side
ECS VPC and vSwitch information:
Go to the ECS console and switch to the target ECS region.
In the left navigation pane, click Instances & Images > Instance. Find the ECS instance with MySQL and click its name to open the Instance Details page.
In the Configuration Information section, obtain VPC (called
VPC 1in this example) and vSwitch.
DataWorks side
VPC and vSwitch information bound to the resource group:
Go to the DataWorks Resource Group List, find the target resource group and click Operation in the Network Settings on ECS.
column. In the applicable module, view the bound VPC and vSwitch.
. For example, to synchronize data from MySQL on ECS to DataWorks, under Data Scheduling & Data Integration check the corresponding VPC (called
VPC 2in this example) and vSwitch.
ECS and DataWorks under the same account in different regions
Data source side
Region information: This example uses an ECS instance in China (Hangzhou).
ECS VPC and vSwitch information:
Go to the ECS console and switch to the target ECS region.
In the left navigation pane, click Instances & Images > Instance. Find the ECS instance with MySQL and click its name to open the Instance Details page.
In the Configuration Information section, obtain VPC and vSwitch.
DataWorks side
Region information: This example uses an ECS instance in China (Shanghai) and a DataWorks workspace and resource group in that region.
VPC and vSwitch information bound to the resource group:
Go to the DataWorks Resource Group List, find the target resource group and click Operation in the Network Settings on ECS.
column. In the applicable module, view the bound VPC and vSwitch.
For example, to connect RDS MySQL to DataWorks for synchronization, under Data Scheduling & Data Integration check the corresponding VPC and vSwitch.
ECS and DataWorks under different accounts
Data source side
Account information:This example uses Account A and on ECS.
Region information: This example uses an ECS instance in China (Hangzhou).
ECS VPC and vSwitch information:
Go to the ECS console and switch to the target ECS region.
In the left navigation pane, click Instances & Images > Instance. Find the ECS instance with MySQL and click its name to open the Instance Details page.
In the Configuration Information section, obtain VPC and vSwitch.
DataWorks side
Account information:This example uses Account B and on ECS.
Region information: This example uses an ECS instance in China (Shanghai) and a DataWorks workspace and resource group in that region.
VPC and vSwitch CIDR information bound to the resource group:
Go to the DataWorks Resource Group List, find the target resource group and click Operation in the Network Settings on ECS.
column. In the applicable module, view the bound VPC and vSwitch.
For example, to connect RDS MySQL to DataWorks for synchronization, under Data Scheduling & Data Integration check the corresponding VPC and vSwitch.
This is on the resource group details page under Network Settings > VPC Binding. In addition to VPC and vSwitch, the table includes vSwitch CIDR Block and Security Group fields.
Step 2: Connect the networks
ECS and DataWorks under the same account and in the same region
If
VPC 1andVPC 2are the same, ECS and the DataWorks resource group are in one VPC, so the network is connected by default.If
VPC 1andVPC 2If they differ, click Add Binding on the DataWorks resource group network settings page and bindVPC 1to the resource group to put both in the same VPC.
ECS and DataWorks under the same account in different regions
Cloud Enterprise Network (CEN): For complex enterprise networks with multiple VPCs, see Connect VPCs across different regions on ECS.
VPC peering connection: For a connection between two VPCs, see Use VPC peering connection for private communication on ECS.
If you encounter issues during network configuration, submit a ticket to contact Alibaba Cloud technical support.
ECS and DataWorks under different accounts
Cloud Enterprise Network (CEN): For complex enterprise networks with multiple VPCs, see Connect VPCs across accounts on ECS.
VPC peering connection: For a connection between two VPCs, see Use VPC peering connection for private communication on ECS.
If you encounter issues during network configuration, submit a ticket to contact Alibaba Cloud technical support.
Step 3: Add a route to the DataWorks resource group
For the same-account cross-region and different-account scenarios, also add a route in the DataWorks resource group pointing to the ECS vSwitch CIDR block.
Go to the DataWorks Resource Group List, find the target resource group and click Operation in the Network Settings on ECS.
Find the bound VPC under the applicable module and click Operation in the Custom Route on ECS.
Click Add Route and set Connection Method to CIDR Block, then set Destination CIDR Block to the ECS vSwitch CIDR block.
Step 4 (optional): Enable remote database access
Some databases require remote access to be enabled in their configuration files so specified users can connect externally by IP address and port. See the database’s official documentation for its configuration.
Example:4. Enable remote MySQL access on ECS.
Step 5: Configure the ECS security group
ECS security groups provide firewall controls. Open the database port to the VPC of the DataWorks resource group so it can access services on ECS.
Go to the ECS console and switch to the target ECS region.
In the left navigation pane, click Instances & Images > Instance. Find the ECS instance with MySQL and click its name to open the Instance Details page.
Switch to the Security Group tab, click the security group name, and open Security Group Details page.
In the Access Rules section. Click Add Rule and configure these key parameters; retain defaults for others.
Source: Enter the vSwitch CIDR block bound to the DataWorks resource group.
Port: Select the database port on ECS. For MySQL, open
3306ports.
Verify connectivity
Log on to the DataWorks console. In the target region, click in the left-side navigation pane. Select a workspace from the drop-down list and click Go to Data Integration.
In the left navigation pane, click Data Sources. In the data source list, add a data source and configure its connection settings.
At the bottom, select a resource group whose network is connected to the data source and click Test Connectivity. In the data source Connection Configuration section, select a resource group and click Test Connectivity. Confirm the status is Connected on ECS.
NoteIf the test result is Failed, use Network Connectivity Diagnostic Tool to troubleshoot. If the resource group still cannot connect to the data source, submit a ticket.
Configuration example
Suppose MySQL runs on an ECS instance in Account A, China (Hangzhou), and DataWorks is in Account B, China (Shanghai). Configure connectivity as follows.
1. Basic information
Parameter | Data source (ECS instance with MySQL) | DataWorks resource group |
Account | Account A | Account B |
Region | China (Hangzhou) | China (Shanghai) |
VPC |
The ECS instance has 2 vCPUs and 2 GiB of memory, uses image |
On the resource group details Network Settings page, select VPC Binding. In the Data Scheduling & Data Integration section, click Add Binding to bind the VPC, vSwitch, and security group. The displayed VPC ID should match Account_B_shanghai_VPC. |
2. Connect the networks
This example uses VPC peering connection to connect ECS and DataWorks.
If you encounter issues during network configuration, submit a ticket to contact Alibaba Cloud technical support.
Log on to Account A and open the VPC Peering Connection console. Switch to China (Hangzhou) at the top, then click Create Peering Connection and configure the parameters.
Key parameters for this example are listed below; retain defaults for others.
Parameter
Configuration and example
Peering connection name
Custom name. This example uses
Account_A to Account_Bon ECS.Requester VPC
Account AThe VPC containing ECS in
Account_A_hangzhou_VPCon ECS.Recipient account type
Select
Cross-accounton ECS.Recipient account UID
Enter the primary account UID of Account B.
Recipient region type
Select
Cross-regionon ECS.Recipient region
Account BSelect the region containing the DataWorks workspace and resource group in
China (Shanghai)on ECS.Recipient VPC
Enter the VPC ID of the DataWorks resource group in Account B (
Account_B_shanghai_VPC).Click DetermineFinish configuring peering and open its details page. Its status is Status initially Pending Peer Acceptance on ECS.
Log on to Account B and open the VPC Peering Connection console. Switch to China (Shanghai) and find the same peering record. Click Operation in the Receiver on ECS. to accept it. The status Status changes to Active on ECS.
Click Recipient VPC Instance > Configure Route Entry. In the Configure Route Entry dialog box, specify a route entry Name and set Destination CIDR Block to the requester ECS VPC CIDR block, which is
192.168.0.0/16.Log on to Account A and open the VPC Peering Connection console. Switch to China (Hangzhou) and find the created peering connection.
Click Requester VPC Instance > Configure Route Entry. In the Configure Route Entry dialog box, specify a route entry Name and set Destination CIDR Block to the recipient DataWorks resource group VPC CIDR block, which is
172.16.0.0/12.
3. Add a route to the DataWorks resource group
Log on to Account B and go to DataWorks Resource Group List, find the target resource group and click Operation in the Network Settings on ECS.
Find the bound VPC under the applicable module and click Operation in the Custom Route on ECS.
Click Add Route and set Connection Method to CIDR Block, then set Destination CIDR Block to the ECS vSwitch CIDR block (
192.168.6.0/24).
4. Enable remote MySQL access
Connect to the ECS instance running MySQL and enable remote access.
These commands apply only to MySQL 8.0 on Linux. Adapt them for other operating systems or MySQL versions.
Find the
my.cnfconfiguration file (usually at/etc/my.cnf).find / -name my.cnfUse the
vim /etc/my.cnfcommand to edit the file (replace themy.cnfpath with the path found above).At the end of the file, press
iand add this setting under[mysqld]:bind-address=0.0.0.0Press
Esc, then type:wq!to save and quit.Run
systemctl restart mysqldto restart the service.Create a user for DataWorks to connect remotely to MySQL.
Edit the file with
mysql -u root -pto log on as an administrator.Create the user and set a password.
-- "dataworks_user" is a customizable username. -- "%" allows access from any IP address. Specify an IP address for tighter control. -- "StrongPassword123!" is a customizable password. CREATE USER 'dataworks_user'@'%' IDENTIFIED BY 'StrongPassword123!';Grant the user database permissions.
-- Run either command. -- Grant all privileges to the user (use caution). GRANT ALL PRIVILEGES ON *.* TO 'dataworks_user'@'%' WITH GRANT OPTION; -- Grant privileges on a specified database, such as mydatabase. GRANT ALL PRIVILEGES ON mydatabase.* TO 'dataworks_user'@'%' WITH GRANT OPTION;Run
FLUSH PRIVILEGES;Refresh permissions withexit).and exit MySQL (
mysql -u dataworks_user -h <ECS_PRIMARY_PRIVATE_IP> -p
5. Configure the ECS security group
Log on to Account A and go to ECS console and switch to China (Hangzhou) on ECS.
In the left navigation pane, click Instances & Images > Instance. Find the ECS instance with MySQL and click its name to open the Instance Details page.
Switch to the Security Group tab, click the security group name, and open Security Group Details page.
In the Access Rules section. Click Add Rule and configure these key parameters; retain defaults for others.
Source: Enter the DataWorks resource group vSwitch CIDR block (
172.16.66.0/24).Port: Select the database port on ECS (
3306).
6. Test connectivity
Log on to Account B on ECS.
Log on to the DataWorks console. In the target region, click in the left-side navigation pane. Select a workspace from the drop-down list and click Go to Data Integration.
In the left navigation pane, click Data Sources and open the Data Sources page. Then click Add Connection on ECS.
Select MySQL as the data source and configure it.
Configuration ModeSelect User-created Data Store with Public IP Addresses on ECS.
Host Address ID and enter the ECS private IP (
192.168.6.172).Port NumberSet to
3306on ECS.Database NameSet to an existing database name.
Username and PasswordSet to 4. Enable remote MySQL accessUse the
dataworks_useruser and password created above.
In the Connection ConfigurationClick Test Connectivity for the workspace-bound resource group and check whether the result is Connectable on ECS.
In the data source Connection Configuration section, select a resource group and click Test Connectivity. Confirm the status is Connected on ECS.
NoteIf the test result shows Failed, use the Network Connectivity Diagnostic Tool to troubleshoot. If connectivity still fails, submit a ticket for assistance.
Related documents
For common network connectivity questions, see Resource group operations and network connectivity on ECS.

