Solution 4: Network connectivity for data sources deployed on ECS
This topic uses a MySQL database on an Alibaba Cloud ECS instance as an example to describe how to connect your data source to DataWorks.
Use case
This solution is recommended if your data source meets the following condition:
The data source is deployed on an Alibaba Cloud ECS instance.
Solution
Same account and 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.
Different accounts or 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
A DataWorks-supported data source is deployed on an ECS instance.
-
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.
A VPC peering connection between different accounts in the same region is free of charge.
Configure network connectivity
The following describes the general procedure for configuring network connectivity between a data source and DataWorks, which helps you quickly understand the core logic. For more configuration details, this topic also provides a specific configuration example for your reference.
Step 1: Obtain basic information
Same account and region
Data source side
VPC and vSwitch information of the ECS instance:
Go to the ECS console and switch to the region of your ECS instance at the top of the page.
In the left-side navigation pane, click Instances & Images > Instance. Find the ECS instance on which the MySQL database is deployed, and click the instance name to go to the Instance Details page.
In the Configuration Information section, obtain the VPC (referred to as
VPC 1in this example) and vSwitch information.
DataWorks side
VPC and vSwitch information bound to the resource group:
Go to the DataWorks Resource Group List page. Find the target resource group and click Network Settings in the Operation column.
Under the corresponding module, view the bound VPC and vSwitch information.
For example, if you want to connect the MySQL database deployed on ECS to DataWorks for data synchronization, view the VPC (referred to as
VPC 2in this example) and vSwitch information under Data Scheduling & Data Integration.
Same account, different regions
Data source side
Region: This example uses an ECS instance in the China (Hangzhou) region.
VPC information of the ECS instance:
Go to the ECS console and switch to the region of your ECS instance at the top of the page.
In the left-side navigation pane, click Instances & Images > Instance. Find the ECS instance on which the MySQL database is deployed, and click the instance name to go to the Instance Details page.
In the Configuration Information section, obtain the VPC and vSwitch information.
DataWorks side
Region: This example uses a DataWorks workspace and resource group in the China (Shanghai) region.
VPC and vSwitch information bound to the resource group:
Go to the DataWorks Resource Group List page. Find the target resource group and click Network Settings in the Operation column.
Under the corresponding module, view the bound VPC and vSwitch information.
For example, if you want to connect an ApsaraDB RDS for MySQL instance to DataWorks for data synchronization, view the VPC and vSwitch information under Data Scheduling & Data Integration.
Different accounts
Data source side
Account: This example uses Account A.
Region: This example uses an ECS instance in the China (Hangzhou) region.
VPC and vSwitch information of the ECS instance:
Go to the ECS console and switch to the region of your ECS instance at the top of the page.
In the left-side navigation pane, click Instances & Images > Instance. Find the ECS instance on which the MySQL database is deployed, and click the instance name to go to the Instance Details page.
In the Configuration Information section, obtain the VPC and vSwitch information.
DataWorks side
Account: This example uses Account B.
Region: This example uses a DataWorks workspace and resource group in the China (Shanghai) region.
VPC and vSwitch CIDR block information bound to the resource group:
Go to the DataWorks Resource Group List page. Find the target resource group and click Network Settings in the Operation column.
Under the corresponding module, view the bound VPC and vSwitch information.
For example, if you want to connect an ApsaraDB RDS for MySQL instance to DataWorks for data synchronization, view the VPC and vSwitch information under Data Scheduling & Data Integration.
This information is located on the Network Settings > VPC Bindingss tab of the resource group details page. In addition to the VPC and vSwitch, the table also includes the vSwitch CIDR Block and Security Group columns.
Step 2: Establish network connectivity
Same account and region
If
VPC 1andVPC 2are the same, the ECS instance and the DataWorks resource group are deployed in the same VPC, and they can communicate with each other by default.If
VPC 1andVPC 2are different, go to the network settings page of the DataWorks resource group and click Add Binding to bindVPC 1to the resource group so that the DataWorks resource group and the ECS instance are in the same VPC.
Same account, different regions
Cloud Enterprise Network (CEN): Suitable for complex enterprise network environments that require connectivity among multiple VPCs. For more information, see Connect to a data source by using CEN.
VPC peering connection: Suitable for peer-to-peer connectivity between two VPCs. For more information, see Connect to a data source by using VPC peering.
If you encounter issues during network configuration, submit a ticket to contact Alibaba Cloud technical support.
Different accounts
Cloud Enterprise Network (CEN): Suitable for complex enterprise network environments that require connectivity among multiple VPCs. For more information, see Connect to a data source by using CEN.
VPC peering connection: Suitable for peer-to-peer connectivity between two VPCs. For more information, see Connect to a data source by using VPC peering.
If you encounter issues during network configuration, submit a ticket to contact Alibaba Cloud technical support.
Step 3: Add a route in the DataWorks resource group
For cross-region scenarios under the same account or cross-account scenarios, you also need to add a route in the DataWorks resource group that points to the vSwitch CIDR block of the ECS instance.
Go to the DataWorks Resource Group List page. Find the target resource group and click Network Settings in the Operation column.
Under the corresponding module, find the bound VPC and click Custom Route in the Operation column.
Click Add Route. Set the connection method to CIDR Block, and set Destination CIDR Block to the vSwitch CIDR block of the ECS instance.
Step 4: (Optional) Enable remote access for the database
Some databases require remote access to be enabled in their configuration files to allow specified users to access the database from external networks by using an IP address and port. The configuration method varies by database. Refer to the official documentation for your database.
For example: Enable remote access for MySQL.
Step 5: Configure ECS security group rules
Alibaba Cloud ECS uses security groups to implement firewall capabilities. You need to open the database port in the ECS security group for the VPC of the DataWorks resource group, so that the DataWorks resource group can access the service deployed on the ECS instance.
Go to the ECS console and switch to the region of your ECS instance at the top of the page.
In the left-side navigation pane, click Instances & Images > Instance. Find the ECS instance on which the MySQL database is deployed, and click the instance name to go to the Instance Details page.
At the top of the page, switch to the Security Group tab. Click the security group name to go to the Security Group Details page.
In the Access Rules section, click Add Rule and configure the following key parameters. You can use the default values for other parameters.
Source: Enter the vSwitch CIDR block bound to the DataWorks resource group.
Port: Select the port of the database deployed on the ECS instance. For example, open port
3306for MySQL.
Verify network 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-side navigation pane, click Data Sources. In the data source list, click to add a data source, select the data source type, and configure the connection parameters based on your requirements.
In the resource group list at the bottom, select the resource group that has network connectivity with the data source and click Test Connectivity. In the Connection Configuration section of the data source, select a resource group and click Test Connectivity. Verify that the connectivity status is Connectable.
NoteIf the connectivity test result is Not Connectable, use the Network Connectivity Diagnostic Tool to troubleshoot the issue. If the resource group and data source still cannot connect, submit a ticket.
Configuration example
Assume that a MySQL database is deployed on an ECS instance under Account A in the China (Hangzhou) region, and DataWorks is activated under Account B in the China (Shanghai) region. The procedure for configuring network connectivity is 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 is configured with 2 vCPUs and 2 GiB of memory, uses the image |
On the Network Settings page of the resource group details, select the VPC Bindings tab. In the Data Scheduling & Data Integration section, click Add Binding to bind the VPC, vSwitch, and security group. After binding, the VPC ID displayed in the list should match the VPC ID of Account_B_shanghai_VPC. |
2. Establish network connectivity
This example uses a VPC peering connection to configure network connectivity between the ECS instance and DataWorks.
If you encounter issues during network configuration, submit a ticket to contact Alibaba Cloud technical support.
Log on with Account A. Go to the VPC Peering Connection console. Switch the region to China (Hangzhou) at the top of the page, and then click Create Peering Connection to configure the parameters.
The following table describes the key parameters for this example. You can use the default values for other parameters.
Parameter
Description and example
Peering Connection Name
Specify a custom name. In this example, enter
Account_A to Account_B.Requester VPC
The VPC of the ECS instance under Account A. In this example, select
Account_A_hangzhou_VPC.Accepter Account Type
In this example, select
Cross-account.Accepter Account UID
Enter the UID of the Alibaba Cloud account for Account B.
Accepter Region Type
In this example, select
Cross-region.Accepter Region
The region of the DataWorks workspace and resource group under Account B. Select
China (Shanghai).Accepter VPC
Manually enter the VPC ID of the VPC (
Account_B_shanghai_VPC) that contains the DataWorks resource group under Account B.Click Determine to complete the peering connection configuration. The system automatically redirects to the peering connection details page, where the Status is Accepting.
Log on with Account B. Go to the VPC Peering Connection console. Switch the region to China (Shanghai) at the top of the page. You can see a peering connection record that matches the one created under Account A. Click Receiver in the Operation column. After acceptance, the Status changes to Activated.
Click Configure Route Entry under Accepter VPC. In the Configure Route Entry dialog, specify a custom Name for the route entry and set Destination CIDR Block to the VPC CIDR block of the requester (ECS). In this example, enter
192.168.0.0/16.Log on with Account A. Go to the VPC Peering Connection console. Switch the region to China (Hangzhou) at the top of the page and find the peering connection that you created.
Click Configure Route Entry under Requester VPC. In the Configure Route Entry dialog, specify a custom Name for the route entry and set Destination CIDR Block to the VPC CIDR block of the accepter (DataWorks resource group). In this example, enter
172.16.0.0/12.
3. Add a route in the DataWorks resource group
Log on with Account B. Go to the DataWorks Resource Group List page. Find the target resource group and click Network Settings in the Operation column.
Under the corresponding module, find the bound VPC and click Custom Route in the Operation column.
Click Add Route. Set the connection method to CIDR Block, and set Destination CIDR Block to the vSwitch CIDR block of the ECS instance (in this example,
192.168.6.0/24).
4. Enable remote access for the MySQL database
Connect to the ECS instance on which the MySQL database is deployed and enable remote access for the database.
The following commands apply only to MySQL 8.0 databases deployed on Linux. Adapt the commands as needed for other operating systems and MySQL versions.
Locate the
my.cnfconfiguration file. By default, the file is located at/etc/my.cnf.find / -name my.cnfRun the
vim /etc/my.cnfcommand to edit the configuration file. Replace themy.cnfpath based on the actual result from the previous step.At the end of the configuration file, press
iand add the following configuration under the[mysqld]section:bind-address=0.0.0.0Press
Esc, type:wq!, and then press Enter to save and exit.Run the
systemctl restart mysqldcommand to restart the service.Create a user that will be used when configuring the data source in DataWorks 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, which you can customize. -- "%" means access is allowed from any IP. You can also specify an IP for fine-grained control. -- "StrongPassword123!" is the user password, which you can customize. CREATE USER 'dataworks_user'@'%' IDENTIFIED BY 'StrongPassword123!';Grant database permissions to the user.
-- Execute any one of the following commands. -- Grant all privileges to the user (use with caution). GRANT ALL PRIVILEGES ON *.* TO 'dataworks_user'@'%' WITH GRANT OPTION; -- Grant privileges on a specific database (e.g., 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 <Primary private IP address of the ECS instance> -p
5. Configure ECS security group rules
Log on with Account A. Go to the ECS console and switch to China (Hangzhou) at the top of the page.
In the left-side navigation pane, click Instances & Images > Instance. Find the ECS instance on which the MySQL database is deployed, and click the instance name to go to the Instance Details page.
At the top of the page, switch to the Security Group tab. Click the security group name to go to the Security Group Details page.
In the Access Rules section, click Add Rule and configure the following key parameters. You can use the default values for other parameters.
Source: Enter the vSwitch CIDR block of the DataWorks resource group (in this example,
172.16.66.0/24).Port: Select the port of the database deployed on the ECS instance (in this example,
3306).
6. Test connectivity
Log on with Account B.
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-side navigation pane, click Data Sources to go to the Data Sources page. Click Add Connection.
Select the MySQL data source type and configure the connection parameters.
Set Configuration Mode to User-created Data Store with Public IP Addresses.
Set Host Address to the private IP address of the ECS instance (in this example,
192.168.6.172).Set Port Number to
3306.Set Database Name to an existing database name.
Set Username and Password to the
dataworks_usercredentials created in the Enable remote access for MySQL step.
In the Connection Configuration section, click the test connectivity button next to the resource group bound to the workspace to check whether the result is Connectable.
In the Connection Configuration section of the data source, select a resource group and click Test Connectivity. Verify that the connectivity status is Connectable.
NoteIf the test result shows Failed, use the Network Connectivity Diagnostic Tool to troubleshoot. If connectivity still fails, submit a ticket for assistance.
Reference
For frequently asked questions about network connectivity, see Network connectivity FAQ.

