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
NoteOnly 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.
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
Log on to the DAS console.
In the Recommended Features section of the Overview page, click Access Instance.
On the page that appears, click DB Instances on ECS.
Click Method 1: Direct Access.
Select the region in which the ECS instances are deployed.
Find a security group and select Private Network in the Add DAS access rules column. Then, click Save.
NoteDAS 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.
Select the ECS instances on which the database nodes are deployed and click Next.
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.
NoteThe 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.
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.
Click OK.
Connect databases to DAS in centralized mode
Log on to the DAS console.
In the Recommended Features section of the Overview page, click Access Instance.
On the page that appears, click DB Instances on ECS.
Click Method 2: DBGateway in Centralized Mode.
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.
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.
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.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 .
In the Select DBGateway step, select the DAS gateway.
Click Discover Instance.
In the Discover Instance step, configure the DAS gateway to scan for databases.
You can use one of the following methods to discover databases:
Select Automatic Scan
Enter the CIDR block that you want to scan in the Scanned Address field.
Enter the port range in the Port Range field.
Click Scan.
Select Enter Instances
Enter databases in the correct format in the Instances field.
Click Scan.
After the information of the database that you want to access is displayed in the Scan Results section, click Next.
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.
NoteThe 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.
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.
Click OK.
Connect databases to DAS in host mode
Log on to the DAS console.
In the Recommended Features section of the Overview page, click Access Instance.
On the page that appears, click DB Instances on ECS.
Click Method 3: DBGateway in Host Mode.
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.
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.DAS can automatically discover the deployed gateway. If the DAS gateway is in the Normal state, click Next.
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.
NoteThe 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.
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.
Click OK.
Related API operation
Operation | Description |
Connects a database instance to DAS. |