Implementing Redis's master-slave replication configuration is simple and easy to understand.
is the master-slave copy structure that you want to configure:
1. Description
A master service in Redis master-slave replication can have multiple slave services, one from a service.
Configuration is simple, you only need to change the slaveof parameter configuration in the redis.conf file.
The format of the slaveof parameter is as follows: Slaveof <masterip> <masterport>
You need to configure the Masterauth parameter if the master server has a password set.
Masterauth parameter formats such as: Masterauth <master-password>
2. Configuring the master-Slave server
The IP of the port of the server is visible as master and Slave1,slave2,slave3.
Master:
Port 6379
Requirepass Redis
SLAVE1:
Port 6479
slaveof 127.0.0.1 6379
Masterauth Redis
Requirepass Redis
Slave2:
Port 6579
slaveof 127.0.0.1 6479
Masterauth Redis
Requirepass Redis
Slave3:
Port 6679
slaveof 127.0.0.1 6379
Masterauth Redis
Requirepass Redis
It is important to note that if you set the Requirepass parameter in the server, you do not need to set the Masterauth parameter from the service.
3. Starting server and client connections
master:$ Redis-server master.conf
slaven:$ redis-server slaven.conf[in turn)
client:$ redis-cli-a <requirepass>-P <port> Note here the port number must be set to the ports on which the server to connect is listening because there are more servers open.
After connecting to Redis-serverz via REDIS-CLI, execute the info command to view the server information.
Master
You can see that the master server's role is master and that it has 2 slave services, namely 127.0.0.1:6479 and 127.0.0.1:6679, which are the slave2 and slave3 described in the corresponding article.
SLAVE1:
It can be seen that the SLAVE1 server role is slave, and the primary server to which it connects is 127.0.0.1:6379, the master described in the article, as the primary server in the entire master-slave replication set, and the 1 slave-server 127.0.0.1:6579 connected to it. The server is the slave2 described in this article, which is set as slave server throughout the master-slave replication.
Slave2:
It can be seen that slave2 is from the server, whose connection to the primary server is 127.0.0.1:6479, that the slave1,slave1 described in this article is the same as from the server in the entire master-slave replication set.
Slave3:
It can be seen that slave3 is from the server, its connected primary server is 127.0.0.1:6379, that is, the master,master described in this article is the primary server in the entire master-slave replication set.
4. Application
The write functionality from the service is closed by default, and it is not recommended to write data from the server.
Some of the column configurations in this article allow for a reasonable separation of client reads and writes from the Redis database in the application.
Ubuntu 14.04 Redis installation and simple test http://www.linuxidc.com/Linux/2014-05/101544.htm
Redis Cluster Detail Document Http://www.linuxidc.com/Linux/2013-09/90118.htm
Installation of Redis under Ubuntu 12.10 (graphic) + Jedis connection Redis http://www.linuxidc.com/Linux/2013-06/85816.htm
Redis Series-Installation and deployment Maintenance Chapter Http://www.linuxidc.com/Linux/2012-12/75627.htm
CentOS 6.3 Installation Redis http://www.linuxidc.com/Linux/2012-12/75314.htm
Redis Installation Deployment Learning Note http://www.linuxidc.com/Linux/2014-07/104306.htm
Redis configuration file redis.conf detailed http://www.linuxidc.com/Linux/2013-11/92524.htm
a detailed introduction to Redis : please click here
Redis's : please click here
This article permanently updates the link address : http://www.linuxidc.com/Linux/2015-03/115610.htm
Implementing a master-slave replication configuration for Redis