All Products
Search
Document Center

Database Autonomy Service:Connect ECS-hosted self-managed databases to DAS

Last Updated:Nov 03, 2023

This topic describes how to connect self-managed databases hosted on Elastic Compute Service (ECS) instances to Database Autonomy Service (DAS).

Prerequisites

  • The ECS-hosted self-managed database that you want to connect to DAS is of one of the following types:

    • MySQL

    • PostgreSQL

    • MongoDB

    • Redis

      Note

      Only self-managed Redis databases that run Redis 6.0 or earlier versions can be connected to DAS.

  • The ECS instance on which the self-managed database is deployed belongs to the Alibaba Cloud account that you use to activate DAS.

Connection modes

You can connect ECS-hosted self-managed databases to DAS in one of the following modes:

  • Direct mode: No DAS gateways (DBGateways) are deployed. You need to only enter your database account and password. This method is suitable for scenarios in which a small number of ECS instances are used. You need to configure security groups for the ECS instances.

  • Centralized mode: A DAS gateway is deployed on at least one ECS instance to automatically discover databases by means of CIDR blocks. We recommend that you deploy DAS gateways on two or more ECS instances for disaster recovery. This method is suitable for scenarios in which the ECS instances are deployed in a virtual private cloud (VPC). If the ECS instances are deployed in the classic network, we recommend that you do not use this method.

  • Host mode: A DAS gateway is deployed on every ECS instance to automatically discover databases. All DAS features are supported in this mode, such as full request analysis, SQL response time analysis, and security audit. For more information, see the Features for three connection modes section of this topic.

Important

DAS gateways can be deployed only on Linux servers.

Features for three connection modes

The following table describes the DAS features that are supported by databases that are connected to DAS by using the preceding access methods. In this example, the features that DAS provides for MySQL databases are listed.

Feature

Direct mode

Centralized mode

Host mode

Database metric monitoring

Supported

Supported

Supported

Real-time performance monitoring

Supported

Supported

Supported

Real-time session monitoring

Supported

Supported

Supported

Storage analysis

Supported

Supported

Supported

SQL diagnostics

Supported

Supported

Supported

Slow request analysis

Supported only when slow query logs are stored in tables

Supported only when slow query logs are stored in tables

Supported

Host metric monitoring

Not supported

Not supported

Supported

Full request analysis

Not supported

Not supported

Supported

SQL response time analysis

Not supported

Not supported

Supported

Security audit

Not supported

Not supported

Supported

Connect databases to DAS in direct mode

  1. Log on to the DAS console.

  2. In the Recommended Features section of the Overview page, click Access Instance.

  3. On the page that appears, click DB Instances on ECS.

  4. Click Method 1: Direct Access.

  5. Select the region in which the ECS instances are deployed.

  6. Find a security group and select Private Network in the Add DAS access rules column. Then, click Save.

    Note
    • DAS automatically adds the IP address of the DAS server in the specified region to the security rules of the ECS instances. For more information about the IP addresses of DAS servers in different regions, see IP addresses of DAS servers.

    • You must add the IP address of a DAS server to the private network of at least one security group.

  7. Select the ECS instances on which the database nodes are deployed and click Next.

  8. Configure the parameters that are described in the following table.

    Parameter

    Description

    Select Engine

    The type of the database. Valid values: MySQL, PostgreSQL, MongoDB, and Redis.

    Port Number

    The port that is used to access the database.

    Database Account

    The account that is used to log on to the database.

    Password

    The password that is used to log on to the database.

    Note

    The database account must be granted the required permissions. For more information, see Permissions.

    • If the database has an existing account that is granted the required permissions, you can enter the account and password and then click Authorize.

    • If the database does not have an existing account that is granted the required permissions, you can enter a new database account and password and then click Generate Authorization Command. After you copy and run the authorization command on the database, click Authorize.

  9. Click Authorize. If Accessed is displayed after you click Authorize, the connection is successful. The following common errors may also be displayed:

    • Unauthorized: No account or password is specified.

    • Connection Failed: Errors such as network failure or database downtime occur.

    • Authentication Failed: The database account or password is invalid.

    • Insufficient Permissions: The database can be connected, but the permissions are insufficient. For more information, see Permissions.

  10. Click OK.

Connect databases to DAS in centralized mode

  1. Log on to the DAS console.

  2. In the Recommended Features section of the Overview page, click Access Instance.

  3. On the page that appears, click DB Instances on ECS.

  4. Click Method 2: DBGateway in Centralized Mode.

  5. In the dialog box that appears, select an access method.

    • If you have not deployed a DAS gateway in the corresponding VPC, click Deploy a new DAS DBGateway and search for instances.

      1. Select the region in which the ECS instances are deployed. Then, select an ECS instance on which you want to deploy a DAS gateway, and click Generate Deployment Command.

      2. Copy the deployment command. Then, log on to the ECS instance on which you want to deploy a DAS gateway and run the command.

        If successfully is returned, the DAS gateway is deployed. DAS can automatically discover the gateway. If the DAS gateway failed to be deployed, see the "Deployment issue troubleshooting" section of the Common issues about DBGateway topic to troubleshoot the issue and redeploy the DAS gateway.

      3. DAS can automatically discover the deployed gateway. If the DAS gateway is in the Normal state, click Next.

    • If you have deployed a DAS gateway in the corresponding VPC, select Use existing DAS DBGateway to scan for new instances .

      1. In the Select DBGateway step, select the DAS gateway.

      2. Click Discover Instance.

  6. In the Discover Instance step, configure the DAS gateway to scan for databases.

    1. You can use one of the following methods to discover databases:

      • Select Automatic Scan

        1. Enter the CIDR block that you want to scan in the Scanned Address field.

        2. Enter the port range in the Port Range field.

        3. Click Scan.

      • Select Enter Instances

        1. Enter databases in the correct format in the Instances field.

        2. Click Scan.

    2. After the information of the database that you want to access is displayed in the Scan Results section, click Next.

  7. Configure the parameters that are described in the following table.

    Parameter

    Description

    Select Engine

    The type of the database. Valid values: MySQL, PostgreSQL, MongoDB, and Redis.

    Database Account

    The account that is used to log on to the database.

    Password

    The password that is used to log on to the database.

    IP Address

    The IP address of the database server.

    Note

    The database account must be granted the required permissions. For more information, see Permissions.

    • If the database has an existing account that is granted the required permissions, you can enter the account and password and then click Authorize.

    • If the database does not have an existing account that is granted the required permissions, you can enter a new database account and password and then click Generate Authorization Command. After you copy and run the authorization command on the database, click Authorize.

  8. Click Authorize. If Accessed is displayed after you click Authorize, the connection is successful. The following common errors may also be displayed:

    • Unauthorized: No account or password is specified.

    • Connection Failed: Errors such as network failure or database downtime occur.

    • Authentication Failed: The database account or password is invalid.

    • Insufficient Permissions: The database can be connected, but the permissions are insufficient. For more information, see Permissions.

  9. Click OK.

Connect databases to DAS in host mode

  1. Log on to the DAS console.

  2. In the Recommended Features section of the Overview page, click Access Instance.

  3. On the page that appears, click DB Instances on ECS.

  4. Click Method 3: DBGateway in Host Mode.

  5. Select the region in which the ECS instances are deployed. Then, select an ECS instance on which you want to deploy a DAS gateway, and click Generate Authorization Command.

  6. Copy the deployment command. Then, log on to the ECS instance on which you want to deploy a DAS gateway and run the command.

    If successfully is returned, the DAS gateway is deployed. DAS can automatically discover the gateway. If the DAS gateway failed to be deployed, see the "Deployment issue troubleshooting" section of the Common issues about DBGateway topic to troubleshoot the issue and redeploy the DAS gateway.

  7. DAS can automatically discover the deployed gateway. If the DAS gateway is in the Normal state, click Next.

  8. Configure the parameters that are described in the following table.

    Parameter

    Description

    Select Engine

    The type of the database. Valid values: MySQL, PostgreSQL, MongoDB, and Redis.

    Database Account

    The account that is used to log on to the database.

    Password

    The password that is used to log on to the database.

    IP Address

    The IP address of the database server.

    Note

    The database account must be granted the required permissions. For more information, see Permissions.

    • If the database has an existing account that is granted the required permissions, you can enter the account and password and then click Authorize.

    • If the database does not have an existing account that is granted the required permissions, you can enter a new database account and password and then click Generate Authorization Command. After you copy and run the authorization command on the database, click Authorize.

  9. Click Authorize. If Accessed is displayed after you click Authorize, the connection is successful. The following common errors may also be displayed:

    • Unauthorized: No account or password is specified.

    • Connection Failed: Errors such as network failure or database downtime occur.

    • Authentication Failed: The database account or password is invalid.

    • Insufficient Permissions: The database can be connected, but the permissions are insufficient. For more information, see Permissions.

  10. Click OK.

Related API operation

AddHDMInstance