Programmers conversation series - some of understanding about the redis

A, Redis data loss, power failure how to do?

There RDB and redis AOF backup operation which, RDB is desynchronized redis intervals, generate a binary file. AOF will write a command to the file appendonly, the relative amount of data relatively wide real-time, but the files are large. RDB is bgsave command, background fork child process, copy writing through the resulting file redis large, then there will be a big impact

Two, redis clusters how to ensure that?

Development of Sentinel mode, when the master downtime, and to select the optimal, high availability from the slave.

Third, the cluster split brain phenomenon how to solve?

Preventing split brain - set timeout: As - link timeout is set to 2 seconds. Any link will only work within 2 seconds. So Sentinel elect a new master, it can be delayed for 2 seconds. Places to live: to enhance network health to ensure that no hardware problems arise, there would be no link may be interrupted, and in case of link is broken, it must be master of all the external broken links.

Resolve split brain - set up monitoring center to provide early warning function. Offline processing of human brain split consequences. Timing scanning synchronization data.

Fourth, how to synchronize database initialization redis

Start a slave of time, will send a psync command to the master, if it is first connected to the slave master, he will trigger a full-volume copy. master will start a thread to generate RDB snapshot, but also the new write requests are cached in memory, RDB after the file is generated, the master will RDB sent to the slave, the slave got to do after the first thing written to the local disk, and then loaded into memory, and then put those newly named master cache memory which are sent to slave.

V. cache breakdown how to solve?

Hot Key catastrophic failure at a certain time, the emergence of data crashes.

1, buffer time and never fail

2, a distributed lock to avoid falls directly on the library: set nx can jedis achieve. (How to avoid deadlock phenomenon?)

3, to set up a multi-level cache, avoid direct query the database, use eache.

Guess you like

Origin www.cnblogs.com/ffdsj/p/12555036.html