Connect self-managed ECS databases to DAS

更新时间:
复制 MD 格式

Connect a self-managed database on an ECS instance to DAS using direct, centralized, or host connection mode.

Prerequisites

  • DAS supports the following self-managed database engines on ECS:

    • MySQL: 5.6 or later

    • PostgreSQL: 9.0 or later

    • MongoDB: 3.2 or later

    • Redis: 2.8 or later

  • The ECS instance that hosts your database instance and DAS must belong to the same Alibaba Cloud account.

Connection modes

DAS supports three connection modes for self-managed ECS databases:

  • Direct mode: Connects without DBGateway. Suitable for a small number of ECS instances. Requires security group configuration.

  • Centralized mode: Deploys DBGateway on one or more ECS instances to auto-discover databases within a CIDR block. Recommended for VPC; not recommended for classic networks. Deploy on two or more instances for high availability.

  • Host mode: Deploys DBGateway on each ECS instance to auto-discover databases. Provides all DAS features, including full request analysis, SQL response time, and security audit. Feature comparison of the three connection modes.

Important

DBGateway can be deployed only on Linux.

Feature comparison of connection modes

The following table compares features by connection mode, using MySQL as an example.

Feature

Direct mode

Centralized mode

Host mode

Database metrics

Supported

Supported

Supported

Real-time performance

Supported

Supported

Supported

Real-time sessions

Supported

Supported

Supported

Space analysis

Supported

Supported

Supported

SQL diagnostics

Supported

Supported

Supported

Slow request analysis

Partial (slow query log must be in tables)

Partial (slow query log must be in tables)

Supported

Host metrics

Not supported

Not supported

Supported

Full request analysis

Not supported

Not supported

Supported

SQL response time

Not supported

Not supported

Supported

Security audit

Not supported

Not supported

Supported

Direct connection

  1. Log on to the DAS console.

  2. In the left-side navigation pane, choose Intelligent O&M Center > Instance Monitoring.

  3. In the upper-right corner of the page, click Access Instance.

  4. Click DB Instances on ECS.

  5. Click Direct Access.

  6. Select a region.

  7. Find the target security group. In the Add DAS access rules column, select the checkbox for Private Network, and then click Save.

    Note
    • DAS automatically adds its service IP address for the selected region to the ECS instance's security group rules. DAS service IP addresses.

    • Add the DAS service IP address to at least one security group (private network).

  8. Select the ECS instance and click Next.

  9. Enter the database login information.

    Parameter

    Description

    Select Engine

    Database engine: MySQL, PostgreSQL, MongoDB, and Redis.

    Port

    Port of the self-managed database.

    Database account

    Account for the self-managed database.

    Password

    Password for the database account.

    Note

    The database account must have the required permissions.

    • If an account with the required permissions already exists, enter the database account and password, and then click Authorize.

    • If an account with the required permissions does not exist, enter a database account and password, and then click Generate Authorization Command. Copy the command, run it on your database, and then click Authorize.

  10. Click Authorize. After you click Authorize, in addition to the Normal Connection status, there are four common errors:

    • Unauthorized: No database account or password provided.

    • Failed to access.: DAS could not connect. Possible causes: network issue or instance downtime.

    • Failed to verify.: The database account or password is incorrect.

    • Insufficient Permissions: Connected successfully, but the account lacks required permissions.

  11. Click Complete.

Centralized connection

  1. Log on to the DAS console.

  2. In the left-side navigation pane, choose Intelligent O&M Center > Instance Monitoring.

  3. In the upper-right corner of the page, click Access Instance.

  4. Click DB Instances on ECS.

  5. Click Use DBGateway in Centralized Mode.

  6. Select a deployment method:

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

      1. Select the ECS instance in the target region and click Generate Deployment Command.

      2. Copy the command, log on to the ECS instance, and run it.

        If the command-line interface returns successfully, the deployment is successful. Otherwise, see Troubleshoot DBGateway deployment issues, resolve the issue, and redeploy.

      3. After the deployment is successful, DAS automatically discovers the gateway. If Current Status shows Normal, click Next.

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

      1. On the Select DBGateway page, select the target DBGateway.

      2. Click Discover Instance.

  7. On the Discover Instance page, discover database instances.

    1. DAS provides the following two methods for discovering database instances:

      • Select Automatic Scan:

        1. In the Scan Address field, enter the IP range or CIDR block.

        2. In the Port Range field, enter the port range to scan.

        3. Click Scan.

      • Select Enter Instances:

        1. In the Instances field, enter the instance details in the required format.

        2. Click Scan.

    2. After the instances are discovered, click Next.

  8. Enter the database login information.

    Parameter

    Description

    Select Engine

    Database engine: MySQL, PostgreSQL, MongoDB, and Redis.

    Database account

    Account for the self-managed database.

    Password

    Password for the database account.

    Database IP

    IP address of the database to authorize.

    Note

    The database account must have the required permissions.

    • If an account with the required permissions already exists, enter the database account and password, and then click Authorize.

    • If an account with the required permissions does not exist, enter a database account and password, and then click Generate Authorization Command. Copy the command, run it on your database, and then click Authorize.

  9. Click Authorize. After you click Authorize, in addition to the Normal Connection status, there are four common errors:

    • Unauthorized: No database account or password provided.

    • Failed to access.: DAS could not connect. Possible causes: network issue or instance downtime.

    • Failed to verify.: The database account or password is incorrect.

    • Insufficient Permissions: Connected successfully, but the account lacks required permissions.

  10. Click Complete.

Host connection

  1. Log on to the DAS console.

  2. In the left-side navigation pane, choose Intelligent O&M Center > Instance Monitoring.

  3. In the upper-right corner of the page, click Access Instance.

  4. Click DB Instances on ECS.

  5. Click Use DBGateway in Host Mode.

  6. Select the ECS instance in the target region and click Generate Deployment Command.

  7. Copy the deployment command and run it on the selected ECS instance.

    If the command-line interface returns successfully, the deployment is successful. Otherwise, see Troubleshoot DBGateway deployment issues, resolve the issue, and redeploy.

  8. After the deployment is successful, DAS automatically discovers the gateway. If Current Status shows Normal, click Next.

  9. Enter the database login information.

    Parameter

    Description

    Select Engine

    Database engine: MySQL, PostgreSQL, MongoDB, and Redis.

    Database account

    Account for the self-managed database.

    Password

    Password for the database account.

    Database IP

    IP address of the database to authorize.

    Note

    The database account must have the required permissions.

    • If an account with the required permissions already exists, enter the database account and password, and then click Authorize.

    • If an account with the required permissions does not exist, enter a database account and password, and then click Generate Authorization Command. Copy the command, run it on your database, and then click Authorize.

  10. Click Authorize. After you click Authorize, in addition to the Normal Connection status, there are four common errors:

    • Unauthorized: No database account or password provided.

    • Failed to access.: DAS could not connect. Possible causes: network issue or instance downtime.

    • Failed to verify.: The database account or password is incorrect.

    • Insufficient Permissions: Connected successfully, but the account lacks required permissions.

  11. Click Complete.

API reference

API

Description

AddHDMInstance

Connects a database instance to DAS.