可信赖的redis备份方案
伊谢尔伦
伊谢尔伦 2017-04-21 11:17:01
0
2
658

redis是基于内存的,所以存在当程序挂掉数据丢失的可能。我目前想到的备份方案是,做一个主从,从库做定时dump。

但是dump是不是实时的,而是隔一段时间做一次,所以这期间还是有丢失数据的可能。是否有方案能实时备份redis的数据,让redis出了问题以后快速恢复。

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
迷茫

Enable AOF (append-only file).

大家讲道理

The problem of data loss can be solved through master-slave replication of redis. However, I think there are ways to reduce the risk and scope of data loss. Ticket grabbing is a typical high-concurrency scenario. You can consider only storing the ticket inventory information in the memory, and storing other information through a more reliable database.

Specific solution:
1. Redis enables master-slave replication and can use more than two slaves to solve single-point problems and load balancing when providing external read services;
2. As for the crashed data recovery solution, you can log out of the queue operation to record the log. If the service crashes, you can quickly restore the inventory through the log after restarting;
3. Solutions to reduce the risk of data loss. For example, use the queue data structure of redis to save the ticket inventory. If you successfully exit the queue, you will get the ticket. Then save the ticket grabbing relationship to the database, and then place the order & pay;
4. In actual use experience, the probability of redis crashing is low, but it is really troublesome to recover data after it crashes. So it’s best to look at the usage scenarios. If the data is very important, it is recommended to avoid placing it in the memory database as much as possible. It is better to implement the data.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template