Redis master-slave replication is actually very simple, and even easier than MySQL configuration, because basically no operation is required on the master server.
We open different ports on the same server for testing (the installation part is not mentioned. The previous articles include ::)
1. Start the master server (default port 6379)
/Etc/init. d/redis_6379 start
2. enable the first slave server
Redis-server -- Port 6380 -- slaveof 127.0.0.1 6379
This command needs to be performed in the src directory under your redis installation directory. It is strange that it is named make-install and an error will be reported when an existing service is started.
First, set the slave server port to 6380, enable the slave server function, and point the port to 6379.
3. Enable the second slave server
Redis-server -- Port 6381 -- slaveof 127.0.0.1 6380
========================================================== ======================================
In this way, our server group forms the relationship between the master and slave;
In fact, you can also set the port number of the master replication server of the second slave server to 6379, which becomes the relationship between one master and two slaves.
========================================================== ======================================
We set
Check the two slave servers:
It should be noted that once it is set as a slave server, you cannot perform write or modify operations, and only read operations are allowed.
This also indirectly facilitates the read/write Splitting Operation after we use the redis cluster;