w3resource

Redis Server: SLAVEOF

Redis SLAVEOF Command

Redis SLAVEOF command can change the replication settings of a slave on the fly. If a Redis server is already acting as a slave, the command SLAVEOF NO ONE will turn off the replication, turning the Redis server into a MASTER. If a server is already a slave of some master, SLAVEOF hostname port will stop the replication against the old server and start the synchronization against the new one, discarding the old dataset.

Here are some common uses and scenarios for the "SLAVEOF" command:

  • Replication Setup: Configures a Redis instance to act as a replica (slave) of another Redis instance (master), enabling data replication.
  • Failover Configuration: Supports setting up high availability by designating a new master if the current master fails.
  • Role Changes: Allows changing the role of an instance from master to replica or vice versa, facilitating role reconfiguration.
  • Testing and Development: Useful for testing replication and failover scenarios in development environments.

Syntax:

SLAVEOF host port

Available since

1.0.0.

Return Value

Simple string reply

Return Value Type

String

Previous: SHUTDOWN
Next: SLOWLOG



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/redis/redis-server-slaveof-host-port.php