redis master-slave replication principle and configuration

1. scenario
write speed 2.redis although very fast, when a large amount of data access time, or somewhat laborious, from the master copy can share some of the pressure from the structure, a single server Redis single point of failure, and a server needs to process all requests load, greater pressure; from the capacity, the limited memory capacity of a single server Redis, even if a memory capacity of 256G Redis server, all of the memory can not be used as memory storage Redis, in general, Redis largest single use of memory should not exceed 20G.
2. Fundamentals
redis master-slave replication principle and configuration
3. Detailed configuration
192.168.98.27 as master, 192.168.98.111 192.168.98.112 and a slave, redis installation source is omitted here, after installation redis.conf need to modify the configuration in which the following is necessary to place make changes, find the daemonize be amended to mean yes open daemon, add the bind line to find out the address of 0.0.0.0 release is meant to allow any address to the link, find requirepass line behind the release of custom code, find dir row edb written after the storage path absolute path, you can customize my written / var / lib / redisdb, otherwise after starting redis rdb file will be fixed in the otherwise chaotic fixed directory, in the last two 192.168.98.111 and 192.168.98.112 a redis.conf which were added slaveof 192.168.98.27 6379, and then add masterauth master password to save and exit! Below illustrates
redis master-slave replication principle and configuration
redis master-slave replication principle and configuration
redis master-slave replication principle and configuration
redis master-slave replication principle and configuration
redis master-slave replication principle and configuration
4 respectively starting from the master node and two nodes redis
redis master-slave replication principle and configuration
log 5. 192.168.98.27 main redis
redis master-slave replication principle and configuration
6. The display configuration status info view two Replication in force from the input node of the master node
redis master-slave replication principle and configuration
7. In the two 192.168.98.111 and two 192.168.98.112 view from the master node from the state has entered into force
redis master-slave replication principle and configuration
redis master-slave replication principle and configuration
8. redis into the primary data, clear data flushall, to avoid interference
redis master-slave replication principle and configuration
in the 111 and 112 The above data can be read
redis master-slave replication principle and configuration
9. The test 111 and 112 to write data from the database from redis fails, the default slave-read-only yes, If it is possible to write data from the no
redis master-slave replication principle and configuration
completion point, Redis master-slave configuration described hereinafter disaster recovery processing section!
10. DR processing
when master service failure, the need to manually lift the slave of one master, the remaining slave linked to a new master (cold treatment: hang the machine, reprocessing)
192.168.98.27master simulated fault close, the master will enhance 192.168.98.111
redis master-slave replication principle and configuration
use slaveof no one, to a second server to 192.168.98.111slave Master ( slaveof no one is lifting a slave master)
redis master-slave replication principle and configuration
info Replication
redis master-slave replication principle and configuration
performed in SLAVEOF 192.168.98.111 6379 192.168.98.112 above
redis master-slave replication principle and configuration
info replication, the main display 111 112redis from the redis
redis master-slave replication principle and configuration
added to the original broken 192.168.98.27redis from the structure, restarting redis 98.27 on the server, and then execute SLAVEOF 192.168.98.111 6379 iNFO replication view the information found in the main library from the library only to realize that the success of the 112, 98.27 Main library to see the state is down, the reason is not configured manually add masterauth after a successful state in redis.conf 27's!
redis master-slave replication principle and configuration
View the status of all normal! (27 and 112 from the main success of library, library 111)
redis master-slave replication principle and configuration
PS: This modification in the command line switches from the temporary library commands are in effect, you must modify the order permanent redis.conf configuration file, which is required instead slaveof 192.168.98.111 6379 masterauth 111redis password inside 27 and 112redis.conf before the redis.conf 192.168.98.111 inside slaveof and masterauth can be removed; redis main conclusion is that the main library from the configuration file and do not write slaveof masterauth that two-line arguments, and who is to write slaveof masterauth from the library in the configuration from the library inside that two-line parameters, save and exit permanent!

Guess you like

Origin blog.51cto.com/10087093/2480487