﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-aa19870406-随笔分类-k-v数据库</title><link>http://www.cppblog.com/aa19870406/category/19484.html</link><description /><language>zh-cn</language><lastBuildDate>Thu, 14 Jun 2012 23:45:24 GMT</lastBuildDate><pubDate>Thu, 14 Jun 2012 23:45:24 GMT</pubDate><ttl>60</ttl><item><title>redis aof文件浅析</title><link>http://www.cppblog.com/aa19870406/archive/2012/06/11/178419.html</link><dc:creator>MrRightLeft</dc:creator><author>MrRightLeft</author><pubDate>Mon, 11 Jun 2012 12:15:00 GMT</pubDate><guid>http://www.cppblog.com/aa19870406/archive/2012/06/11/178419.html</guid><wfw:comment>http://www.cppblog.com/aa19870406/comments/178419.html</wfw:comment><comments>http://www.cppblog.com/aa19870406/archive/2012/06/11/178419.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/aa19870406/comments/commentRss/178419.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/aa19870406/services/trackbacks/178419.html</trackback:ping><description><![CDATA[<div><div style="text-align: center;"><strong style="font-size: 18pt; ">redis aof文件浅析<br /><br /></strong></div>redis中的数据持久化有两种方式：RDB持久化和AOF持久化。RDB相对于AOF来说是一个粗粒度的备份，即RDB可能是一天备份一次，而AOF可能是每秒一次甚至每次写操作进行一次备份。</div><div></div><div>redis中的aof(append only file)文件的作用就相当于mysql中的binlog，用于记录写操作日志。当redis服务器异常宕机，可以使用该文件对数据进行恢复。进行数据恢复时，redis服务器端会创建一个 fake client（假冒客户端），即通过fake client来模拟redis客户端，该fake client读取aof文件并执行其中的redis command，通过这种方式来模拟redis客户端对redis服务器的操作（增删改），从而达到恢复数据的目的。</div><div></div><div>另外redis是k-v数据库，数据存储在内存，当然也会定时持久化。在redis服务关闭时，内存中原先的数据就会丢失，所以在redis每次重新启动时，需要将持久化的数据恢复到内存中。持久化的数据就是rdb和aof文件，具体采用的方式是根据redis的配置文件而定。</div> <div class="vimiumReset vimiumHUD" style="right: 150px; opacity: 0; display: none; "></div> <div class="vimiumReset vimiumHUD" style="right: 150px; opacity: 0; display: none; "></div> <div class="vimiumReset vimiumHUD" style="right: 150px; opacity: 0; display: none; "></div> <div class="vimiumReset vimiumHUD" style="right: 150px; opacity: 0; display: none; "></div> <div class="vimiumReset vimiumHUD" style="right: 150px; opacity: 0; display: none; "></div><img src ="http://www.cppblog.com/aa19870406/aggbug/178419.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/aa19870406/" target="_blank">MrRightLeft</a> 2012-06-11 20:15 <a href="http://www.cppblog.com/aa19870406/archive/2012/06/11/178419.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>