This topic describes how to connect self-managed databases that are not deployed on Alibaba Cloud to Database Autonomy Service (DAS). The databases include self-managed databases that are deployed in data centers or on VMs provided by other cloud service providers and database instances that are provided by other cloud service providers.

Prerequisites

The following types of self-managed databases can be connected to DAS:
  • MySQL
  • MongoDB
  • PostgreSQL
  • Redis
    Note Only self-managed Redis databases that run Redis 6.0 or earlier versions can be connected to DAS.

Usage notes

DAS opens only port 80. Database gateways can access DAS only by using port 80. Data is encrypted and transmitted by using gRPC and Transport Layer Security (TLS). This ensures data transmission security.

Connection modes

You can connect self-managed databases that are not deployed on Alibaba Cloud to DAS in one of the following modes:
  • Direct mode: No DAS gateways (DBGateways) are deployed. DAS accesses your database over the Internet. You need to only enter your database account and password. Only MySQL, MongoDB, and Redis databases can be accessed in this mode.
  • Centralized mode: A DAS gateway is deployed on at least one server to automatically discover database instances by means of CIDR blocks. We recommend that you deploy DAS gateways on two or more servers for disaster recovery.
  • Host mode: A DAS gateway is deployed on every server to automatically discover database instances. All DAS features are supported in this mode, such as full request analysis, SQL response time, and security audit. For more information, see Features for three connection modes.
Important DAS gateways can be deployed only on Linux servers.

Features for three connection modes

FeatureDirect modeCentralized modeHost mode (recommended)
Database metric monitoringSupportedSupportedSupported
Real-time performance monitoringSupportedSupportedSupported
Real-time session monitoringSupportedSupportedSupported
Storage analysisSupportedSupportedSupported
Slow request analysisSupportedSupportedSupported
Host metric monitoringNot supportedNot supportedSupported
Request diagnosticsNot supportedNot supportedSupported
Full request analysisNot supportedNot supportedSupported
Request response timeNot supportedNot supportedSupported
Security auditNot supportedNot supportedSupported

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. Click Other On-premise and Cloud Databases.
  4. Click Method 1: Direct Access.
  5. Configure the parameters that are described in the following table.
    ParameterDescription
    Select RegionSelect the region that is nearest to the location of the database.
    Select EngineSelect the type of the database.
    Database AccountEnter an account used to log on to the database.
    PasswordEnter a password used to log on to the database.
    InstancesEnter the names of instances in the Address:port format.
  6. Click Test Connection.
  7. If Verified is displayed in the Status column, click Save Instance. If Verified is not displayed, modify the parameters and then click Test Connection.
  8. If you want to add more databases, click Add More.

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. Click Other On-premise and Cloud Databases.
  4. Click Method 2: DBGateway in Centralized Mode.
  5. Select an access method.
    Note If you have not deployed a DAS gateway in the corresponding virtual private cloud (VPC), click Deploy a new DAS DBGateway and search for instances. If you have deployed a DAS gateway in the corresponding VPC, click Use existing DAS DBGateway to scan for new instances.
    • Deploy a new DAS DBGateway and search for instances
      1. In the dialog box that appears, click Deploy a new DAS DBGateway and search for instances.
      2. Select a network type and then click Generate Deployment Command.
        Note
        • Network Type: Configure this parameter based on the connection mode between the host on which DBGateway is deployed and Alibaba Cloud. Examples:
          • For self-managed databases connected over the Internet, select Public Network (Classic Network).
          • For databases in data centers or databases from other cloud service providers that are connected over a leased line, select Proprietary Network (VPC/Leased Line).
        • Network Domain: Configure this parameter to manage different environments such as self-managed databases deployed in data centers or those provided by other cloud service providers.
      3. Copy the deployment command. Then, log on to the corresponding host and run the command.
        Note If successfully is returned, the DAS gateway is deployed. DAS can automatically discover the gateway. If the DAS gateway failed to be deployed, refer to Common issues about DBGateway to troubleshoot this issue.
      4. If Normal is displayed in the Current Status column, click Next.
    • Use existing DAS DBGateway to scan for new instances
      1. In the dialog box that appears, click Use existing DAS DBGateway to search for instances.
      2. In the Select DBGateway step, select the DAS gateway and then click Discover Instance.
  6. In the Discover Instance step, scan and discover the database instances that you want to access.
    1. You can use one of the following methods to discover database instances:
      • 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 instances in the correct format in the Instances field.
        2. Click Scan.
          Note The DAS gateway automatically scans and discovers the database instance.
    2. Click Next Step.
  7. Configure the parameters that are described in the following table.
    ParameterDescription
    Select EngineSelect the type of the database.
    Database AccountEnter an account used to log on to the database.
    PasswordEnter a password used to log on to the database.
    IP AddressSelect 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 instance downtime occur.
    • Authentication Failed: The database account or password is incorrect.
    • Insufficient Permissions: The instance 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. Click Other On-premise and Cloud Databases.
  4. Click Method 3: DBGateway in Host Mode.
  5. Select a network type and then click Generate Deployment Command.
    Note
    • Network Type: Configure this parameter based on the connection mode between the host on which DBGateway is deployed and Alibaba Cloud. Examples:
      • For self-managed databases connected over the Internet, select Public Network (Classic Network).
      • For databases in data centers or databases from other cloud service providers that are connected over a leased line, select Proprietary Network (VPC/Leased Line).
    • Network Domain: Configure this parameter to manage different environments such as self-managed databases deployed in data centers or those provided by other cloud service providers.
  6. Copy the deployment command. Then, log on to the corresponding host and run the command.
    Note If successfully is returned, the DAS gateway is deployed. DAS can automatically discover the gateway. If Normal is displayed in the Current Status column, click Next. If the DAS gateway failed to be deployed, refer to Common issues about DBGateway to troubleshoot this issue.
  7. Configure the parameters that are described in the following table.
    ParameterDescription
    Select EngineSelect the type of the database.
    Database AccountEnter an account used to log on to the database.
    PasswordEnter a password used to log on to the database.
    IP AddressSelect 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 instance downtime occur.
    • Authentication Failed: The database account or password is incorrect.
    • Insufficient Permissions: The instance can be connected, but the permissions are insufficient. For more information, see Permissions.
  9. Click OK.