In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Redis all data is kept in memory. Here are three backup methods:
1. Periodically save to disk asynchronously, which is called semi-persistent mode.
1) semi-persistent RDB mode is also the default method for Redis backup, which is done through snapshots. When the relevant conditions set in the redis.conf configuration file are met, Redis will automatically snapshot and store all the data in memory on the hard disk to complete the data backup.
2) the conditions of RDB snapshots are customized by the user in the redis.conf configuration file, determined by the time and the number of keywords changed. When the number of keys changed within a specified time is greater than the specified value, the snapshot will be taken. Here are three preset conditions, and as long as one of them is met, a snapshot will be taken.
When save 9001 # refreshes the snapshot to the hard drive, both requirements must be met before it will be triggered, that is, at least 1 keyword will change after 900 seconds.
Save 30010 # must be at least 10 keywords changed after 300 seconds.
Save 60 10000 # must be at least 10000 keywords changed after 60 seconds.
3) if automatic snapshots are disabled, delete or comment all save parameters.
4) obtain the path to save redis data:
127.0.0.1 purl 6379 > config get dir
"dir"
"/ usr/local/redis/bin"
5) it is recommended to modify the data storage path: # vim redis.conf
Dir. / # the directory where you install by default
Dir / data/redis # modified to a new path
Operation skills: the save path must be created before the configuration file will take effect, otherwise the redis service will be disabled
[root@redis_master /] # mkdir-p / data/redis
6) Test the storage effect of modified data
127.0.0.1 purl 6379 > config get dir
"dir"
"/ data/redis"
7) persistence is implemented in RDB mode. Once Redis exits abnormally, all data changed since the last snapshot will be lost.
two。 Fully persistent AOF mode
1) if the data is important and cannot lose any data, you can consider using AOF for persistence. The full persistence mode of AOF is not enabled by default in Redis.
2) AOF and RDB are allowed to be enabled at the same time, which ensures data security and makes backup and other operations very easy.
3) detailed description of parameter configuration:
Appendonly yes # enables AOF persistence
Appendifilename appendonly.aof # Save file name
Appendfsync always # synchronizes every time a write is performed, which is the safest and slowest
The meaning of the auto-aof-rewirte-percentage 100 # parameter is that when the current AOF file size exceeds how many percent of the file size of the last AOF rewrite, it will be rewritten again, if it has not been overridden before, based on the AOF file size at startup.
Auto-aof-rewrite-min-size 64MB # limits the minimum size of AOF files that are allowed to be rewritten.
Appendsync everysec # performs a synchronization operation every second.
Appendsync no # does not take the initiative to synchronize, once every 30s, which is the fastest and not the most secure.
3.Redis master-slave replication backup
1) through the persistence feature, it ensures that no or a small amount of data will be lost even if the server is restarted. However, because the data is stored on a server, if the hard disk of this server fails, it will also lead to data loss.
2) in order to avoid a single point of failure, replicate multiple copies of the database to be deployed on different servers, and other servers can continue to provide services even if one server fails. This requires that when the database on one server is updated, the updated data can be automatically synchronized to other servers.
3) the separation of read and write can be realized based on master-slave synchronization to improve the load capacity of the server.
4) the master database only operates, while the slave database is responsible for read operations.
5) Redis can be balanced and highly available based on LVS+keepalived.
6) when the master library crashes, it can be reduced to a slave library, and the slave library can also be upgraded to a master library.
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.