In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "how to achieve persistence in redis". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
There are two ways to persist Redis:
1. Persistence of SnapShotting snapshots:
1. Persistent configuration:
This persistence is enabled by default, and all the data in Redis is saved to the hard disk at one time. If there is a lot of data (10-20g), it is not suitable for this persistence operation frequently.
The configuration information for snapshot persistence can be found in redis.conf, as follows:
Save 9001 initiates snapshot persistence if more than one key is modified within 900 seconds.
Save 30010 initiates snapshot persistence if more than 10 key are modified within 300 seconds.
Save 60 10000, initiates snapshot persistence if more than 10000 key are modified within 60 seconds.
The above three save means:
The frequency of data modification and backup is high.
The frequency of data modification is low and the frequency of backup is also low.
2. Persistent directory and file name:
3. Initiate snapshot persistence manually:
. / redis-cli bgsave
Second, Append Only File fine persistence (AOF):
1. Essence:
Each "write" instruction (add, modify, delete) executed by the user is backed up to a file, and the specific write instruction is executed when the data is restored. Is a more detailed and accurate persistence than snapshot persistence, so it is called fine persistence.
Note: enabling AOF persistence clears the data in Redis, so AOF persistence should be enabled before the Redis service starts to use.
2. Enable method: AOF persistence is disabled by default.
(1) change appendonly no to appendonly yes in redis.conf
(2) configure appendfilename appendonly.aof at the same time.
3. Aof backup frequency:
(1), appendfsync always: backup every time it is modified, which affects the performance of Redis and is rarely used.
(2), appendfsync no: look at whether the server is idle. If the server is idle, there are many uncertain factors and it is rarely used.
(3), appendfsync everysec: backup once a second, commonly used.
4. Optimized compression of aof backup files: bgrewriteaof, see the following screenshot: the size of appendonly.aof before optimization is 457, and that of appendonly.aof after optimization is 257
This is the end of "how to make redis persistent". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.