Implementing Redis's master-slave replication configuration is simple and easy to understand.
is the master-slave copy structure that you want to configure:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/5B/80/wKioL1UKr4TgRgBSAADSvXHCQuM707.jpg "title=" Redis-master-slave-replication.png "alt=" Wkiol1ukr4tgrgbsaadsvxhcqum707.jpg "/>
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
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5B/80/wKioL1UKsz_Ai7P4AAFeY4buNpA662.jpg "style=" float: none; "title=" Master.png "alt=" Wkiol1uksz_ai7p4aafey4bunpa662.jpg "/>
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:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5B/86/wKiom1UKshXi8QLcAAHfo87VVq0801.jpg "style=" float: none; "title=" Slave-1.png "alt=" Wkiom1ukshxi8qlcaahfo87vvq0801.jpg "/>
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:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5B/80/wKioL1UKs0DgpZxzAAF_CbjMLyM284.jpg "style=" float: none; "title=" Slave-2.png "alt=" Wkiol1uks0dgpzxzaaf_cbjmlym284.jpg "/>
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:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5B/86/wKiom1UKshWTT86XAAGJYgEcVN0080.jpg "style=" float: none; "title=" Slave-3.png "alt=" Wkiom1ukshwtt86xaagjygecvn0080.jpg "/>
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.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5B/86/wKiom1UKtYSh4gNZAACKfNzBwz0141.jpg "title=" Read-only.png "alt=" Wkiom1uktysh4gnzaackfnzbwz0141.jpg "/>
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.
This article is from the "Red Horse Red" blog, please be sure to keep this source http://aiilive.blog.51cto.com/1925756/1622329
Redis Master-slave replication Basic Configuration