Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Persistence of Redis

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Redis is an in-memory database that supports persistence, which means that redis needs to frequently synchronize the data in memory to the hard disk to ensure persistence. Redis supports two persistence methods:

1. Snapshotting (snapshot) is also the default method. Writes the data in memory to the file as a snapshot. The default file name is dump.rdb.

[root@D2-LZY245 redis-4.0.1] # grep ^ save redis.conf

Save 900 1

Save 300 10

Save 60 10000

2. Append-only file (aof). Because snapshots are done at regular intervals, if redis accidentally down, all modifications since the last snapshot will be lost. Aof is more persistent than snapshots because when using aof, redis appends every write command received to the file through the write function, and when redis restarts, it rebuilds the contents of the entire database in memory by re-executing the write commands saved in the file.

Because os caches changes made by write in the kernel, everything may not be written to disk immediately. In this way, it is still possible to lose some of the changes in aof persistence. You can tell redis through the configuration file when you want to force OS to write to disk through the fsync function.

# The name of the appendonly file (default: "appendonly.aof")

Appendfilename "appendonly.aof"

# always: fsync after every write to the append only log. Slow, Safest.

# appendfsync always

Appendfsync everysec

# appendfsync no

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report