ApsaraDB for Redis provides multiple endpoint types and allows you to connect to an instance over a Virtual Private Cloud (VPC) or the Internet. You can connect to an instance by using Data Management (DMS), redis-cli, or a client.
Endpoint types
By default, you can connect to a ApsaraDB for Redis instance over VPC.If you want to connect to your ApsaraDB for Redis instance from your on-premises device or other devices over the Internet, apply for a public endpoint for the ApsaraDB for Redis instance.
- If your client is deployed on an ECS instance in the same VPC as your ApsaraDB for Redis instance, we recommend that you connect to the ApsaraDB for Redis instance over the VPC by using a private endpoint. This improves security and reduces network latency.
- If your client is deployed on an on-premises device or an ECS instance that resides in a different region and a different VPC from your ApsaraDB for Redis instance, you can connect to the ApsaraDB for Redis instance over the Internet by using a public endpoint. Otherwise, you fail to connect to the ApsaraDB for Redis instance.
Prerequisites
- The public IP address of your client is added to a whitelist of the ApsaraDB for Redis instance.
Before you can connect to your ApsaraDB for Redis instance over a VPC or the Internet, you must add the IP address or CIDR block of your client to a whitelist of the ApsaraDB for Redis instance. For more information, see Step 2: Configure whitelists.
- The username and password of an account are set to connect to the ApsaraDB for Redis instance.
You can connect to your ApsaraDB for Redis instance by using a default or custom account. For more information, see Access an ApsaraDB for Redis instance.
Procedure
In this example, redis-cli is used to establish a connection between an Elastic Compute Service (ECS) instance that runs on the Linux operating system and an ApsaraDB for Redis instance over a VPC.
Common connection methods
Client | Recommended network type | Description |
---|---|---|
DMS | VPC | Log on to an ApsaraDB for Redis instance by using DMS |
ECS instance in the same VPC as the ApsaraDB for Redis instance | VPC | |
|
Internet |
- Use a client to connect to an ApsaraDB for Redis instance that has SSL encryption enabled: SSL encryption improves transport link security and ensures data integrity.
- Use a private endpoint to connect to an ApsaraDB for Redis instance: If your instance is a ApsaraDB for Redis cluster instance, you can use a private endpoint to bypass proxy nodes and directly access backend data shards. This connection to cluster instances is similar to the connection to open source Redis clusters. Compared with the proxy mode, the direct connection mode reduces the response time of ApsaraDB for Redis because requests do not need to pass through proxy servers.
- Use the Sentinel-compatible mode to connect to an ApsaraDB for Redis instance: ApsaraDB for Redis provides the Sentinel-compatible mode. After you enable this mode, ApsaraDB for Redis instances can be connected from the client in the same manner as the native Redis Sentinel.
FAQ
Error message | Cause and solution |
---|---|
(error) ERR illegal address |
The whitelist is incorrectly configured.
ping endpoint command. If no errors are returned, the client connects to the ApsaraDB for Redis instance. Sample command: ping r-bp1zxszhcgatnx****.redis.rds.aliyuncs.com .
|
(error) ERR client ip is not in whitelist |
|
Could not connect to Redis |
|
|
The password is invalid. Specify the correct password in a valid format. The password
format varies with the account type.
Note
|