In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the example analysis of the Redis configuration file redis.conf. The introduction in this article is very detailed and has certain reference value. Interested friends must read it!
The redis.conf configuration entry is described as follows
Redis configuration file details
# vi redis.confdaemonize yes #Run pidfile /var/run/redis/redis-server.pid #pid file location port 6379 #Listen on port bind 127.0.0.1 #Binding address, if external network needs connection, set 0.0.0timeout 300 #Connection timeout in seconds loglevel notice #Log levels, respectively: # debug: for development and testing # verbose: more details # notice: for production # warning: log only warnings or errors logfile/var/log/redis/redis-server.log #log file location sy-enabled no #whether to output logs to system log databases 16#set the number of databases, Default database is 0###############then snapshot rdbcompression yes #dump whether to compress data dir /var/lib/redis #database (dump.rdb) file storage directory #################slaveof #Master-slave copy used for native redis as slave to connect master redismasterauth #When master sets password authentication, slave specifies master authentication password with this option slave-serve-stale-data yes #When the connection between slave and master is disconnected or slave is synchronizing data with master, if there is a slave request, when set to yes, slave still responds to the request, there may be a problem, if set to no, slave will return "SYNC with master in progress" error message. Except for INFO and SLAVEOF commands.############### security ###############delete infrequently used keys # volatile-random: delete expiring keys # allkeys-random: delete a key# volatile-ttl: delete expiring keys # noeviction: Do not expire, write operation returns error maxmemory-policy volatile-lru#If maxmemory value is reached, adopt this policy maxmemory-samples3 #Default randomly selects 3 keys, Eliminate the least frequently used ################appendonly no #AOF persistence, whether to record update operation log, default redis asynchronous (snapshot) Write data to local disk appendfilename appendonly.aof #Specify update log file name # AOF persistence Three synchronization strategies: # appendfsync always #appendonly.aof# appendfsync everysec #default, sync once a second to appendonly.aof# appendfsync no #Out of sync, data will not persist no-appendfsync-on-rewrite no #Redis automatically overwrites AOF log files by calling BGREWRITEAOF when the AOF log file is about to grow to a specified percentage.############### ##################vm-enabled no #Whether to enable virtual memory mechanism, virtual memory machine will page data storage, rarely accessed pages on swap, memory consumption, it is best to turn off virtual memory vm-swap-file /var/lib/redis/redis.swap #virtual memory file location vm-max-memory 0 #maximum memory limit used by redis, Protecting redis from excessive use of physical memory affects performance vm-page-size 32 #Each page size is 32 bytes vm-pages 134217728 #Set the number of pages in the swap file vm-max-threads 4 #Number of threads accessing the swap file ###############hash-max-zipmap-entries 512 #When the total number of elements (entries) in the hash table does not exceed the set number, the linear compact format is used to save space. hash-max-zipmap-value 64 #When the length of each value in the hash table does not exceed the number of bytes, store it in a linear compact format to save space list-max-ziplist-entries 512 #list data type How many nodes will be stored in a compact format with pointers removed list-max-ziplist-value 64 #list data type How many bytes the node value size is less than will be stored in a compact format set-max-intset-entries 512 #set data type Internal data If all data are numeric, and how many nodes it contains The following stores activehashing yes in compact format #Whether to activate reset hash
Summary:
Redis provides several persistence mechanisms:
a). RDB Persistence
How it works: Snapshots (dumps) of data in redis to dump.rdb files at intervals of time
Benefits: Backup recovery is simple. RDB completes the persistence work through sub-processes, which is more efficient than AOF startup
Disadvantage: Server failure can result in loss of data within minutes
b). AOF Persistence
How it works: Record all update operations in the form of logs to the AOF log file, which will be read when the redis service restarts to rebuild the database to ensure data integrity after startup.
Advantages: AOF provides two synchronization mechanisms: fsync always synchronizes to log files every time there is a data change and fsync everysec synchronizes to log files once a second to maximize data integrity.
Disadvantages: Log files are much larger than RDB snapshot files
AOF log rewriting function:
If the AOF log file is too large, redis will automatically overwrite the AOF log, append mode will continuously write updated records to the old log file, and redis will also create a new log file for appending subsequent records.
c). Apply AOF and RDB simultaneously
For scenarios with high data security, you can use both AOF and RDB, which can degrade performance.
d). No persistence
Disable redis service persistence.
2. After AOF log file error, repair method:
redis-check-aof --fix appendonly.aof #--fix parameter is to repair log file, if not add, check log file
3. Switch from RDB persistence to AOF persistence without restarting redis:
redis-cli> CONFIG SET appendonly yes #Enable AOFredis-cli> CONFIG SET save "" #Close RDB Above is "Sample analysis of Redis configuration file redis.conf" All the contents of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
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.