All Products
Search
Document Center

DataWorks:Solution 4: Connect to a data source on an ECS instance

Last Updated:Feb 26, 2026

This topic describes how to connect DataWorks to a data source, using a MySQL database deployed on an Alibaba Cloud Elastic Compute Service (ECS) Instance as an example.

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.

Network connection diagrams

Same account and region

幻灯片5

Same account, different regions

幻灯片6

Different accounts

幻灯片7

Prerequisites

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.

Note

If you use a Peering Connection, no fees are charged when the ECS Instance and the DataWorks resource group are in different accounts but in the same region.

Network configuration

Note

The following section outlines the general configuration process to help you understand the core logic. For a detailed walkthrough, refer to the Configuration example section of this topic.

Step 1: Obtain basic information

Same account and region

Data source side
  • VPC and vSwitch information of the ECS Instance:

    1. Go to the ECS console. In the top navigation bar, select the region where your target ECS Instance is located.

    2. In the left-side navigation pane, choose Instances & Images > Instances. Find the ECS Instance where the MySQL database is deployed and click the Instance name to go to the Instance Details page.

    3. In the Configuration Information section, find the VPC (named VPC 1 in this example) and vSwitch information.

      image

DataWorks side
  • VPC and vSwitch information of the bound resource group:

    1. Go to the Resource Groups page in the DataWorks console. Find the target resource group and click Network Settings in the Actions column.

    2. In the corresponding feature module, view the bound VPC and vSwitch information.

      For example, if you need to connect a MySQL database on an ECS Instance to DataWorks for data synchronization, view the corresponding VPC (named VPC 2 in this example) and vSwitch information under Data Scheduling & Data Integration.

      image

Same account, different regions

Data source side
  • Region information: An ECS Instance in the China (Hangzhou) region is used as an example.

  • VPC and vSwitch information of the ECS Instance:

    1. Go to the ECS console. In the top navigation bar, select the region where your target ECS Instance is located.

    2. In the left-side navigation pane, choose Instances & Images > Instances. Find the ECS Instance where the MySQL database is deployed and click the Instance name to go to the Instance Details page.

    3. In the Configuration Information section, find the VPC and vSwitch information.

      image

DataWorks side
  • Region information: A DataWorks workspace and resource group in the China (Shanghai) region are used as an example.

  • VPC and vSwitch information of the bound resource group:

    1. Go to the Resource Groups page in the DataWorks console. Find the target resource group and click Network Settings in the Actions column.

    2. In the corresponding feature module, view the bound VPC and vSwitch information.

      For example, if you need to connect an ECS-based MySQL Instance to DataWorks for data synchronization, view the corresponding VPC and vSwitch information under Data Scheduling & Data Integration.

      image

Different accounts

Data source side
  • Account information: Account A is used as an example.

  • Region information: An ECS Instance in the China (Hangzhou) region is used as an example.

  • VPC and vSwitch information of the ECS Instance:

    1. Go to the ECS console. In the top navigation bar, select the region where your target ECS Instance is located.

    2. In the left-side navigation pane, choose Instances & Images > Instances. Find the ECS Instance where the MySQL database is deployed and click the Instance name to go to the Instance Details page.

    3. In the Configuration Information section, find the VPC and vSwitch information.

      image

DataWorks side
  • Account information: Account B is used as an example.

  • Region information: A DataWorks workspace and resource group in the China (Shanghai) region are used as an example.

  • VPC and vSwitch CIDR block information of the bound resource group:

    1. Go to the Resource Groups page in the DataWorks console. Find the target resource group and click Network Settings in the Actions column.

    2. In the corresponding feature module, view the bound VPC and vSwitch information.

      For example, if you need to connect an ECS-based MySQL Instance to DataWorks for data synchronization, view the corresponding VPC and vSwitch information under Data Scheduling & Data Integration.

      image

Step 2: Establish network connectivity

Same account and region

  • If VPC 1 and VPC 2 are the same, the ECS Instance and the DataWorks resource group are in the same VPC and are connected by default.

  • If VPC 1 and VPC 2 are different, go to the Network Settings page of the DataWorks resource group and click Add VPC Association to bind VPC 1 to the resource group, which places the DataWorks resource group and the ECS Instance in the same VPC.

Same account, different regions

Note

If you encounter issues while establishing the network connection, submit a ticket to contact technical support for the relevant cloud product.

Different accounts

Note

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 resource group route

For cross-account or cross-region scenarios, you must add a route in the DataWorks resource group that points to the CIDR block of the ECS Instance's vSwitch.

  1. Go to the Resource Groups page in the DataWorks console. Find the target resource group and click Network Settings in the Actions column.

  2. In the corresponding feature module, find the bound VPC and click Custom Route in the Actions column.

  3. Click Add Route. For Connection Method, select CIDR Block. For

    Destination CIDR Block
    , enter the CIDR block of the ECS Instance's vSwitch.

Step 4: Enable remote database access

To allow users to connect remotely using an IP address and port, you may need to enable remote access in your database's configuration file. Configuration methods vary by database. For specific instructions, refer to your database's official documentation.

Example:
4. Enable remote MySQL access
.

Step 5: Configure the ECS security group

    Alibaba Cloud ECS provides firewall capabilities through Security Groups. You must open the database port in the ECS Instance's Security Group and grant access to the vSwitch CIDR block of the DataWorks resource group. This allows the resource group to access services deployed on the ECS Instance.
  • Go to the

  • ECS console
  • . In the top navigation bar, select the region where your target ECS Instance is located.

    Instances & Images > Instances

  • Instance Details
  • page.

    Click the Security Groups tab. 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 bound to the DataWorks resource group.
  • Port Range: Enter the port used by the database on the ECS Instance. For example, MySQL requires port 3306 to be open.

    Verify the network connection

    1. Log on to the DataWorks console. In the top navigation bar, select the desired region. In the left-side navigation pane, choose Data Integration > Data Integration. On the page that appears, select the desired workspace from the drop-down list and click Go to Data Integration.

    2. In the left-side navigation pane, click Data source. On the Data Sources page, click Add Data Source.

    3. 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.image

      Note

      If the connectivity test shows Connection failed, you can use the Self-service Troubleshoot tool to resolve the issue. If the connection still fails, submit a ticket for assistance.

    Configuration example

    Assume a MySQL database is deployed on an ECS Instance in the China (Hangzhou) region in Account A. DataWorks is activated in the China (Shanghai) region in Account B. The following steps show how to configure the network connection.

    1. Basic information

    Parameter

    Data source

    DataWorks resource group

    Account

    Account A

    Account B

    Region

    China (Hangzhou)

    China (Shanghai)

    VPC

    • Primary private IP of the ECS Instance: 192.168.6.172

    • VPC Name: Account_A_hangzhou_VPC

    • VPC CIDR block: 192.168.0.0/16

    • vSwitch CIDR block: 192.168.6.0/24

    ECS basic information page:

    image

    • VPC Name: Account_B_shanghai_VPC

    • VPC CIDR block: 172.16.0.0/12

    • vSwitch CIDR block: 172.16.66.0/24

    Resource group Network Settings page:

    image

    2. Establish network connectivity

    This example uses a VPC Peering Connection to connect the ECS Instance and DataWorks.

    Note

    If you encounter issues while establishing the network connection, submit a ticket to contact technical support for the relevant cloud product.

    1. Log on to Account A. Go to the VPC Peering Connection page of the VPC console. In the top navigation bar, select the China (Hangzhou) region, then click Create Peering Connection and configure the parameters.

      The following table describes the key parameters for this example. Keep the default values for other parameters.

      Parameter

      Configuration

      Peering Connection Name

      Enter a custom name. In this example, it is set to Account_A to Account_B.

      Requester VPC Instance

      The VPC of the ECS Instance in Account A. In this example, Account_A_hangzhou_VPC is selected.

      Accepter Account Type

      In this example, Cross-account is selected.

      Accepter UID

      Enter the UID of Account B.

      Accepter Region Type

      In this example, Cross-region is selected.

      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 DataWorks resource group's VPC under Account B (Account_B_shanghai_VPC).

    2. Click OK. The peering connection is configured and you are automatically taken to its details page. The status of the connection is now Peering Accepting.

    3. Log on to Account B. Go to the VPC Peering Connection page of the VPC console. In the top navigation bar, select the China (Shanghai) region. You will see a peering connection record matching the one created in Account A. Click Accept in the Actions column. After you accept the request, the connection status changes to Activated.

    4. Click Configure Route under Accepter VPC. In the Configure Route dialog box, enter a custom Name for the route entry, and set the Destination CIDR Block to the VPC CIDR block of the requester (the ECS Instance). In this example, it is 192.168.0.0/16.

      image

    5. Log on to Account A. Go to the VPC Peering Connection page of the VPC console. In the top navigation bar, select the China (Hangzhou) region and find the peering connection you created.

    6. Click Configure Route under Requester VPC Instance. In the Configure Route dialog box, enter a custom Name for the route entry, and set the Destination CIDR Block to the VPC CIDR block of the accepter (the DataWorks resource group). In this example, it is 172.16.0.0/12.

      image

    3. Add a resource group route

    1. Log on to Account B. Go to the Resource Groups page in the DataWorks console. Find the target resource group and click Network Settings in the Actions column.

    2. In the corresponding feature module, find the bound VPC and click Custom Route in the Actions column.

    3. Click Add Route. For Connection Method, select CIDR Block. For Destination CIDR Block, enter the CIDR block of the ECS Instance's vSwitch (in this example, 192.168.6.0/24).

    4. Enable remote MySQL access

    Connect to the ECS Instance where the MySQL database is deployed and enable remote access for the database.

    Note

    The following commands are for MySQL 8.0 deployed in a Linux environment. Adapt them for other operating systems and MySQL versions.

    1. Find the location of the my.cnf configuration file. By default, it is usually located at /etc/my.cnf.

      find / -name my.cnf
    2. Use the vim /etc/my.cnf command to edit the configuration file. Replace the path with the actual path found in the previous step.

    3. At the end of the file, press i and add the following configuration under [mysqld]:

      bind-address=0.0.0.0
    4. Press Esc, then enter :wq! to save and exit.

    5. Run the systemctl restart mysqld command to restart the service.

    6. Create a user for the DataWorks remote connection.

      1. Use the mysql -u root -p command to log in to the database as an administrator.

      2. Create a user and set a password.

        -- "dataworks_user" is the username. You can customize it.
        -- "%" allows access from any IP address. You can specify an IP for fine-grained control.
        -- "StrongPassword123!" is the user password. You can customize it.
        CREATE USER 'dataworks_user'@'%' IDENTIFIED BY 'StrongPassword123!';
      3. Grant database privileges to the user.

        -- Run either 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 (for example, mydatabase) to the user.
        GRANT ALL PRIVILEGES ON mydatabase.* TO 'dataworks_user'@'%' WITH GRANT OPTION;
      4. Run the FLUSH PRIVILEGES; command to refresh privileges, then exit the database (exit).

      5. Verify the remote connection.

        mysql -u dataworks_user -h <Primary private IP of ECS> -p

    5. Configure the ECS security group

    1. Log on to Account A. Go to the ECS console and in the top navigation bar, select the China (Hangzhou) region.

    2. In the left-side navigation pane, choose Instances & Images > Instances. Find the ECS Instance where the MySQL database is deployed and click the Instance name to go to the Instance Details page.

    3. Click the Security Groups tab. Click the name of the Security Group to go to the Security Group Details page.

    4. 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 (in this example, 172.16.66.0/24).

      • Port Range: Enter the port used by the database on the ECS Instance (in this example, 3306).

    6. Test the connection

    1. Log on to Account B.

    2. Log on to the DataWorks console. In the top navigation bar, select the desired region. In the left-side navigation pane, choose Data Integration > Data Integration. On the page that appears, select the desired workspace from the drop-down list and click Go to Data Integration.

    3. In the left-side navigation pane, click Data source to go to the Data Sources page, then click Add Data Source.

    4. Select MySQL as the data source type and configure its connection parameters.

      • For Configuration Mode, select Connection String Mode.

      • For Host IP Address, enter the private IP address of the ECS Instance (in this example, 192.168.6.172).

      • Set Port to 3306.

      • For Database Name, enter the name of an existing database.

      • For Username and Password, use the dataworks_user credentials created in the 4. Enable remote MySQL access step.

    5. In the Connection Configuration section, click Test Network Connectivity for the resource group bound to the workspace. Verify that the result is passed.

      image

      Note

      If the connectivity test Fails, you can use the 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.