简体   繁体   English

即使重新启动并完全关闭电源后,Redis如何将数据持久保存在本地Apache服务器上?

[英]How does Redis persist data on my local Apache server even after reboot and complete power down?

From how I understand, Redis uses in memory from which I gather my RAM if I am running a local apache development server. 据我了解,如果我正在运行本地apache开发服务器,Redis会在内存中使用收集内存的内存。 I tried powering down my computer and disconnected the power cable as well, but the redis data on my local server development website persisted when I powered back up my computer and tested my test website again. 我曾尝试关闭计算机电源并断开了电源线,但是当我重新启动计算机并再次测试我的测试网站时,本地服务器开发网站上的redis数据仍然存在。 I thought RAM data gets completely wiped when I do a system reboot, how does Redis persist data even after reboot on my local development environment? 我以为重新启动系统后RAM数据会被完全擦除,即使在本地开发环境上重新启动后,Redis如何持久保存数据? Thanks! 谢谢! :) :)

Redis serves data only out of RAM, but it provides two modes of persistence RDB (snapshot persistence) and AOF (changelog persistence). Redis仅在RAM之外提供数据,但是它提供了两种持久性模式RDB(快照持久性)和AOF(变更日志持久性)。 If either mode of persistence is enabled on your Redis server, then your data will persist between reboots. 如果在Redis服务器上启用了任何一种持久性模式,则数据将在两次重新引导之间保持不变。

The config directives you want to check are: 您要检查的config指令是:

  • appendonly yes appendonly是
  • save

More information on Redis Persistence here. 有关Redis Persistence的更多信息,请参见此处。

Redis has persistence options that saves Redis data in either RDB or AOF format (basically saving the Redis data to a file/log): Redis具有持久性选项,可将其以RDB或AOF格式保存(基本上将Redis数据保存到文件/日志中):

  • The RDB persistence performs point-in-time snapshots of your dataset at specified intervals. RDB持久性按指定的时间间隔执行数据集的时间点快照。

  • The AOF persistence logs every write operation received by the server, that will be played again at server startup, reconstructing the original dataset. AOF持久性会记录服务器接收的每个写入操作,这些操作将在服务器启动时再次播放,以重建原始数据集。 Commands are logged using the same format as the Redis protocol itself, in an append-only fashion. 使用与Redis协议本身相同的格式记录命令,并且采用仅追加方式。 Redis is able to rewrite the log on background when it gets too big. 当日志太大时,Redis可以在后台重写日志。

  • If you wish, you can disable persistence at all, if you want your data to just exist as long as the server is running. 如果希望,只要您的数据在服务器运行时就一直存在,则可以完全禁用持久性。
  • It is possible to combine both AOF and RDB in the same instance. 可以在同一实例中同时合并AOF和RDB。 Notice that, in this case, when Redis restarts the AOF file will be used to reconstruct the original dataset since it is guaranteed to be the most complete. 请注意,在这种情况下,当Redis重新启动时,AOF文件将用于重建原始数据集,因为它可以保证是最完整的。

This info was quoted from https://redis.io/topics/persistence , which goes into detail about these options. 此信息引自https://redis.io/topics/persistence ,其中详细介绍了这些选项。

You can read more from the Antirez weblog: Redis Persistence Demystified 您可以从Antirez网站日志中了解更多信息: Redis Persistence Demystified

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C++ - 即使在突然断电的情况下,如何将应用程序日志写入磁盘 - C++ - How to make application-logs written to disk even in case of a sudden power down 为什么延迟只有在重启后才会停止? - Why does lag only stop after reboot? 在运行时将数据保存在服务器中的首选方法是什么 - what are the preferred ways to persist data in server in runtime 重新启动或群集故障转移后SQL Server Extreme缓慢 - SQL Server Extreme slowness after reboot or fail-over of cluster 完成lambda function后,存储在redis上的AWS lambda数据是否保留? - Does AWS lambda data stored on redis remain after finish lambda function? 在Windows API应用程序定义的回调函数中,指针参数数据的生存期是多少? 回调返回后是否继续存在? - In Windows API application-defined callback functions, what is the lifetime of pointer parameter data? Does it persist after the callback returns? 为什么指针的分配内存在函数之后仍然存在,而不是数组? - Why does a pointer's allocated memory persist after a function, but not an array? 数据应该在Redis Cache中存放多长时间? - How long should data be stored in Redis Cache? Apache MINA 不删除未使用的数据 - Apache MINA does not remove unused data redis服务器的足迹 - Footprint of a redis server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM