redis.conf Configuration Details Chinese 2.8

Source: Internet
Author: User
Tags allkeys redis version rehash set background syslog system log strong password truncated

# Redis Version 2.8.19 # 1k = bytes
# 1kb = 1024x768 bytes
# 1m = 1000000 bytes
# 1MB = 1024*1024 bytes
# 1g = 1000000000 bytes
# 1gb = 1024*1024*1024 bytes # Only with the latest, so you can put it to the last. # include/path/to/local.conf
# include/path/to/other.conf ################################ Universal ##################################### # Whether the background executes the PID file daemonize Yes #
# pidfile/var/run/redis.pid # 0, TCP connection port 6379 # TCP Listen () backlog is not accepted. Although listen has two parameters int listen (int s, int backlog);  But the second parameter is overwritten by/proc/sys/net/core/somaxconn. For example, the Nginx set is 511, but it will be overwritten by the default 128,# so/etc/sysctl.conf to add Net.core.somaxconn = 2048 and then  sysctl-p, that is, If the software settings are larger than the Linux configuration, the Linux configuration, the software is set to less than Linux, the software is used, is the smallest one. Tcp-backlog 511 # bind IP Request source # bind 192.168.1.100 10.0.0.1 # close link after idle number of seconds (0 is disable this feature) timeout 0 # TCP keepalive# Linux kernel, the value below in seconds, equivalent to Tcp_keepalive_time, it takes twice the time to kill (the outside sound, that is, probes*intvl= the following values, see Evernote Search "Linux Online Server Optimization configuration") # Set to 60 better tcp-keepalive 0 # logging level debug "verbose" notice (production environment) Warningloglevel notice # log name. An empty string means output to standard output. The Redis standard output running in the background is/dev/null. (so you want to set a file name) logfile ""  # whether log to the system log. What is the mark? # syslog-enabled no# syslog-ident redis  #设置db的数量, default db is 0, you can use select <dbid> dbid in 0 to bottom value -1;databases 16  ################################ Snapshot ################################ # Save time interval, update quantity. If 1 keys are updated, 15min is saved once. 10 keys updated, 5 pointsClock is saved once, 10,000 keys are updated and saved every 1 minutes. Active call to save () will block all clients! is generally bgsave asynchronous. Save 1save 10save 10000 # If the last background save Rdb snapshot error, Redis rejects allWriteRequest. This is also the equivalent of an alarm bar. After the background save continues to work, Redis is allowed to write. # If you have your own configuration for the monitoring of the Redis persistence process, you can close the bottom: stop-writes-on-bgsave-error Yes # does it compress the. Rdb database after dump? Default compression. Saves the hard drive, but consumes the CPU. Rdbcompression No # Check the Rdb snapshot? The CRC64 checksum value is placed at the end of the file. can cause 10% performance degradation. When off, the checksum value is populated with 0 rdbchecksum Yes # DB name Dbfilename Dump.rdb # working directory # DB will be written to this directory with the top name. This directory will also exist for "Append files only". Note: This must be a directory name, not a file name! Dir./

################################# replica set ################################# # master-slave replication. Use slaveof to copy another redis. # 1) Redis replication is asynchronous. But you can let master Redis refuse to write requests when less than a certain number of Redis online. # 2) If the copy process pauses for a little while, slave can perform a partial resynchronization, and you can set the copy backlog size # 3) automatically, without intervention.  # slaveof <masterip> <masterport> # If the host needs authentication, you need to configure the password # Masterauth <master-password>  # when slave and master are broken, there are two things: # 1) Default: Slave-serve-stale-data Yes at this point, slave accept the request and return the old Data # 2) If it is no, then any command will return sync with Except for Master in Progress,info and slaveof commands! Slave-serve-stale-data yes # 2.6, the Redis default slave is read-only, but slave can execute all administrator commands by default. Config,debug and so on. You can use Rename-command to rename dangerous commands and hide them. Slave-read-only yes # Replication Set synchronization policy: disk or socket# new slave connection or old slave reconnect time can not only receive different, have to do a full synchronization. A new Rdb file needs to be dump out and then uploaded from master to slave. There are two scenarios: # 1) based on hard disk (disk-backed): Master creates a new process dump RDB, which is passed to slaves by the parent process (that is, the main process) increment. # 2) based on socket (diskless): Master creates a new process that directly dumps the RDB to the slave socket without passing through the main process without the hard drive. # based on the hard disk, when the Rdb file is created, once created, you can serve more slave at the same time. Based on the socket, after the new slave arrived, have to queue (if beyond the repl-diskless-sync-delay have not come), the end of a furtherOne. # when using diskless, master waiting for a repl-diskless-sync-delay seconds, if not slave to, then directly, then the queue to wait. Otherwise you can pass it together. # disk is slow, and the network is faster, you can use diskless. (Default with disk-based) Repl-diskless-sync no# is set to 0, the transfer starts Asaprepl-diskless-sync-delay 5 # slave send ping to master. Default 10s# repl-ping-slave-period 10 # time-out, including slave from Master, see Master from slave, larger than repl-ping-slave-period# above Repl-timeout 60 # Sync is complete, close tcp_nodelay in slave socket. # If Yes,reids sends a small amount of TCP packets to slave, it can result in a data delay of up to 40ms. # If it is no, it may consume a small amount of bandwidth when replicating. # By default we are set to no for low latency optimizations, and if there is a lot of network jumps between master and slave. Let's set it to Yes. Repl-disable-tcp-nodelay no # Replica Set background backlog size # The larger the slave, the longer it can be lost. # repl-backlog-size 1mb # How long it takes to release the backlog when confirming that master no longer needs slave. 0 is never released. # Repl-backlog-ttl 3600 # When Master is unavailable, Sentinel elects a master based on the priority of the slave. MostLowThe priority of the slave, elected master. and configureinto 0And will never be elected. (Must be ≥0). The default is 100slave-priority # slave is less than a few, and the network lag is more than a few seconds when master stops accepting the write request. The default number of slave is unlimited, giving 0. Network delay to 10s# min-slaves-to-write 3min-slaves-max-lag 10 ################################## Security ######################### ########### Most cases do not require a password identification slave. At the same time, because the Redis processing speed is too fast,Blasting RateUp to 150k/s. 100,000/S. So if you want to set a password, you must set a strong password. # Requirepass foobared <--This is the password # command rename # In a shared environment, you can rename a dangerous command, such as config: You can also use an empty string to achieve the purpose of completely masking this command. # rename-command config b840fc02d524045429941cc15f59e41cb7be6c52# rename-command config "" # Logging into aof or renaming to slave may cause problems. ################################### limit ##################################### To set the maximum number of client connections. Default of 1,000,010,000. If Redis cannot control the maximum number of files. To the lowest 32.# maxclients 10000 # If Redis uses more memory than the set limit, first, start by deleting data with Maxmemory-policy configured, if configured as Noeviction. All write will be rejected, such as Set,lpush. All read requests are acceptable. # used primarily in the LRU cache for Redis, or in a strategy where memory is tight and cannot be removed. # If you have slave, you should set the maximum memory to be too large, leave some system memory to slave output buffers (if it is a noeviction policy, you do not have to set up) # MaxMemory <bytes> # Memory policy. # Volatile-lru with LRU delete set TTL key# Allkeys-lru, with LRU delete any key# volatile-random, randomly delete ttl key# allkeys-random ---Random Delete any key# volatile-ttl---delete the TTL expires key# noeviction, do not delete, there is an error when write. # The following operation will return error # set SETNX Setex Append
# incr DECR rpush lpush rpushx lpushx linsert lset Rpoplpush sadd
# sinter Sinterstore sunion sunionstore sdiff sdiffstore zadd Zincrby
# zunionstore Zinterstore hset hsetnx hmset hincrby Incrby Decrby
#       getset mset msetnx exec sort# default is # Maxmemory-policy volatile-lru # LRU and minimum TTL are not the most accurate, but almost. The default Redis takes 3 keys at a time and then removes the most consistent deletion policy. You can configure this number. The lower the number, the more things will be removed. For example, set 100, you can delete 1%. # maxmemory-samples 3 ############################## AOF ################################ Default Redis asynchronous dump data to disk. But if the power is off, then some of the data will be lost (depending on the configuration of Save). # AOF provides a better mode. For example, the default Aof,redis only loses the last second of data (power outage), or the final write operation (Redis itself error, os OK). Each write operation is written once aof. # when the aof file is too large, Redis will automatically rewrite a aof file. # aof and RDB persistence can be enabled at the same time. Redis will first read aof recovery data. # Please check the http://redis.io/topics/persistence for more informationappendonly no # default file name Appendfilename " Appendonly.aof " # fsync () Three kinds: # No: Let OS be hosted, so faster. # always: Each write is brushed to log, slow, the most secure. # Everysec: Flush once per second. (default) # http://antirez.com/post/redis-persistence-demystified.html# Appendfsync alwaysappendfsync everysec# Appendfsync no # when Fsync is always or everysec, when a bgsave or aof rewrite thread is consuming a lot of i/0,redis it may block for a long time on Fsync. After this happens, you can't fix it, even if another thread runs Fsync, it will block our synchronous write method. # Here's how to solve this problem: when Bgsave () or BGrewriteaof () is running, Fsync () of the main process cannot be called. That is, when the child process is in save, that time is equivalent to Redis is appendaof No. That is, it is possible to lose up to 30s of log. # So if you have a lag problem, change the bottom to Yes, or use No. Yes means to suspend aof and reject this fsync of the main process. No is that Redis is queued and will not be prevent, but the main process is blocked. No-appendfsync-on-rewrite no # automatically overrides aof# when the aof file size is proportional, the bgrewriteaof# process is automatically called implicitly: Redis remembers the last timerewriteWhen the aof file size (not rewrite after reboot, is the size of the aof file at boot time), if the aof size and the last scale reached a specific value, then rewrite it. Also specify the minimum aof size to prevent up to twice times: 1M is also rewritten. # change the percentage to 0 to disable rewriting. Auto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64MB # aof file may not be complete at the end (last system shutdown has a problem, especially mount The data=ordered option is not added to the Ext4 file system. It only happens when the OS dies, and Redis itself is not completely dead. That's a problem when the Redis load comes into memory when it restarts. # When it happens, you can choose Redis to initiate an error, or load as much normal data as possible. # If aof-load-truncated is yes, it will automatically publish a log to the client and load (default). If it is no, the user must manually redis-check-aof repair the aof file before it can. aof-load-truncated Yes ################################ LUA SCRIPTING ################################ If the maximum time limit (in milliseconds) is reached, Redis logs a log and returns an error. # When a script exceeds the maximum time limit. Only script kill and shutdown Nosave can be used. The first thing to kill without a write command. If you have already called write, you can only kill with the second command. # set to 0 or negative, the time limit is infinite. Lua-time-limit ################################## SLOW LOG #################################### The length of time that a thread block cannot serve other requests. Two parameters: The first one is the length of the day in microseconds! , which is 1 per thousand of milliseconds. )。 The second is the size of log, and the previous log will be deleted. # 1000000 is a second.Negative ValueAll requests are recorded log! Below is 0.10S. 100 milliseconds. Slowlog-log-slower-than 10000 # Log Length setting value is unlimited. But memory is required. Slowlog-max-len 128 ################################ LATENCY MONITOR ############################### Use latency to print the time-consuming chart of Redis instances when running commands. # only actions that are greater than or equal to the values set below are logged. 0, is to turn off surveillance. Can be turned on dynamically. Directly run config SET latency-monitor-threshold <milliseconds>latency-monitor-threshold 0 #################### ######### Event Notification ############################### can notify the Pub/sub client about the change in key space. http://redis.io/topics/notifications#, for example, if you turn on the switch. A client performed a del operation on the "Foo" key on the DATABASE0. Two messages will be released via Pub/sub# publish [Email protected]__:foo del# PUBLISH [Email protected]__:del foo# Most people don't need this feature, and they need a certain amount of overhead, so it's off by default. Notify-keyspace-events ""  ############################### Advanced CONFIG ################################ Hash structure storage, the use of small data arrays, large data volume with map (encoding preservation structure information) hash-max-ziplist-entries 512hash-max-ziplist-value 64 # list Ibid. List-max-ziplist-entries 512list-max-ziplist-value 64 # set uses special encoding in one case: the entire set is a string, butSuddenly you need to become a 64-bit signed integer and 10 is the root: Don't understand. Set-max-intset-entries 512 # zset with setzset-max-ziplist-entries 128zset-max-ziplist-value 64 # HyperLogLog Don't understand. Greater than 16000 is totally unacceptable! When the CPU is very good to live, give 10000 can. By default, the more multiple operations 3000.hll-sparse-max-bytes 3000 # Active rehashing into the table being rehash, the more rehash steps need to be performed. If the Redis is idle, then the rehash operation is never stopped, and the more memory is consumed. # The default is to use Yes if you want to release the memory ASAP. activerehashing yes # client output buffer limit, which can be used to force the shutdown of slow-moving clients (such as Redis pub things with slower client not in time sub) # Client-output-buffer-limit <class> #
# Normal clients including MONITOR clients
# slave, slave clients
# pubsub-Clients subscribed to at least one pubsub channel or pattern# when hard is restricted to the client will be shut down immediately. If the soft limit is reached, it will wait soft seconds. # For example, the hard limit is 32m,soft is 16m,10secs. To 32m immediately break, or at 16m or more stop 10secs. # set to 0 is off. Client-output-buffer-limit Normal 0 0 0
Client-output-buffer-limit slave 256MB 64MB 60
Client-output-buffer-limit pubsub 32MB 8MB # redis Internal scheduling (client to close timeout, delete expired key, etc.) frequency, the higher the scheduling frequency. Setting it to more than 100 will cause great pressure on the CPU unless you have a high demand for online real-time. can be between 1~500. Hz 10 # When the child process is in the rewrite aof file, if this option is yes, then this file will write Fsync () per 32MB. This is a guaranteed incremental write drive and prevents the I/O burst when the hard drive is written. Aof-rewrite-incremental-fsync Yes

redis.conf Configuration Details Chinese 2.8

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.