All Products
Search
Document Center

ApsaraDB for Redis:Use the Sentinel-compatible mode to connect to an ApsaraDB for Redis instance

Last Updated:May 10, 2024

ApsaraDB for Redis uses the high-availability (HA) component developed by Alibaba Cloud instead of Redis Sentinel. To improve the compatibility of ApsaraDB for Redis with open source Redis and minimize code modifications, ApsaraDB for Redis provides the Sentinel-compatible mode. After you enable this mode for an instance, clients can connect to the instance in the same manner as they connect to Redis Sentinel.

Overview of Redis Sentinel

Redis Sentinel provides open source Redis with features such as master and replica monitoring, fault alerting, and automatic failover. Redis Sentinel is suitable for many business scenarios that use self-managed Redis databases and require high reliability. To facilitate the migration of Redis databases to the cloud in such scenarios, Alibaba Cloud provides the Sentinel-compatible mode. After you enable the Sentinel-compatible mode, you can run the Sentinel commands described in the following table.

Command

Description

SENTINEL sentinels

Queries Sentinel instances of a master and the status of the Sentinel instances. Command syntax:

SENTINEL sentinels <Name of a master>

SENTINEL get-master-addr-by-name

Queries the IP address and port number of a master. Command syntax:

SENTINEL get-master-addr-by-name <Name of a master>

For more information about Sentinel commands that are supported by different engine versions, see Commands supported by ApsaraDB for Redis Community Edition.

Prerequisites

  • The engine version of the ApsaraDB for Redis instance is Redis 4.0 or later.

  • The ApsaraDB for Redis instance is deployed in a virtual private cloud (VPC).

    Note

    If the ApsaraDB for Redis instance runs in the classic network, switch the network type to VPC. For more information, see Switch the network type from classic network to VPC.

  • The internal IP address of your Elastic Compute Service (ECS) instance or the public IP address of your on-premises host is added to an IP address whitelist of the ApsaraDB for Redis instance. For more information, see Configure whitelists.

Procedure

  1. Log on to the ApsaraDB for Redis 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.

  2. In the left-side navigation pane of the Instance Information page, click System Parameters.

  3. Enable the Sentinel-compatible mode for the instance by modifying the corresponding parameter based on the instance architecture. For more information, see Configure instance parameters.

    • If the instance is a read/write splitting instance or a cluster instance in proxy mode, set the sentinel_compat_enable parameter to 1.

    • If the instance is a standard instance, set the #no_loose_sentinel-enabled parameter to yes.

    Note
    • You can view the instance architecture on the instance details page.

    • Cluster instances in direct connection mode use open source Redis Cluster for load balancing, eliminating the need for the Sentinel component. Additionally, Sentinel parameters cannot be configured in this mode.

    After you enable the Sentinel-compatible mode for the instance, you can connect to the instance and run the SENTINEL sentinels test command. If the command is successful, the Redis Sentinel-compatible mode is enabled for the instance. The Sentinel-compatible mode does not provide additional endpoints. You can use the original endpoint, such as r-********.redis.rds.aliyuncs.com:6379 to connect to the instance.

Connect to an instance in Sentinel-compatible mode

After the Sentinel-compatible mode is enabled, you can use one of the following methods to connect to the Redis instance: If password-free access is enabled for the Redis instance, you can connect to the instance in Sentinel-compatible mode. Otherwise, you must configure authentication information when you connect to the instance.

FAQ

  • What do I do if the NOAUTH Authentication required error message appears when I switch from the native Redis Sentinel mode to the Sentinel-compatible mode?

    You can upgrade your client, modify the code to add a password for Sentinel authentication, and then try again. For more information, see the "Connect to an instance in Sentinel-compatible mode" section of this topic.

  • Do Redis cost-efficient instances support the Sentinel-compatible mode?

    Yes, Redis cost-efficient instances support the Sentinel-compatible mode.