This topic describes how to connect to a Tair (Redis OSS-compatible) instance by using Data Management (DMS) or redis-cli.
Prerequisites
An IP address whitelist is configured for the instance.
A password is specified for the instance. If no password is specified for the instance, see Change or reset the password.
Procedure
DMS
Log on to the console and go to the Instances page. In the top navigation bar, select the region in which the instance that you want to manage resides. Then, find the instance and click the instance ID.
In the upper-right corner of the instance details page, click Log into Database.
In the Log on to Database Instance dialog box, set the Access mode parameter to password login and enter a password.
In this mode, the default account is used for logon. You can view the account details on the Account Management page in the console.
Click Login.
Write and read data.
On the SQLConsole page in the DMS console, enter the
SET foo hello
command and click Execute(F8).The expected output is
OK
.Enter the
GET foo
command and click Execute(F8).The expected output is
hello
.
redis-cli
In this example, redis-cli is used to connect to a Tair (Redis OSS-compatible) instance from a Linux Elastic Compute Service (ECS) instance. The ECS instance is deployed in the same virtual private cloud (VPC) as the Tair (Redis OSS-compatible) instance.
Log on to the ECS instance and run the following commands in sequence to download, install, and compile redis-cli:
sudo yum -y install gcc # Install GNU Compiler Collection (GCC). wget https://download.redis.io/releases/redis-7.0.0.tar.gz tar xzf redis-7.0.0.tar.gz cd redis-7.0.0&&make
In this example, redis-cli 7.0.0 is used. You can install another version. It takes 2 to 3 minutes to compile and install redis-cli.
Run the following command to connect to the instance:
src/redis-cli -h hostname -a password -p port
Parameters:
hostname: the endpoint of the instance. In the Connection Information section of the instance details page in the console, you can view the VPC endpoint of the instance, such as
r-8vbwds91ie1rdl****.redis.zhangbei.rds.aliyuncs.com
. For more information, see View endpoints.password: the password of the instance.
port: the port number. Default value: 6379.
Sample command:
src/redis-cli -h r-8vbwds91ie1rdl****.redis.zhangbei.rds.aliyuncs.com -a TestPassword123 -p 6379
Write and read data.
Run the
SET bar foo
command.The expected output is
OK
.Run the
GET bar
command.The expected output is
"foo"
.
References
For more information, see the following topics:
Special connection methods
Use a client to connect to an instance for which TLS (SSL) encryption is enabled: TLS encryption improves transport link security and ensures data integrity.
Use the direct connection mode to connect to a cluster instance: If your instance is a cluster instance in direct connection mode, you can use the 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 because requests do not need to pass through proxy nodes.
Use the Sentinel-compatible mode to connect to an instance: Tair (Redis OSS-compatible) provides the Sentinel-compatible mode. After you enable this mode, instances can be connected from the client in the same manner as the native Redis Sentinel.
Common errors and troubleshooting
Error message | Cause and solution |
| The whitelist is incorrectly configured.
Then, run the |
| |
| |
| The password is invalid. Specify the correct password in a valid format. The password format varies based on the selected account.
Note
|