Redis configuration file redis.conf detailed configuration instructions

Source: Internet
Author: User
Tags allkeys compact
This article lists the configuration files of Redis redis.conf detailed description of the configuration items, simple and easy to understand, there is a need for the pot friends can refer to OH.

REDIS.CONF configuration items are described below

Redis configuration file in a detailed

# vi redis.confdaemonize Yes #是否以后台进程运行pidfile/var/run/redis/redis-server.pid #pid文件位置port 6379# listening port bind 127.0.0.1 #绑定  Address, such as the need to connect the external network, set 0.0.0.0timeout #连接超时时间, unit seconds loglevel notice #日志级别, respectively: # Debug: For development and Testing # verbose: More details # Notice: For production environments # Warning: Log only warnings or error messages Logfile/var/log/redis/redis-server.log #日志文件位置syslog-enabled no #是否将日志输出到系统日志databases 16# Set the number of databases, the default database is 0############### snapshot mode ############## #save 1 #在900s (15m), at least 1 key changes, after the snapshot save #在300s (5m), At least 10 key changes, the snapshot save 10000 #在60s (1m), at least 1000 key changes, the snapshot rdbcompression yes #dump时是否压缩数据dir/var/lib/redis # Database (DUMP.RDB) file directory ############### master-slave copy ############## #slaveof <masterip> <masterport> #主从复制使用, Used for native Redis as slave to connect main redismasterauth <master-password> #当master设置密码认证, Slave Use this option to specify the master authentication password Slave-serve-stale-data Yes #当slave与master之间的连接断开或slave正在与master进行数据同步时, if there is a slave request, when set to Yes, Slave still responds to the request, there may be a problem, and if no is set, slave returns the "SYNC with Master in progress" error message. Except for the info and slaveof commands. ############### Safety ############## #requirepass foobared #配置redis连接认证密码 ############### limit ############## #maxclients 128# Set the maximum number of connections, 0 for unrestricted maxmemory <bytes> #内存清理策略, if this value is reached, the following action will be taken: # Volatile-lru: Default Policy, only the LRU algorithm is removed for the key setting expiration # ALLKEYS-LRU : Delete infrequently used key# volatile-random: Randomly delete the expiring key# allkeys-random: Randomly delete a key# volatile-ttl: delete the key# noeviction that is about to expire: however, Write operation returned error maxmemory-policy volatile-lru# if MaxMemory value is reached, use this strategy Maxmemory-samples 3 #默认随机选择3个key, eliminate the most common ############# # # Additional mode ############## #appendonly no #AOF持久化, whether the update operation log is logged, the default Redis is asynchronous (snapshot) to write data to the local disk Appendfilename appendonly.aof # Specify the update log file name # AOF persistent three synchronization policies: # Appendfsync always #每次有数据发生变化时都会写入appendonly. aof# Appendfsync everysec #默认方式, Sync once per second to appendonly.aof# Appendfsync no #不同步, data is not persisted No-appendfsync-on-rewrite no #当AOF日志文件即将增长到指定百分比时, Redis automatically rewrites aof log files by calling Bgrewriteaof. ############### virtual Memory ############## #vm-enabled no #是否启用虚拟内存机制, virtual memory machine paging data, put rarely accessed pages on swap, memory consumption, It is best to turn off virtual memory Vm-swap-file/var/lib/redis/redis.swap #虚拟内存文件位置vm-max-memory 0 #redis使用的最大内存上限 to protect Redis from excessive use of physical memoryPerformance vm-page-size #每个页面的大小为32字节vm-pages 134217728 #设置swap文件中页面数量vm-max-threads 4 #访问swap文件的线程数 ############### Advanced Configuration # # # ########### #hash-max-zipmap-entries #哈希表中元素 (entries) Save space by using linear compact format storage when the total number of items does not exceed the set number Hash-max-zipmap-value 64 # A linear compact format is used to save space when the length of each value in the hash table does not exceed the number of bytes List-max-ziplist-entries 512 # List data type How many nodes below will use a compact storage format for pointers List-max-ziplist-value #list数据类型节点值大小小于多少字节会采用紧凑存储格式set-max-intset-entries 512 # Set data type internal data if all are numeric, and how many nodes are included the following will be stored in a compact format activerehashing Yes #是否激活重置哈希

Summarize:

1. Redis provides several persistence mechanisms :

a). Rdb persistence

How you work: Snapshot (Dump) data from Redis to Dump.rdb file based on time interval

Advantage: Backup recovery is simple. The RDB completes the persistence work through the sub-process, which is relatively more efficient than the AOF start

Disadvantage: Server failure will lose data in a few minutes

b). AoF Persistence

How it works: Log all update operations to the AOF log file, and read the log file when the Redis service restarts to rebuild the database to ensure data integrity after startup.

Advantage: AOF provides two kinds of synchronization mechanism, one is that Fsync always synchronizes to log files and Fsync everysec synchronize to log files every time with data changes, to ensure the maximum data integrity.

Disadvantage: The log file is much larger than the Rdb snapshot file

aof log rewrite function :

AoF log file is too large, Redis will automatically rewrite the AOF log, append mode continuously writes the update record to the old log file, and Redis also creates a new log file to append subsequent records.

c). Simultaneous application of aof and RDB

For scenarios with high data security, you can use both AOF and RDB, which can degrade performance.

d). No persistence

Disables the Redis service persistence feature.

2, aof log file after the error, repair method :

Redis-check-aof--fix appendonly.aof #--fix parameter for repairing log file, check for log without adding

3. Do not restart Redis from the RDB persistence switch to aof persistence :

redis-cli> Config set appendonly yes   #启用AOFredis-cli> config set save ""     #关闭RDB

The Redis configuration file provides a detailed list of Redis basic configuration items that are commonly used, and it is important to understand these configuration items using Redis

Related recommendations:

Redis configuration file redis.conf detailed

"Redis Notes" 4th: REDIS.CONF Replication Configuration Item Description

Why do I have to comment on the Save configuration item in redis.conf and the last write data in Redis after restarting the server?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.