In some usage scenarios, we do not need to use redis persistence, instead we need to play Redis's in-memory database features for full memory operation to achieve the required high performance.
Redis itself supports persistence by synchronizing the in-memory data to disk at certain intervals or triggering operations. Redis supports two persistence modes, one is snapshotting (snapshot), saved as Dump.rdb file, is the default, and the other is Append-only file (abbreviated AOF), saved as. aof files.
The Snapshot snapshot notifies Redis to do a snapshot persistence with either the Save or the Bgsave command. The save action is to save the snapshot in the main thread, which blocks all client requests because Redis uses a main thread to process all client requests. So it is not recommended. It is also important to note that each snapshot persistence is a full write of memory data to disk once, not incremental synchronous incremental data only. If the volume of data is large, the write operation will be more, will inevitably cause a large number of disk IO operations, may seriously affect performance.
In the default snapshot Rdb save mode, the configuration in redis.conf is as follows
Save 1 #900秒内如果超过1 key is modified to initiate a snapshot save
Save #300秒内容如超过10个key is modified to initiate a snapshot save
Save 60 10000
If we need to close the snapshot, just comment the lines and restart Redis.
If you are running an instance, you can use the REDIS-CLI command
# View Current configuration
Config get save
# Close the snapshot
Config set save ""
To update the configuration online, the output OK indicates a successful setup.
AOF is more durable than snapshot mode, because Redis will write each of the received writes when using the AOF persistence mode.
Commands are appended to the file via the Write function (default is appendonly.aof). When a Redis reboot is performed by re-executing the file
Save the Write command to rebuild the contents of the entire database in memory
The default configuration is as follows:
AppendOnly Yes//enable log append persistence mode
#appendfsync always//write command is immediately forced to disk, the slowest, but guaranteed full persistence, not recommended
Appendfsync everysec//force write disk once per second, a good compromise in performance and persistence, recommended
#appendfsync no//full reliance on operating system, best performance, no guarantee of durability
We need to update the configuration file to:
Appendfsync No
Online Update configuration using
# View Current configuration
Config get Appendfsync
# Close the snapshot
Config set Appendfsync No
With these two configurations, Redis can run completely in memory.
If you want to persist manually, you can use Redis's bgsave and bgrewriteaof to manually persist.
Ubuntu 14.04 Redis installation and simple test http://www.linuxidc.com/Linux/2014-05/101544.htm
Redis Cluster Detail Document Http://www.linuxidc.com/Linux/2013-09/90118.htm
Installation of Redis under Ubuntu 12.10 (graphic) + Jedis connection Redis http://www.linuxidc.com/Linux/2013-06/85816.htm
Redis Series-Installation and deployment Maintenance Chapter Http://www.linuxidc.com/Linux/2012-12/75627.htm
CentOS 6.3 Installation Redis http://www.linuxidc.com/Linux/2012-12/75314.htm
Redis Installation Deployment Learning Note http://www.linuxidc.com/Linux/2014-07/104306.htm
Redis configuration file redis.conf detailed http://www.linuxidc.com/Linux/2013-11/92524.htm
a detailed introduction to Redis : please click here
Redis's Download address : please click here
This article permanently updates the link address : http://www.linuxidc.com/Linux/2015-01/111378.htm