---
title: "SLAVEOF host port "
author: "cocos"
date: "2011-07-18T13:54:58Z"
tags: []
categories: ["开源软件"]
slug: "slaveof-host-port"
draft: false
lastmod: "2011-07-18T13:54:58Z"
id: 1126910
url: "https://cocos.iteye.com/blog/1126910"
---

The [SLAVEOF](http://redis.io/commands/slaveof) command can change the replication settings of a slave on the fly. If a Redis server is already acting as slave, the command [SLAVEOF](http://redis.io/commands/slaveof) NO ONE will turn off the replication turning the Redis server into a MASTER. In the proper form [SLAVEOF](http://redis.io/commands/slaveof) hostname port will make the server a slave of the specific server listening at the specified hostname and port.

If a server is already a slave of some master, [SLAVEOF](http://redis.io/commands/slaveof) hostname port will stop the replication against the old server and start the synchronization against the new one discarding the old dataset.

The form [SLAVEOF](http://redis.io/commands/slaveof) no one will stop replication turning the server into a MASTER but will not discard the replication. So if the old master stop working it is possible to turn the slave into a master and set the application to use the new master in read/write. Later when the other Redis server will be fixed it can be configured in order to work as slave.