This topic uses a MySQL database deployed on an Alibaba Cloud Elastic Compute Service (ECS) instance as an example to describe how to establish network connectivity between your data source and DataWorks.
Use cases
Use this solution if your data source meets the following condition:
The data source is deployed on an Alibaba Cloud ECS instance.
How it works
Same account and region
If the ECS instance where the data source is deployed and the DataWorks workspace are in the same account and region, you can use a VPC (private network) connection. You can deploy the resource group of the DataWorks workspace and the ECS instance in the same VPC to enable network communication.
Different accounts or regions
If the ECS instance where the data source is deployed and the DataWorks workspace are in different accounts or in the same account but different regions, you can use a VPC (private network) connection. You can use a network connectivity tool, such as CEN or a VPC peering connection, to connect the VPC of the DataWorks resource group to the VPC of the ECS instance. This enables network communication.
Before you begin
You have deployed a DataWorks-supported data source on an ECS instance.
Billing
Charges vary depending on the networking product you choose. For more information, see the billing details for Cloud Enterprise Network (CEN) or Peering Connection.
If you use a VPC Peering Connection and the ECS instance and DataWorks resource group are in different accounts but the same region, no fees are charged.
Configure network connectivity
The following steps outline the general procedure for establishing network connectivity between your data source and DataWorks. For a detailed example, see the Configuration example in this topic.
Step 1: Get the required information
Same account and region
Data source details
VPC and vSwitch information for the ECS instance:
Go to the Elastic Compute Service console. In the top navigation bar, select the region where your ECS instance is located.
In the left-side navigation pane, choose > Instances. Find the ECS instance that hosts your MySQL database and click the instance name to open the Instance Details page.
In the Configuration Information section, find the VPC (named
VPC 1in this example) and vSwitch information.
DataWorks details
VPC and vSwitch information for the resource group:
Go to the DataWorks resource group list. Find the target resource group and click Network Settings in the Actions column.
Under the relevant feature module, view the associated VPC and vSwitch.
For example, if you need to perform data synchronization, check the VPC (named
VPC 2in this example) and vSwitch under Data Scheduling & Data Integration.
Same account, different regions
Data source details
Region information: This example uses an ECS instance in the China (Hangzhou) region.
VPC and vSwitch information for the ECS instance:
Go to the Elastic Compute Service console. In the top navigation bar, select the region where your ECS instance is located.
In the left-side navigation pane, choose > Instances. Find the ECS instance that hosts your MySQL database and click the instance name to go to the Instance Details page.
In the Configuration Information section, find the VPC and vSwitch information.

DataWorks details
Region information: This example uses a DataWorks workspace and resource group in the China (Shanghai) region.
VPC and vSwitch information for the resource group:
Go to the DataWorks resource group list. Find the target resource group and click Network Settings in the Actions column.
Under the relevant feature module, view the associated VPC and vSwitch.
For example, to connect your ECS instance to DataWorks for data synchronization, check the VPC and vSwitch under Data Scheduling & Data Integration.

Different accounts
Data source details
Account information: This example uses Account A.
Region information: This example uses an ECS instance in the China (Hangzhou) region.
VPC and vSwitch information for the ECS instance:
Go to the Elastic Compute Service console. In the top navigation bar, select the region where your ECS instance is located.
In the left-side navigation pane, choose > Instances. Find the ECS instance that hosts your MySQL database and click the instance name to go to the Instance Details page.
In the Configuration Information section, find the VPC and vSwitch information.

DataWorks details
Account information: This example uses Account B.
Region information: This example uses a DataWorks workspace and resource group in the China (Shanghai) region.
VPC and vSwitch information for the resource group:
Go to the DataWorks resource group list. Find the target resource group and click Network Settings in the Actions column.
Under the relevant feature module, view the associated VPC and vSwitch.
For example, to connect your ECS instance to DataWorks for data synchronization, check the VPC and vSwitch under Data Scheduling & Data Integration.

Step 2: Establish network connection
Same account and region
If
VPC 1andVPC 2are the same, the ECS instance and the DataWorks resource group are in the same VPC. Network connectivity is established by default.If
VPC 1andVPC 2are different, go to the network settings page of the DataWorks resource group and click Add VPC Association to associateVPC 1with the resource group. This places the DataWorks resource group and the ECS instance in the same VPC.
Same account, different regions
Cloud Enterprise Network (CEN): Suitable for complex enterprise networks that require multi-VPC connectivity. For configuration details, see Connect VPCs across regions.
VPC Peering Connection: Suitable for connecting two VPCs. For configuration details, see Use a VPC Peering Connection to connect VPCs.
If you encounter issues while establishing the network connection, submit a ticket to contact technical support for the relevant cloud product.
Different accounts
Cloud Enterprise Network (CEN): Suitable for complex enterprise networks that require multi-VPC connectivity. For configuration details, see Connect VPCs across accounts.
VPC Peering Connection: Suitable for connecting two VPCs. For configuration details, see Use a VPC Peering Connection to connect VPCs.
If you encounter issues while establishing the network connection, submit a ticket to contact technical support for the relevant cloud product.
Step 3: Add a route to the resource group
For scenarios involving different accounts or different regions, you must also add a route in the DataWorks resource group that points to the CIDR block of the ECS instance's vSwitch.
Go to the DataWorks resource group list. Find the target resource group and click Network Settings in the Actions column.
Under the relevant feature module, find the associated VPC and click Custom Route in the Actions column.
Click Add Route, set the connection method to Specify CIDR Block, and set Destination CIDR Block to the CIDR block of the vSwitch for the ECS instance.
Step 4: (Optional) Enable remote database access
Some databases require you to enable remote access in a configuration file to allow specified users to connect from external IP addresses and ports. The configuration method varies by database. See the official documentation for your database.
Step 5: Configure the security group
Alibaba Cloud ECS uses security groups to provide firewall capabilities. You must add a rule to the security group of the ECS instance to open the database port to the CIDR block of the DataWorks resource group's vSwitch. This allows the resource group to access the service running on the ECS instance.
Go to the Elastic Compute Service console. In the top navigation bar, select the region where your ECS instance is located.
In the left-side navigation pane, choose > Instances. Find the ECS instance that hosts your MySQL database and click the instance name to go to the Instance Details page.
Click the Security Groups tab and click the name of the security group to go to the Security Group Details page.
In the Access Rule section, click Quick Add and configure the following key parameters. Keep the default values for other parameters.
Authorization Object: Enter the CIDR block of the vSwitch associated with the DataWorks resource group.
Port Range: Select the port used by the database on your ECS instance. For example, MySQL requires port
3306.
Verify network connectivity
Log on to the DataWorks console. In the top navigation bar, select the desired region. In the left-side navigation pane, choose . On the page that appears, select the desired workspace from the drop-down list and click Go to Data Integration.
In the left-side navigation pane, click Data source. On the Data Sources page, click Add Data Source. Select the appropriate data source type and configure the connection parameters.
In the resource group list at the bottom of the page, select the resource group that is connected to the data source and click Test Network Connectivity.
NoteIf the test result is Connection failed, you can use the Self-service Troubleshoot tool to resolve the issue. If you still cannot connect the resource group to the data source, submit a ticket.
Configuration example
This example describes how to configure network connectivity in a cross-account, cross-region scenario. Assume that a MySQL database is deployed on an ECS instance in the China (Hangzhou) region under Account A, and your DataWorks workspace is in the China (Shanghai) region under Account B.
1. Basic information
Parameter | Data source | DataWorks resource group |
Account | Account A | Account B |
Region | China (Hangzhou) | China (Shanghai) |
VPC |
ECS basic information page:
|
Resource group network settings page:
|
2. Establish network connection
This example uses a VPC Peering Connection to establish network connectivity between the ECS instance and DataWorks.
If you encounter issues while establishing the network connection, submit a ticket to contact technical support for the relevant cloud product.
Log on to Account A. Go to the VPC Peering Connection console. In the top navigation bar, select the China (Hangzhou) region, and then click Create Peering Connection. Configure the parameters.
The following table describes the key parameters for this example. Keep the default values for other parameters.
Parameter
Configuration and example
Peering connection name
Enter a custom name. This example uses
Account_A to Account_B.Requester VPC instance
The VPC in Account A that contains the ECS instance. This example uses
Account_A_hangzhou_VPC.Accepter account type
This example uses
Cross-account.UID of the receiver
Enter the UID of the Alibaba Cloud account for Account B.
Accepter region type
This example uses
Cross-region.Accepter region
The region where the DataWorks workspace and resource group for Account B are located. Select
China (Shanghai).Accepter VPC
Manually enter the ID of the VPC associated with the DataWorks resource group in Account B (
Account_B_shanghai_VPC).Click OK. You are redirected to the basic information page for the peering connection. The Status of the connection is Peering Accepting.
Log on to Account B. Go to the VPC Peering Connection console. In the top navigation bar, select the China (Shanghai) region. You will find the matching peering connection request. In the Actions column, click Accept. After you accept the request, the Status of the peering connection changes to Activated.
Click Configure Route under the Accepter VPC Instance. In the Configure Route dialog box, enter a custom Name for the route entry. Set the Destination CIDR Block to the VPC CIDR block of the Requester (the ECS instance), which is
192.168.0.0/16in this example.
Log on to Account A. Go to the VPC Peering Connection console. In the top navigation bar, select the China (Hangzhou) region and find the peering connection you created.
Click Configure Route under the Requester VPC Instance. In the Configure Route dialog box, enter a custom Name for the route entry. Set the Destination CIDR Block to the VPC CIDR block of the Accepter (the DataWorks resource group), which is
172.16.0.0/12in this example.
3. Add a route to the resource group
Log on to Account B. Go to the DataWorks resource group list. Find the target resource group and click Network Settings in the Actions column.
Under the relevant feature module, find the associated VPC and click Custom Route in the Actions column.
Click Add Route. For Connection Method, select CIDR Block. For Destination CIDR Block, enter the CIDR block of the vSwitch where the ECS instance is located (
192.168.6.0/24in this example).
4. Enable remote database access
Connect to the ECS instance that hosts the MySQL database and enable remote access for the database.
The following commands apply only to MySQL 8.0 databases deployed in a Linux environment. Adapt the commands for other operating systems and MySQL versions.
Find the location of the
my.cnfconfiguration file. If you use the default installation settings, the file is typically located in the/etc/my.cnfdirectory.find / -name my.cnfRun the
vim /etc/my.cnfcommand to edit the configuration file. Replace the path of themy.cnffile with the actual path that you found in the previous step.At the end of the configuration file, press
ito enter insert mode and add the following configuration under[mysqld]:bind-address=0.0.0.0Press
Escand enter:wq!to save the file and exit.Run the
systemctl restart mysqldcommand to restart the service.Create a user that DataWorks can use to remotely connect to the MySQL database.
Run the
mysql -u root -pcommand to log on to the database as the administrator.Create a user and set a password.
-- "dataworks_user" is the username. You can customize it. -- "%" indicates access from any IP address. You can also specify an IP address for finer-grained control. -- "StrongPassword123!" is the password. You can customize it. CREATE USER 'dataworks_user'@'%' IDENTIFIED BY 'StrongPassword123!';Grant permissions on the database to the user.
-- Run one of the following commands. -- Grants all privileges to the user. Use with caution. GRANT ALL PRIVILEGES ON *.* TO 'dataworks_user'@'%' WITH GRANT OPTION; -- Grants privileges on a specific database (for example, mydatabase) to the user. GRANT ALL PRIVILEGES ON mydatabase.* TO 'dataworks_user'@'%' WITH GRANT OPTION;Run the
FLUSH PRIVILEGES;command to flush the privileges, and then exit the database (exit).Verify the remote connection.
mysql -u dataworks_user -h <Private_IP_address_of_the_ECS_instance> -p
5. Configure the security group
Log on to Account A. Go to the Elastic Compute Service console. In the top navigation bar, select the China (Hangzhou) region.
In the left-side navigation pane, choose > Instances. Find the ECS instance that hosts your MySQL database and click the instance name to go to the Instance Details page.
Click the Security Groups tab and click the name of the security group to go to the Security Group Details page.
In the Access Rule section, click Quick Add and configure the following key parameters. Keep the default values for other parameters.
Authorization Object: Enter the CIDR block of the DataWorks resource group's vSwitch (
172.16.66.0/24in this example).Port Range: Select the port used by the database on your ECS instance (
3306in this example).
6. Test the connection
Log on to Account B.
Log on to the DataWorks console. In the top navigation bar, select the desired region. In the left-side navigation pane, choose . On the page that appears, select the desired workspace from the drop-down list and click Go to Data Integration.
In the left-side navigation pane, click Data source to open the Data Sources page, and then click Add Data Source.
Select the MySQL data source type and configure the parameters.
For Configuration Mode, select Connection String Mode.
For Host IP Address, enter the private IP address of the ECS instance (
192.168.6.172in this example).Set Port Number to
3306.For Database Name, enter the name of an existing database.
For Username and Password, enter the
dataworks_userusername and password you created in the 4. Enable remote access for the MySQL database step.
In the Connection Configuration section, click Test Network Connectivity for the associated resource group. Verify that the result is passed.
NoteIf the connectivity test Fails, you can use the Network Connectivity Diagnosis Tool to troubleshoot the issue. If you still cannot connect the Resource Group to the data source, submit a ticket for assistance.
Related documents
For frequently asked questions about network connectivity, see Resource group operations and network connectivity.




