0
0
Redisquery~5 mins

Client discovery through Sentinel in Redis

Choose your learning style9 modes available
Introduction

Client discovery through Sentinel helps your application find the current master server automatically. This way, your app always talks to the right Redis server even if the master changes.

When you have a Redis setup with one master and multiple replicas.
When you want your app to automatically connect to the current master without manual changes.
When you want high availability and automatic failover in Redis.
When you want to avoid downtime caused by master server changes.
When you want your app to be resilient to Redis server failures.
Syntax
Redis
SENTINEL get-master-addr-by-name <master-name>

This command asks Sentinel for the current master address by its name.

The response is an array with two elements: the IP and the port of the master.

Examples
Returns the IP and port of the master named 'mymaster'.
Redis
SENTINEL get-master-addr-by-name mymaster
Lists all masters monitored by Sentinel with their details.
Redis
SENTINEL masters
Sample Program

This command asks Sentinel to give the current master address for the master named 'mymaster'.

Redis
SENTINEL get-master-addr-by-name mymaster
OutputSuccess
Important Notes

Make sure your application connects to the IP and port returned by Sentinel to always reach the master.

If the master fails, Sentinel will promote a replica to master and update the address returned.

You can run this command periodically or at app startup to discover the master.

Summary

Sentinel helps your app find the current Redis master automatically.

Use SENTINEL get-master-addr-by-name to get the master IP and port.

This makes your Redis setup more reliable and easier to manage.