天天看點

redis中的aof模式,産生的是增量資料,還是全量資料?

先說答案:全量資料。

1、修改redis.conf,開啟rdb,禁用aof

redis中的aof模式,産生的是增量資料,還是全量資料?
redis中的aof模式,産生的是增量資料,還是全量資料?
redis中的aof模式,産生的是增量資料,還是全量資料?
上面這個是持久化檔案的路徑,我們ll看下:
redis中的aof模式,産生的是增量資料,還是全量資料?
2、啟動redis後,cli檢視裡面的key

[root@mini1 redis-4.0.2]# src/redis-server ./redis.conf 

[root@mini1 redis-4.0.2]# src/redis-cli 


      
redis中的aof模式,産生的是增量資料,還是全量資料?

3、現在轉換為aof模式

線上轉換參考:https://redis.io/topics/persistence

How I can switch to AOF, if I'm currently using dump.rdb snapshots?
There is a different procedure to do this in Redis 2.0 and Redis 2.2, as you can guess it's simpler in Redis 2.2 and does not require a restart at all.
Redis >= 2.2
Make a backup of your latest dump.rdb file.
Transfer this backup into a safe place.
Issue the following two commands:
redis-cli config set appendonly yes
redis-cli config set save ""
Make sure that your database contains the same number of keys it contained.
Make sure that writes are appended to the append only file correctly.
The first CONFIG command enables the Append Only File. In order to do so Redis will block to generate the initial dump, then will open the file for writing, and will start appending all the next write queries.
The second CONFIG command is used to turn off snapshotting persistence. This is optional, if you wish you can take both the persistence methods enabled.
IMPORTANT: remember to edit your redis.conf to turn on the AOF, otherwise when you restart the server the configuration changes will be lost and the server will start again with the old configuration.
      

  

 在用戶端cli執行:

config set appendonly yes

config set save ""      
redis中的aof模式,産生的是增量資料,還是全量資料?

 4、新增幾個key,生成aof檔案,檢視内容是否包含rdb中的内容

redis中的aof模式,産生的是增量資料,還是全量資料?
[root@mini1 backup]# less appendonly.aof       

結果如下:

redis中的aof模式,産生的是增量資料,還是全量資料?

綜上:說明aof生成的檔案不是增量的,不是僅僅生成開啟aof之後的指令的記錄,而是包括全部的資料庫記錄